mlflow.projects

class mlflow.projects.EntryPoint(name, parameters, command)

Bases: object

An entry point in an MLproject specification.

compute_command(user_parameters, storage_dir)
compute_parameters(user_parameters, storage_dir)

Given a dict mapping user-specified param names to values, computes parameters to substitute into the command for this entry point. Returns a tuple (params, extra_params) where params contains key-value pairs for parameters specified in the entry point definition, and extra_params contains key-value pairs for additional parameters passed by the user.

Note that resolving parameter values can be a heavy operation, e.g. if a remote URI is passed for a parameter of type path, we download the URI to a local path within storage_dir and substitute in the local path as the parameter value.

exception mlflow.projects.ExecutionException

Bases: exceptions.Exception

class mlflow.projects.Parameter(name, yaml_obj)

Bases: object

A parameter in an MLproject entry point.

compute_value(user_param_value, storage_dir)
class mlflow.projects.Project(uri, yaml_obj)

Bases: object

A project specification loaded from an MLproject file.

get_entry_point(entry_point)
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, use_temp_cwd=False, storage_dir=None)

Run an MLflow project from the given URI in a new directory.

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.

Parameters:
  • 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 “databricks” or “local”
  • 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.
  • use_temp_cwd – Only used if mode is “local” and uri is a local directory. If True, copies project to a temporary working directory before running it. Otherwise (the default), runs project using uri (the project’s path) as the working directory.
  • storage_dir – Only used if mode is local. MLflow will download artifacts from distributed URIs passed to parameters of type ‘path’ to subdirectories of storage_dir.