def __init__(self, root_directory=None, artifact_root_uri=None): """ Create a new FileStore with the given root directory and a given default artifact root URI. """ super(FileStore, self).__init__() self.root_directory = local_file_uri_to_path(root_directory or _default_root_dir()) self.artifact_root_uri = artifact_root_uri or path_to_local_file_uri(self.root_directory) self.trash_folder = os.path.join(self.root_directory, FileStore.TRASH_FOLDER_NAME) # Create root directory if needed if not exists(self.root_directory): mkdir(self.root_directory) self._create_experiment_with_id(name=Experiment.DEFAULT_EXPERIMENT_NAME, experiment_id=FileStore.DEFAULT_EXPERIMENT_ID, artifact_uri=None) # Create trash folder if needed if not exists(self.trash_folder): mkdir(self.trash_folder)
def _check_root_dir(self): """ Run checks before running directory operations. """ if not exists(self.root_directory): raise Exception("'%s' does not exist." % self.root_directory) if not is_directory(self.root_directory): raise Exception("'%s' is not a directory." % self.root_directory)
def log_artifacts(self, local_dir, artifact_path=None): if artifact_path and path_not_unique(artifact_path): raise Exception("Invalid artifact path: '%s'. %s" % (artifact_path, bad_path_message(artifact_path))) artifact_dir = build_path(self.artifact_uri, artifact_path) \ if artifact_path else self.artifact_uri if not exists(artifact_dir): mkdir(artifact_dir) dir_util.copy_tree(src=local_dir, dst=artifact_dir)
def __init__(self, root_directory=None, artifact_root_uri=None): """ Create a new FileStore with the given root directory and a given default artifact root URI. """ super(FileStore, self).__init__() self.root_directory = root_directory or _default_root_dir() self.artifact_root_uri = artifact_root_uri or self.root_directory self.trash_folder = build_path(self.root_directory, FileStore.TRASH_FOLDER_NAME) # Create root directory if needed if not exists(self.root_directory): mkdir(self.root_directory) print("here") self._create_experiment_with_id( name="Default", experiment_id=Experiment.DEFAULT_EXPERIMENT_ID, artifact_uri=None) # Create trash folder if needed if not exists(self.trash_folder): mkdir(self.trash_folder)
def __init__(self, root_directory=None, artifact_root_dir=None): super(FileStore, self).__init__() self.root_directory = root_directory or _default_root_dir() self.artifact_root_dir = artifact_root_dir or self.root_directory # Create root directory if needed if not exists(self.root_directory): mkdir(self.root_directory) # Create default experiment if needed if not self._has_experiment( experiment_id=Experiment.DEFAULT_EXPERIMENT_ID): self._create_experiment_with_id( name="Default", experiment_id=Experiment.DEFAULT_EXPERIMENT_ID)
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)
def __init__(self, root_directory=None, artifact_root_uri=None): """ Create a new FileStore with the given root directory and a given default artifact root URI. """ super(FileStore, self).__init__() self.root_directory = root_directory or _default_root_dir() self.artifact_root_uri = artifact_root_uri or self.root_directory # Create root directory if needed if not exists(self.root_directory): mkdir(self.root_directory) # Create default experiment if needed if not self._has_experiment( experiment_id=Experiment.DEFAULT_EXPERIMENT_ID): self._create_experiment_with_id( name="Default", experiment_id=Experiment.DEFAULT_EXPERIMENT_ID)
def log_artifacts(self, local_dir, artifact_path): artifact_dir = build_path(self.artifact_uri, artifact_path) \ if artifact_path else self.artifact_uri if not exists(artifact_dir): mkdir(artifact_dir) dir_util.copy_tree(src=local_dir, dst=artifact_dir)
def log_artifact(self, local_file, artifact_path): artifact_dir = build_path(self.artifact_uri, artifact_path) \ if artifact_path else self.artifact_uri if not exists(artifact_dir): mkdir(artifact_dir) shutil.copy(local_file, artifact_dir)