Ejemplo n.º 1
0
    def test_creation_and_hydration(self):
        (ri1, run_id, experiment_id, user_id, status, start_time, end_time, lifecycle_stage,
         artifact_uri) = self._create()
        self._check(ri1, run_id, experiment_id, user_id, status, start_time, end_time,
                    lifecycle_stage, artifact_uri)
        as_dict = {
            "run_uuid": run_id,
            "run_id": run_id,
            "experiment_id": experiment_id,
            "user_id": user_id,
            "status": status,
            "start_time": start_time,
            "end_time": end_time,
            "lifecycle_stage": lifecycle_stage,
            "artifact_uri": artifact_uri
        }
        self.assertEqual(dict(ri1), as_dict)

        proto = ri1.to_proto()
        ri2 = RunInfo.from_proto(proto)
        self._check(ri2, run_id, experiment_id, user_id, status, start_time, end_time,
                    lifecycle_stage, artifact_uri)
        ri3 = RunInfo.from_dictionary(as_dict)
        self._check(ri3, run_id, experiment_id, user_id, status, start_time, end_time,
                    lifecycle_stage, artifact_uri)
        # Test that we can add a field to RunInfo and still deserialize it from a dictionary
        dict_copy_0 = as_dict.copy()
        dict_copy_0["my_new_field"] = "new field value"
        ri4 = RunInfo.from_dictionary(dict_copy_0)
        self._check(ri4, run_id, experiment_id, user_id, status, start_time, end_time,
                    lifecycle_stage, artifact_uri)
Ejemplo n.º 2
0
    def test_creation_and_hydration(self):
        (ri1, run_uuid, experiment_id, name, source_type, source_name,
         entry_point_name, user_id, status, start_time, end_time,
         source_version, artifact_uri) = self._create()
        self._check(ri1, run_uuid, experiment_id, name, source_type,
                    source_name, entry_point_name, user_id, status, start_time,
                    end_time, source_version, artifact_uri)
        as_dict = {
            "run_uuid": run_uuid,
            "experiment_id": experiment_id,
            "name": name,
            "source_type": source_type,
            "source_name": source_name,
            "entry_point_name": entry_point_name,
            "user_id": user_id,
            "status": status,
            "start_time": start_time,
            "end_time": end_time,
            "source_version": source_version,
            "artifact_uri": artifact_uri,
        }
        self.assertEqual(dict(ri1), as_dict)

        proto = ri1.to_proto()
        ri2 = RunInfo.from_proto(proto)
        self._check(ri2, run_uuid, experiment_id, name, source_type,
                    source_name, entry_point_name, user_id, status, start_time,
                    end_time, source_version, artifact_uri)
        ri3 = RunInfo.from_dictionary(as_dict)
        self._check(ri3, run_uuid, experiment_id, name, source_type,
                    source_name, entry_point_name, user_id, status, start_time,
                    end_time, source_version, artifact_uri)
Ejemplo n.º 3
0
def _read_persisted_run_info_dict(run_info_dict):
    dict_copy = run_info_dict.copy()
    if 'lifecycle_stage' not in dict_copy:
        dict_copy['lifecycle_stage'] = LifecycleStage.ACTIVE

    # 'experiment_id' was changed from int to string, so we must cast to string
    # when reading legacy run_infos
    if isinstance(dict_copy["experiment_id"], int):
        dict_copy["experiment_id"] = str(dict_copy["experiment_id"])
    return RunInfo.from_dictionary(dict_copy)
Ejemplo n.º 4
0
def _read_persisted_run_info_dict(run_info_dict):
    dict_copy = run_info_dict.copy()
    if 'lifecycle_stage' not in dict_copy:
        dict_copy['lifecycle_stage'] = LifecycleStage.ACTIVE
    # 'status' is stored as an integer enum in meta file, but RunInfo.status field is a string.
    # converting to string before hydrating RunInfo.
    # If 'status' value not recorded in files, mark it as 'RUNNING' (default)
    dict_copy['status'] = RunStatus.to_string(run_info_dict.get('status', RunStatus.RUNNING))

    # 'experiment_id' was changed from int to string, so we must cast to string
    # when reading legacy run_infos
    if isinstance(dict_copy["experiment_id"], int):
        dict_copy["experiment_id"] = str(dict_copy["experiment_id"])
    return RunInfo.from_dictionary(dict_copy)
Ejemplo n.º 5
0
def _read_persisted_run_info_dict(run_info_dict):
    dict_copy = run_info_dict.copy()
    if 'lifecycle_stage' not in dict_copy:
        dict_copy['lifecycle_stage'] = LifecycleStage.ACTIVE
    return RunInfo.from_dictionary(dict_copy)
Ejemplo n.º 6
0
 def get_run_info(run_dir):
     meta = read_yaml(run_dir, FileStore.META_DATA_FILE_NAME)
     return RunInfo.from_dictionary(meta)