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

Provide default implementations of AbstractStore log methods #1051

Merged

Conversation

acroz
Copy link
Contributor

@acroz acroz commented Mar 27, 2019

The abstract store has methods for logging individual metrics, params and tags, however since these are not marked as abstract methods they're not currently required to be implemented in tracking store implementations.

This change provides default implementations of log_metric, log_param and set_tag that proxy calls to the more general log_batch added by @smurching in #950.

Following this change, as long as stores implement log_batch, the above methods need not be provided.

@mparkhe
Copy link
Contributor

mparkhe commented Mar 28, 2019

This is a great catch. However, does it make sense to mark all API level methods in abstract store as @abstractmethod requiring implementing stores to have to define those and explicitly throw NotImplemented?

There are a few more methods in AbstractStore that need to be looked at--either marked as @anstractmethod or removed.

  • get_experiment_by_name
  • update_run_info
  • create_run
  • list_run_infos

@acroz
Copy link
Contributor Author

acroz commented Mar 28, 2019

Hey, thanks for the comments.

get_experiment_by_name I think doesn't need to be set as abstract since it has a default implementation that calls list_experiments, which does need to be implemented by subclasses.

The other three should be abstract - I'll update those on this PR.

@acroz
Copy link
Contributor Author

acroz commented Mar 29, 2019

Correction - list_run_infos also has a default implementation, so I've removed its abstract method decorator. I've also removed the redundant identical implementation in RestStore.

@acroz acroz force-pushed the abstract-store-default-log-implementations branch 2 times, most recently from 97dc25c to 97b2685 Compare April 2, 2019 12:30
@acroz
Copy link
Contributor Author

acroz commented Apr 2, 2019

@mparkhe I think I've resolved the outstanding issues on this PR, but the tests are failing for a seemingly unrelated issue with Sagemaker tests. Is this an issue on master?

@mparkhe
Copy link
Contributor

mparkhe commented Apr 2, 2019

@mparkhe I think I've resolved the outstanding issues on this PR, but the tests are failing for a seemingly unrelated issue with Sagemaker tests. Is this an issue on master?

Yes. @smurching and @dbczumar are looking into it.

@@ -224,17 +224,6 @@ def search_runs(self, experiment_ids, search_filter, run_view_type):
response_proto = self._call_endpoint(SearchRuns, req_body)
return [Run.from_proto(proto_run) for proto_run in response_proto.runs]

def list_run_infos(self, experiment_id, run_view_type):
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

from mlflow.entities import ViewType


class ConcreteStore(AbstractStore):
Copy link
Contributor

Choose a reason for hiding this comment

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

🤣 that name.

Can we rename this to something like TestAbstractStoreImpl

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done - though I do miss the ConcreteStore 😁

I made it AbstractStoreTestImpl as classes named Test* are inspected by pytest for test methods, I believe.

def log_batch(self, run_id, metrics, params, tags):
raise NotImplementedError()


Copy link
Contributor

Choose a reason for hiding this comment

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

Would be good to write tests for non-abstract methods in AbstractStore. You have covered log_* methods--can we write one for list_run_infos as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done - also added tests for get_experiment_by_name to complete the set.

Copy link
Contributor

@mparkhe mparkhe left a comment

Choose a reason for hiding this comment

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

A couple of small recommendations. LGTM otherwise.

@acroz acroz force-pushed the abstract-store-default-log-implementations branch from 97b2685 to 14e9555 Compare April 4, 2019 10:02
@acroz
Copy link
Contributor Author

acroz commented Apr 4, 2019

@mparkhe Have addressed your comments and now rerunning tests.

acroz added 15 commits April 5, 2019 18:27
The abstract store has methods for logging individual metrics, params
and tags, however since these are not marked as abstract methods they're
not currently required to be implemented in tracking store
implementations.

This change provides default implementations of `log_metric`,
`log_param` and `set_tag` that proxy calls to the more general
`log_batch` added by @smurching in mlflow#950.

Following this change, as long as stores implement `log_batch`, the
above methods need not be provided.
To make construction of the abstract class work
The implementation is the same as that inherited from `AbstractStore`,
so override is redundant
@acroz acroz force-pushed the abstract-store-default-log-implementations branch from 14e9555 to 36712c7 Compare April 5, 2019 17:27
@mparkhe mparkhe requested a review from dbczumar April 5, 2019 23:19
@acroz
Copy link
Contributor Author

acroz commented Apr 9, 2019

@mparkhe @dbczumar Is there anything left to do to get this merged?

Copy link
Collaborator

@dbczumar dbczumar left a comment

Choose a reason for hiding this comment

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

LGTM

@dbczumar
Copy link
Collaborator

dbczumar commented Apr 9, 2019

@acroz Merging now!

@dbczumar dbczumar merged commit f00cc6d into mlflow:master Apr 9, 2019
@acroz acroz deleted the abstract-store-default-log-implementations branch April 10, 2019 10:19
avflor pushed a commit to avflor/mlflow that referenced this pull request Aug 22, 2020
…1051)

* Provide default implementations of AbstractStore log methods

The abstract store has methods for logging individual metrics, params
and tags, however since these are not marked as abstract methods they're
not currently required to be implemented in tracking store
implementations.

This change provides default implementations of `log_metric`,
`log_param` and `set_tag` that proxy calls to the more general
`log_batch` added by @smurching in mlflow#950.

Following this change, as long as stores implement `log_batch`, the
above methods need not be provided.

* Mark other required methods as abstract

* Patch all abstract methods

To make construction of the abstract class work

* Forgot to add fixture to test functions

* list_run_infos has a default implementation and so doesn't need to be abstract

* Remove RestStore.list_run_infos

The implementation is the same as that inherited from `AbstractStore`,
so override is redundant

* Don't need to patch list_run_infos any more

* Ignore unused argument warning with pytest fixture

* Need to subclass to pass Python 2.7 tests

* Fix linting errors

* Remove duplicate method.

* Rename test store implementation

* Add test for get_experiment_by_name

* Add test for list_run_infos

* Add missing assertion
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