Example #1
0
 def update_run_info(self, run_id, run_status, end_time):
     _validate_run_id(run_id)
     run_info = self._get_run_info(run_id)
     check_run_is_active(run_info)
     new_info = run_info._copy_with_overrides(run_status, end_time)
     self._overwrite_run_info(new_info)
     return new_info
Example #2
0
 def delete_run(self, run_id):
     run_info = self._get_run_info(run_id)
     if run_info is None:
         raise MlflowException(
             "Run '%s' metadata is in invalid state." % run_id,
             databricks_pb2.INVALID_STATE)
     check_run_is_active(run_info)
     new_info = run_info._copy_with_overrides(
         lifecycle_stage=LifecycleStage.DELETED)
     self._overwrite_run_info(new_info)
Example #3
0
 def log_batch(self, run_id, metrics, params, tags):
     _validate_run_id(run_id)
     _validate_batch_log_data(metrics, params, tags)
     _validate_batch_log_limits(metrics, params, tags)
     run_info = self._get_run_info(run_id)
     check_run_is_active(run_info)
     try:
         for param in params:
             self._log_run_param(run_info, param)
         for metric in metrics:
             self._log_run_metric(run_info, metric)
         for tag in tags:
             self._set_run_tag(run_info, tag)
     except Exception as e:
         raise MlflowException(e, INTERNAL_ERROR)
Example #4
0
 def delete_tag(self, run_id, key):
     """
     Delete a tag from a run. This is irreversible.
     :param run_id: String ID of the run
     :param key: Name of the tag
     """
     _validate_run_id(run_id)
     run_info = self._get_run_info(run_id)
     check_run_is_active(run_info)
     tag_path = self._get_tag_path(run_info.experiment_id, run_id, key)
     if not exists(tag_path):
         raise MlflowException(
             "No tag with name: {} in run with id {}".format(key, run_id),
             error_code=RESOURCE_DOES_NOT_EXIST)
     os.remove(tag_path)
Example #5
0
    def record_logged_model(self, run_id, mlflow_model):
        if not isinstance(mlflow_model, Model):
            raise TypeError(
                "Argument 'mlflow_model' should be mlflow.models.Model, got '{}'"
                .format(type(mlflow_model)))
        _validate_run_id(run_id)
        run_info = self._get_run_info(run_id)
        check_run_is_active(run_info)
        model_dict = mlflow_model.to_dict()
        run_info = self._get_run_info(run_id)
        path = self._get_tag_path(run_info.experiment_id, run_info.run_id,
                                  MLFLOW_LOGGED_MODELS)
        if os.path.exists(path):
            with open(path, "r") as f:
                model_list = json.loads(f.read())
        else:
            model_list = []
        tag = RunTag(MLFLOW_LOGGED_MODELS,
                     json.dumps(model_list + [model_dict]))

        try:
            self._set_run_tag(run_info, tag)
        except Exception as e:
            raise MlflowException(e, INTERNAL_ERROR)
Example #6
0
 def set_tag(self, run_id, tag):
     _validate_run_id(run_id)
     _validate_tag_name(tag.key)
     run_info = self._get_run_info(run_id)
     check_run_is_active(run_info)
     self._set_run_tag(run_info, tag)
Example #7
0
 def log_param(self, run_id, param):
     _validate_run_id(run_id)
     _validate_param_name(param.key)
     run_info = self._get_run_info(run_id)
     check_run_is_active(run_info)
     self._log_run_param(run_info, param)
Example #8
0
 def log_metric(self, run_id, metric):
     _validate_run_id(run_id)
     _validate_metric_name(metric.key)
     run_info = self._get_run_info(run_id)
     check_run_is_active(run_info)
     self._log_run_metric(run_info, metric)