Пример #1
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, tags, 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, tags, 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,
            "tags": tags,
            "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, tags, 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, tags, artifact_uri)
Пример #2
0
 def create_run(self, experiment_id, user_id, run_name, source_type,
                source_name, entry_point_name, start_time, source_version,
                tags):
     """
     Creates a run with the specified attributes.
     """
     if self.get_experiment(experiment_id) is None:
         raise Exception(
             "Could not create run under experiment with ID %s - no such experiment "
             "exists." % experiment_id)
     run_uuid = uuid.uuid4().hex
     artifact_uri = self._get_artifact_dir(experiment_id, run_uuid)
     num_runs = len(self._list_run_uuids(experiment_id))
     run_info = RunInfo(run_uuid=run_uuid,
                        experiment_id=experiment_id,
                        name="Run %s" % num_runs,
                        artifact_uri=artifact_uri,
                        source_type=source_type,
                        source_name=source_name,
                        entry_point_name=entry_point_name,
                        user_id=user_id,
                        status=RunStatus.RUNNING,
                        start_time=start_time,
                        end_time=None,
                        source_version=source_version,
                        tags=tags)
     # Persist run metadata and create directories for logging metrics, parameters, artifacts
     run_dir = self._get_run_dir(run_info.experiment_id, run_info.run_uuid)
     mkdir(run_dir)
     write_yaml(run_dir, FileStore.META_DATA_FILE_NAME, dict(run_info))
     mkdir(run_dir, FileStore.METRICS_FOLDER_NAME)
     mkdir(run_dir, FileStore.PARAMS_FOLDER_NAME)
     mkdir(run_dir, FileStore.ARTIFACTS_FOLDER_NAME)
     return Run(run_info=run_info, run_data=None)
Пример #3
0
 def from_dictionary(cls, the_dict):
     if "info" not in the_dict or "data" not in the_dict:
         raise Exception(
             "Malformed input '%s'. Run cannot be constructed." %
             str(the_dict))
     the_info = RunInfo.from_dictionary(the_dict.get("info"))
     the_data = RunData.from_dictionary(the_dict.get("data"))
     return cls(the_info, the_data)
Пример #4
0
 def _create():
     run_uuid = str(uuid.uuid4())
     experiment_id = random_int(10, 2000)
     name = random_str(random_int(10, 40))
     source_type = random_int(1, 4)
     source_name = random_str(random_int(100, 300))
     entry_point_name = random_str(random_int(100, 300))
     user_id = random_str(random_int(10, 25))
     status = random_int(1, 5)
     start_time = random_int(1, 10)
     end_time = start_time + random_int(1, 10)
     source_version = random_str(random_int(10, 40))
     tags = [RunTag(key=random_str(random_int(1, 5)), value=random_str(random_int(1, 5)))
             for _ in range(2)]
     artifact_uri = random_str(random_int(10, 40))
     ri = RunInfo(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, tags=tags, artifact_uri=artifact_uri)
     return (ri, run_uuid, experiment_id, name, source_type, source_name, entry_point_name,
             user_id, status, start_time, end_time, source_version, tags, artifact_uri)
Пример #5
0
 def from_proto(cls, proto):
     return cls(RunInfo.from_proto(proto.info), RunData.from_proto(proto.data))
Пример #6
0
 def get_run_info(run_dir):
     meta = read_yaml(run_dir, FileStore.META_DATA_FILE_NAME)
     return RunInfo.from_dictionary(meta)
Пример #7
0
 def update_run_info(self, run_uuid, run_status, end_time):
     """ Updates the metadata of the specified run. """
     req_body = _message_to_json(
         UpdateRun(run_uuid=run_uuid, status=run_status, end_time=end_time))
     response_proto = self._call_endpoint(UpdateRun, req_body)
     return RunInfo.from_proto(response_proto.run_info)