Exemple #1
0
def _read_persisted_experiment_dict(experiment_dict):
    dict_copy = experiment_dict.copy()

    # 'experiment_id' was changed from int to string, so we must cast to string
    # when reading legacy experiments
    if isinstance(dict_copy['experiment_id'], int):
        dict_copy['experiment_id'] = str(dict_copy['experiment_id'])
    return Experiment.from_dictionary(dict_copy)
Exemple #2
0
 def _get_experiment(self, experiment_id, view_type=ViewType.ALL):
     self._check_root_dir()
     experiment_dirs = self._get_experiment_path(experiment_id, view_type)
     if len(experiment_dirs) == 0:
         raise Exception("Could not find experiment with ID %s" %
                         experiment_id)
     meta = read_yaml(experiment_dirs[0], FileStore.META_DATA_FILE_NAME)
     return Experiment.from_dictionary(meta)
Exemple #3
0
 def _get_experiment(self, experiment_id, view_type=ViewType.ALL):
     self._check_root_dir()
     experiment_dir = self._get_experiment_path(experiment_id, view_type)
     if experiment_dir is None:
         raise Exception("Could not find experiment with ID %s" %
                         experiment_id)
     meta = read_yaml(experiment_dir, FileStore.META_DATA_FILE_NAME)
     if experiment_dir.startswith(self.trash_folder):
         meta['lifecycle_stage'] = Experiment.DELETED_LIFECYCLE
     else:
         meta['lifecycle_stage'] = Experiment.ACTIVE_LIFECYCLE
     return Experiment.from_dictionary(meta)
Exemple #4
0
def _dict_to_experiment(experiment_dict):
    dict_copy = experiment_dict.copy()

    # 'experiment_id' was changed from int to string, so we must cast to string
    # when reading legacy experiments
    if isinstance(dict_copy["experiment_id"], int):
        dict_copy["experiment_id"] = str(dict_copy["experiment_id"])
    # Turn the key/value tags into list of experiment tags
    if "tags" in dict_copy:
        dict_copy["tags"] = [
            ExperimentTag(kv[0], kv[1]) for kv in dict_copy["tags"].items()
        ]
    return Experiment.from_dictionary(dict_copy)
Exemple #5
0
    def test_creation_and_hydration(self):
        exp_id = random_int()
        name = "exp_%d_%d" % (random_int(), random_int())
        location = random_file(".json")

        exp = Experiment(exp_id, name, location)
        self._check(exp, exp_id, name, location)

        as_dict = {"experiment_id": exp_id, "name": name, "artifact_location": location}
        self.assertEqual(dict(exp), as_dict)

        proto = exp.to_proto()
        exp2 = Experiment.from_proto(proto)
        self._check(exp2, exp_id, name, location)

        exp3 = Experiment.from_dictionary(as_dict)
        self._check(exp3, exp_id, name, location)
Exemple #6
0
 def _get_experiment(self, experiment_id, view_type=ViewType.ALL):
     self._check_root_dir()
     _validate_experiment_id(experiment_id)
     experiment_dir = self._get_experiment_path(experiment_id, view_type)
     if experiment_dir is None:
         raise MlflowException("Could not find experiment with ID %s" % experiment_id,
                               databricks_pb2.RESOURCE_DOES_NOT_EXIST)
     meta = read_yaml(experiment_dir, FileStore.META_DATA_FILE_NAME)
     if experiment_dir.startswith(self.trash_folder):
         meta['lifecycle_stage'] = Experiment.DELETED_LIFECYCLE
     else:
         meta['lifecycle_stage'] = Experiment.ACTIVE_LIFECYCLE
     experiment = Experiment.from_dictionary(meta)
     if int(experiment_id) != experiment.experiment_id:
         logging.warning("Experiment ID mismatch for exp %s. ID recorded as '%s' in meta data. "
                         "Experiment will be ignored.",
                         str(experiment_id), str(experiment.experiment_id), exc_info=True)
         return None
     return experiment
    def test_creation_and_hydration(self):
        exp_id = str(random_int())
        name = "exp_%d_%d" % (random_int(), random_int())
        lifecycle_stage = LifecycleStage.ACTIVE
        location = random_file(".json")

        exp = Experiment(exp_id, name, location, lifecycle_stage)
        self._check(exp, exp_id, name, location, lifecycle_stage)

        as_dict = {
            "experiment_id": exp_id,
            "name": name,
            "artifact_location": location,
            "lifecycle_stage": lifecycle_stage
        }
        self.assertEqual(dict(exp), as_dict)

        proto = exp.to_proto()
        exp2 = Experiment.from_proto(proto)
        self._check(exp2, exp_id, name, location, lifecycle_stage)

        exp3 = Experiment.from_dictionary(as_dict)
        self._check(exp3, exp_id, name, location, lifecycle_stage)
Exemple #8
0
 def _get_experiment(experiment_dir_path):
     meta = read_yaml(experiment_dir_path, FileStore.META_DATA_FILE_NAME)
     return Experiment.from_dictionary(meta)