Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli support for delete and restore + docs #367

Merged
merged 6 commits into from Aug 27, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 36 additions & 2 deletions docs/source/cli.rst
Expand Up @@ -21,7 +21,7 @@ and list experiments, and download artifacts.
Commands:
azureml Serve models on Azure ML.
download Download the artifact at the specified DBFS or S3 URI.
experiments Run and list experiments.
experiments Manage experiments.
pyfunc Serve Python models locally.
run Run an MLflow project from the given URI.
sagemaker Serve models on Amazon SageMaker.
Expand Down Expand Up @@ -49,7 +49,41 @@ specified.
Experiments
-----------

Subcommands to create and list experiments.
Subcommands to manage experiments.


Create
------
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs to be a separate kind of header from ---- to render correctly in the docs, since it's under Experiments. Right now these will look like the same level of heading. You can look at the Sphinx/RST docs to see the hierarchy of headings allowed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might also be possible to just make this a bulleted list instead of sections, since there's a lot of detail about each one.

Copy link
Collaborator Author

@mparkhe mparkhe Aug 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! I misread the documentations. Subsections are marked with "~" . Patching coming soon.

I had initially tried the bullet route, but it looked a bit bulky.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed:

image

Subcommand to create a new experiment using name. System will generate a unique ID for each
experiment. Additionally, users can provide an artifact location using ``-l`` or
``--artifact-location`` option. If not provided, backend store will pick default location.

All artifacts related to this experiment will be stored under artifact location under specific
run directories.


List
----

Listing of all experiments managed by backend store.


Delete
------

Delete an active experiment. Command takes an mandatory argument experiment ID. If experiment
is already deleted or not found, the command will throw error. This deletes associated metadata,
runs and data as well. If the backend store controls locations of artifacts, they will be deleted
as well. Deleted experiments can be restored using ``restore`` command.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe talk about how they can clear the trash here? Can also recommend setting up a cron job or something.



Restore
-------

Restore a deleted experiment. Command takes an mandatory argument experiment ID. If experiment is
already active, permanently deleted, or cannot be found, the command will throw error. The command
will restore all runs belonging to the experiment and all metadata associated with experiment and
runs.


Python Function
Expand Down
26 changes: 25 additions & 1 deletion mlflow/experiments.py
Expand Up @@ -38,7 +38,31 @@ def list_experiments():
List all experiments in the configured tracking server.
"""
store = _get_store()
experiments = store.list_experiments()
experiments = store.list_experiments("deleted_only")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ToDo : fix this. Should default to active_only

table = [[exp.experiment_id, exp.name, exp.artifact_location if is_uri(exp.artifact_location)
else os.path.abspath(exp.artifact_location)] for exp in experiments]
print(tabulate(sorted(table), headers=["Experiment Id", "Name", "Artifact Location"]))


@commands.command("delete")
@click.argument("experiment_id")
def delete_experiment(experiment_id):
"""
Delete an experiment from backend store.
Will error out if experiment does not exist or already deleted.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This help should say that you mark it for deletion. Experiments marked this way can be restored with restore, or cleared based on the backend store (refer to docs for that).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

"""
store = _get_store()
store.delete_experiment(experiment_id)
print("Experiment with id %s has been deleted." % str(experiment_id))


@commands.command("restore")
@click.argument("experiment_id")
def restore_experiment(experiment_id):
"""
Restore a deleted experiment.
Will error out if experiment is already active or has been permanently deleted.
"""
store = _get_store()
store.restore_experiment(experiment_id)
print("Experiment with id %s has been restored and is now active." % str(experiment_id))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd remove the "is now active".

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done