def _compute_path_value(self, user_param_value, storage_dir): local_path = get_local_path_or_none(user_param_value) if local_path: if not os.path.exists(local_path): raise ExecutionException("Got value %s for parameter %s, but no such file or " "directory was found." % (user_param_value, self.name)) return os.path.abspath(local_path) basename = os.path.basename(user_param_value) dest_path = os.path.join(storage_dir, basename) if dest_path != user_param_value: data.download_uri(uri=user_param_value, output_path=dest_path) return os.path.abspath(dest_path)
def _compute_path_value(self, user_param_value, storage_dir, key_position): local_path = get_local_path_or_none(user_param_value) if local_path: if not os.path.exists(local_path): raise ExecutionException( "Got value %s for parameter %s, but no such file or " "directory was found." % (user_param_value, self.name)) return os.path.abspath(local_path) target_sub_dir = "param_{}".format(key_position) download_dir = os.path.join(storage_dir, target_sub_dir) os.mkdir(download_dir) return artifact_utils._download_artifact_from_uri( artifact_uri=user_param_value, output_path=download_dir)
def _get_docker_command(image, active_run): docker_path = "docker" cmd = [docker_path, "run", "--rm"] env_vars = _get_run_env_vars(run_id=active_run.info.run_id, experiment_id=active_run.info.experiment_id) tracking_uri = tracking.get_tracking_uri() local_path, container_tracking_uri = _get_local_uri_or_none(tracking_uri) artifact_uri_local_path = get_local_path_or_none( active_run.info.artifact_uri) if local_path is not None: cmd += ["-v", "%s:%s" % (local_path, _MLFLOW_DOCKER_TRACKING_DIR_PATH)] env_vars[tracking._TRACKING_URI_ENV_VAR] = container_tracking_uri if artifact_uri_local_path is not None: container_path = artifact_uri_local_path if not os.path.isabs(container_path): container_path = os.path.join("/mlflow/projects/code/", artifact_uri_local_path) container_path = os.path.normpath(container_path) artifact_uri_local_abspath = os.path.abspath(artifact_uri_local_path) cmd += ["-v", "%s:%s" % (artifact_uri_local_abspath, container_path)] if tracking.utils._is_databricks_uri(tracking_uri): db_profile = mlflow.tracking.utils.get_db_profile_from_uri( tracking_uri) config = databricks_utils.get_databricks_host_creds(db_profile) # We set these via environment variables so that only the current profile is exposed, rather # than all profiles in ~/.databrickscfg; maybe better would be to mount the necessary # part of ~/.databrickscfg into the container env_vars[tracking._TRACKING_URI_ENV_VAR] = 'databricks' env_vars['DATABRICKS_HOST'] = config.host if config.username: env_vars['DATABRICKS_USERNAME'] = config.username if config.password: env_vars['DATABRICKS_PASSWORD'] = config.password if config.token: env_vars['DATABRICKS_TOKEN'] = config.token if config.ignore_tls_verification: env_vars['DATABRICKS_INSECURE'] = config.ignore_tls_verification for key, value in env_vars.items(): cmd += ["-e", "{key}={value}".format(key=key, value=value)] cmd += [image.tags[0]] return cmd