mlflow_extra package

Submodules

mlflow_extra.common module

Common functionality.

mlflow_extra.common.configure_logging(level=20)[source]

Configure logging.

Parameters:

level – The logging level.

mlflow_extra.filter module

Delete suboptimal runs.

mlflow_extra.filter.delete_runs(run_ids, total_runs, confirm=False)[source]

Delete the selected runs

Parameters:
  • run_ids – An iterable of run IDs to delete.

  • total_runs – The total number of runs in the data, only used for display.

  • confirm – If True, delete the run, else perform a dryrun.

Returns:

True if anything was deleted, False otherwise.

mlflow_extra.filter.export_csv(experiment_id, path)[source]

Export experiment data to a CSV file.

Parameters:
  • experiment_id – The experiment ID.

  • path – The output path.

mlflow_extra.filter.filter_by_number(data, columns, number, ascending=False)[source]

Filter rows to only keep a selected number.

Parameters:
  • data – The data to filter.

  • columns – The columns by which to filter the data before selecting the rows.

  • number – The number of rows to keep.

  • ascending – If True, sort the data in ascending order before selecting the rows to keep, otherwise sort in descending order.

mlflow_extra.filter.filter_by_threshold(data, thresholds, ascending=False)[source]

Filter rows in data by threshold values.

Parameters:
  • data – The data to filter.

  • thresholds – A dict mapping column names to threshold values.

  • ascending – If True, keep values less than or equal to the thresold values, otherwise keep values greater than or equal to the threshold values.

mlflow_extra.filter.list_metrics(data)[source]

Print metric data to STDOUT.

Parameters:

data – The data loaded from the CSV file.

mlflow_extra.filter.script_filter_runs(args=None)[source]

Delete runs from experiment based on thresholds.

mlflow_extra.merge module

Merge experiments into a common directory.

mlflow_extra.merge.collect_experiment_names(path)[source]

Collect all experiment names from the experiment directories under the given path.

Parameters:

path – The directory path containing the experiment directories.

Returns:

A dict mapping experiment names to lists of experiment directory paths.

mlflow_extra.merge.copy_experiments(src_path, dst_path)[source]

Copy experiments from one path to another.

Parameters:
  • src_path – The source directory from which to move the experiments.

  • dst_path – The target directory to which to move the experiments.

mlflow_extra.merge.fix_artifact_uris(path, map_path=None)[source]

Update artifact URIs for all experiments and runs under the given path.

Parameters:
  • path – The path containing the experiments to fix.

  • map_path – An optional path to a YAML file that maps old paths to new ones.

mlflow_extra.merge.fix_experiment_ids(path)[source]

Fix the experiment IDs for the experiment and all runs under the given path. This will ensure that the experiment ID is a non-negative integer and that the ID matches the experiment’s directory name. The directory will be moved if necessary.

Parameters:

path – The path to the experiment directory.

mlflow_extra.merge.merge_experiments_by_name(path)[source]

Merge runs from experiments with the same name into a single experiment.

Parameters:

path – The directory path containing the experiment directories.

mlflow_extra.merge.reorder_experiment_ids(path)[source]

Reorder all of the experiment IDs in a directory by their creation time.

mlflow_extra.merge.script_fix_artifact_uris(args=None)[source]

Attempt to fix broken artifact URIs in experiments and runs.

mlflow_extra.merge.script_fix_experiment_ids(args=None)[source]

Attempt to fix experiment IDs so that the experiment’s directory and all of its runs match its ID.

mlflow_extra.merge.script_merge_experiments(args=None)[source]

Copy experiments into a common MLflow directory. Runs from experiments with the same name will be merged.

mlflow_extra.merge.update_experiment_ids(path, new_id)[source]

Update the experiment ID in all metadata files under the given path.

Parameters:
  • path – The path under which to update the experiment IDs.

  • new_id – The new experiment ID.

mlflow_extra.metadata module

Find and manipulate MLflow metadata files.

class mlflow_extra.metadata.Metadata(path=None, data=None)[source]

Bases: object

Metadata wrapper.

FIELD_ARTIFACT_LOCATION = 'artifact_location'[source]
FIELD_ARTIFACT_URI = 'artifact_uri'[source]
FIELD_CREATION_TIME = 'creation_time'[source]
FIELD_EXPERIMENT_ID = 'experiment_id'[source]
FIELD_LAST_UPDATE_TIME = 'last_update_time'[source]
FIELD_LIFECYCLE_STAGE = 'lifecycle_stage'[source]
FIELD_NAME = 'name'[source]
FILENAME = 'meta.yaml'[source]
__init__(path=None, data=None)[source]
Parameters:
  • path – The path to a metadata file, or a directory that contains one. If not None, then the data will be loaded from the path unless data is also passed via the data parameter.

  • data – The data. If not None, then the path will not be loaded.

property artifact_uri[source]

The artifact URI or equivalent

property creation_time[source]

The creation time

property experiment_id[source]

The experiment ID

find_meta(path)[source]

Find all MLflow metadata files in the given directory.

Parameters:

path – The directory path.

Returns:

A generator over the metadata file paths as pathlib.Path objects.

property is_experiment[source]

True if the current metadata appears to be for an experiment and not a run.

property last_update_time[source]

The last update time

property lifecycle_stage[source]

The lifecycle stage

load(path=None)[source]

Load data from a YAML file.

Parameters:

path – The filepath. If None, the current path will be used.

property name[source]

The name

static non_negative_int(value)[source]

Check that the given value is a non-negative integer.

Parameters:

value – The value to check.

Returns:

The value as an int.

Raises:

ValueError – The value could not be converted to a non-negative int.

save(path=None)[source]

Save data to a YAML file.

Parameters:

path – The filepath. If None, the current path will be used.

mlflow_extra.uri module

URI manipulation.

class mlflow_extra.uri.URITransformer(uri)[source]

Bases: object

Transform URIs, including file paths.

__init__(uri)[source]
property is_local_file[source]

True if the URI points to a local path, else False. The path may not exist.

property path[source]

The URI path component

property scheme[source]

The URI scheme.

mlflow_extra.version module

Module contents

File stub.