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

Add rename_experiment Tracking API, along with integration tests #570

Merged
merged 6 commits into from Oct 8, 2018

Conversation

aarondav
Copy link
Contributor

@aarondav aarondav commented Sep 28, 2018

Adds a new REST API called UpdateExperiment which currently only supports changing name via setting new_name, but may be able to mutate other properties in the future. Exposed to users via the tracking API is just rename_experiment to change the name -- the is similar to how set_terminated works on runs today.

Also added support in the Python & Java Tracking APIs and file store, and experiments CLI.

Finally, in adding this I realized that although there are Java client integration tests, there are no tests which spin up a REST store and make end-to-end calls via the tracking API (in other words, the tracking API is not tested). To deal with this, I wrote an integration test at this level.

I think in general the expectation should be if you want to add a new API, you will have to add unit tests to the file store (backing implementation) and integration tests in the Java and Python Tracking API code.

@@ -27,6 +27,9 @@ def name(self):
"""String name of the experiment."""
return self._name

def _set_name(self, new_name):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Needed internally to mutate in file store.

@@ -133,6 +133,24 @@ public long createExperiment(String experimentName) {
return mapper.toCreateExperimentResponse(ojson).getExperimentId();
}

/** Mark an experiment and associated runs, params, metrics, etc for deletion. */
public void deleteExperiment(long experimentId) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also added delete & restore experiment to Java Tracking API (already exists in Python API).

@@ -93,30 +112,6 @@ String toJson(MessageOrBuilder mb) {
return builder.build();
}

GetMetric.Response toGetMetricResponse(String json) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed these unused methods, can always add them back later when they're used.

@@ -36,6 +36,6 @@ public static void assertTag(List<RunTag> tags, String key, String value) {
}

static public String createExperimentName() {
return "TestExp_" + UUID.randomUUID().toString();
return "JavaTestExp_" + UUID.randomUUID().toString();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just to help people grep for code.

// ID of the associated experiment.
optional int64 experiment_id = 1 [(validate_required) = true];

// If provided, the experiment's name will be changed to this. The new name must be unique.
optional string new_name = 2;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Used new_name to distinguish from the fact that we sometimes use experiment_name as an identifier for an experiment.

@@ -57,8 +57,8 @@ def create_run(self, experiment_id, user_id=None, run_name=None, source_type=Non
experiment_id=experiment_id,
user_id=user_id if user_id is not None else _get_user_id(),
run_name=run_name,
source_type=source_type,
source_name=source_name,
source_type=source_type if source_type is not None else SourceType.LOCAL,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added sane defaults here to look closer to the Java API; otherwise, create_run(experiment_id) does not work. Found via the integration test!

@codecov-io
Copy link

codecov-io commented Sep 29, 2018

Codecov Report

Merging #570 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #570   +/-   ##
=======================================
  Coverage   65.75%   65.75%           
=======================================
  Files          22       22           
  Lines         800      800           
=======================================
  Hits          526      526           
  Misses        274      274

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 06adfca...e3348a6. Read the comment docs.

@smurching smurching self-requested a review October 1, 2018 23:09
@smurching smurching self-assigned this Oct 1, 2018
Copy link
Collaborator

@smurching smurching left a comment

Choose a reason for hiding this comment

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

Looks really good, the integration tests are an awesome addition - just had one comment about checking if an experiment is deleted before renaming it (would be nice to test that case too). Also, it'd be cool to add rename_experiment to the experiments CLI, though we could do that in a follow-up.

meta_dir = os.path.join(self.root_directory, str(experiment_id))
experiment = self._get_experiment(experiment_id)
experiment._set_name(new_name)
write_yaml(meta_dir, FileStore.META_DATA_FILE_NAME, dict(experiment), overwrite=True)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should check if the experiment is deleted here, since it'll be in the trash folder (a different directory) if it is. A simple option would be disallowing renaming deleted experiments (matches our existing pattern of not allowing updating/logging params/metrics to deleted runs). Another would be using self._get_experiment_path() to get the path of the experiment's metadata file, and updating the name there.

Copy link
Collaborator

Choose a reason for hiding this comment

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

^Either way, we'd still be subject to bugs in the case of concurrent attempts to delete & rename an experiment. However that race condition would hopefully be rare, so it seems worth it to try to detect if an experiment is deleted.

@aarondav
Copy link
Contributor Author

aarondav commented Oct 2, 2018

@smurching Addressed comments, including adding CLI support.


@commands.command("rename")
@click.argument("experiment_id")
@click.argument("new_name", help="New name to give to the experiment.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unfortunately click.argument doesn't have a help argument (see https://click.palletsprojects.com/en/7.x/documentation/#help-texts), I think we remove that tests will pass (barring an unrelated failure on some Keras tests that I'll look into).

Copy link
Collaborator

@smurching smurching left a comment

Choose a reason for hiding this comment

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

Thanks for the updates, LGTM!

@aarondav aarondav merged commit eabce15 into mlflow:master Oct 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants