mlflow.projects
APIs for running MLflow projects locally or remotely.
-
exception
mlflow.projects.
ExecutionException
Bases:
exceptions.Exception
Exception thrown when executing a project fails.
-
mlflow.projects.
run
(uri, entry_point='main', version=None, parameters=None, experiment_id=None, mode=None, cluster_spec=None, git_username=None, git_password=None, use_conda=True, storage_dir=None, block=True, run_id=None) Run an MLflow project from the given URI.
Supports downloading projects from Git URIs with a specified version, or copying them from the file system. For Git-based projects, a commit can be specified as the
version
.Raises: mlflow.projects.ExecutionException – if a run launched in blocking mode is unsuccessful.
Parameters: - uri – URI of project to run. Expected to be either a relative/absolute local filesystem path or a git repository URI (e.g. https://github.com/mlflow/mlflow-example) pointing to a project directory containing an MLproject file.
- entry_point – Entry point to run within the project. If no entry point with the specified
name is found, attempts to run the project file
entry_point
as a script, using “python” to run .py files and the default shell (specified by environment variable $SHELL) to run .sh files. - experiment_id – ID of experiment under which to launch the run.
- mode – Execution mode for the run. Can be set to “local” or “databricks”.
- cluster_spec – Path to JSON file describing the cluster to use when launching a run on Databricks.
- git_username – Username for HTTP(S) authentication with Git.
- git_password – Password for HTTP(S) authentication with Git.
- use_conda – If True (the default), creates a new Conda environment for the run and installs project dependencies within that environment. Otherwise, runs the project in the current environment without installing any project dependencies.
- storage_dir – Only used if
mode
is local. MLflow will download artifacts from distributed URIs passed to parameters of type ‘path’ to subdirectories ofstorage_dir
. - block – Whether or not to block while waiting for a run to complete. Defaults to True.
Note that if
block
is False and mode is “local”, this method will return, but the current process will block when exiting until the local run completes. If the current process is interrupted, any asynchronous runs launched via this method will be terminated. - run_id – Note: this argument is used internally by the MLflow project APIs and should not be specified. If specified, the given run ID will be used instead of creating a new run.
Returns: A
SubmittedRun
exposing information (e.g. run ID) about the launched run. The returnedSubmittedRun
is not thread-safe.