-
Notifications
You must be signed in to change notification settings - Fork 6
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
feat: model inventory #250
Conversation
…ound truth and domain
bump. @musslick @chadcwilliams @gtdang |
hi @musslick , @benwandrew , @chadcwilliams and @gtdang – here's the updated model inventory PR for your perusal. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! I think this is so clear and easy to use. I just left one suggestion for improvement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! I like the idea of including the docstrings. Other than that, happy to get it merged and then will start filling the data folder with more models :)
This is very well done! It is all very intuitive and I could follow along all of the files without a hitch. I had no issues, so you definitely have my thumbs up. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super sleek! let’s start growing the inventory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great John! I like how you support so many ways of accessing information with the dispatch. Very user friendly! Just had some questions for my understanding.
|
||
from autora.variable import VariableCollection | ||
|
||
|
||
@runtime_checkable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this decorator do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That means that you can do an isinstance(x, _SyntheticExperimentClosure)
call and check whether x
fulfills the Protocol.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh cool! Thanks!
@singledispatch | ||
def describe(arg): | ||
""" | ||
Print the docstring for a synthetic experiment. | ||
|
||
Args: | ||
arg: the experiment's ID, an object returned from the `retrieve` function, or a closure | ||
which creates a new experiment. | ||
""" | ||
raise NotImplementedError(f"{arg=} not yet supported") | ||
|
||
|
||
@describe.register | ||
def _(closure: _SyntheticExperimentClosure): | ||
print(closure.__doc__) | ||
|
||
|
||
@describe.register | ||
def _(collection: SyntheticExperimentCollection): | ||
describe(collection.closure) | ||
|
||
|
||
@describe.register | ||
def _(id_: str): | ||
describe(retrieve(id_)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool! Didn't know about this! Is my understanding correct that if the object type is not one of the of the registered types it will default to the base (first) function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! That's it. It's just a different way of doing
if isinstance(x, SyntheticExperimentCollection):
... do something ...
elif isinstance(x, str):
... do something else ...
else:
... throw an error
which neatly leverages the type hints.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat!
Description
Add the model inventory.
part of #232
resolves #232
Type of change:
Features:
Questions: