-
Notifications
You must be signed in to change notification settings - Fork 17
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 model manager for machine learning models #918
Add model manager for machine learning models #918
Conversation
3e9b7df
to
d4bda26
Compare
1880261
to
ae61647
Compare
Maybe this was talked elsewhere, but it might be nice to provide some extra context about what changed between the closing of #397 and now. Was the experiment inside the actor successful and we think this new slimmed down implementation is good/useful enough to go in the SDK? |
@llucax We decided that it would be best to start the model loading immediately inside the sdk so that we don't have to migrate extra code later. This slimmed down version should be good enough for the initial usecases. We don't need extra |
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.
I'm not crazy about the get_model()
interface because it is too dynamic, it would be good if it could be more static and misuse would be detected by mypy
instead of at runtime.
Looking at the bigger picture here, it seems this code is still inheriting a lot of the complexity of the previous PR. Do we really need a special case for a single model repository? Can't we just use the dict-based repo and let user pass a key with the value they like the most? It seems like a lot of added extra complexity just to avoid passing a key.
I would just remove the special case here and also the SingleModelRepository
class and force users to pass a key. Once this is done, I don't think it makes sense to keep the abstract base class ModelRepository
, and if we remove it, we can just rename DirectModelRepository
to ModelRepository
. This will make this PR much much simpler.
If we need more abstraction and more types of repositories in the future, we can bring the complexity back, but I wouldn't bet on it just yet.
That is actually something I was also considering. @daniel-zullo-frequenz @cwasicki I think I agree with Luca here that we can just have the one repo structure with a dict input and forget about the single model repo structure. If that is ok with you I will make the change. |
Agree. I think we can also limit it to the manager and don't need the repositories. |
I suggest for now to only implement the bare minimum functionality that we currently need. |
I think having only the "dict repository" is simple enough and gives more flexibility to separate different models if we need to, also the manager and repository are very closely related, so doing this would basically mean throwing everything and start again, right? IMHO having |
77f0e3d
to
bcba426
Compare
@llucax @cwasicki I made some changes to the PR. I removed the repository structures for simplicity and changed the @llucax I changed the key from |
TL;DR: I think it is OK. It was a journey to convince myself of that, so I will keep the long version for future reference :D I was going to say it's not important in this context, but then I was thinking about the case where we want to use an enum for safety, as This is why I still liked the separation between the repository and the manager, because then you can have a "weekly" model, where keys are a enum with the week days, and then you can have an arbitrary model with some I think it would be good to encourage users to design their code with safety in mind, so I'm not sure. I understand this is good enough for the current use cases but I feel it might be a move in the wrong direction. But I'm not sure if it is worth to provide a model repository that it is just a |
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.
I got a bit lost in the patching and mock files in the tests, so I will have a look at it later.
5e8e2c9
to
db4b353
Compare
db4b353
to
8f4dc10
Compare
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.
Thanks for the patience!
3c58932
to
92f10f8
Compare
92f10f8
to
f426182
Compare
33d9dd5
to
6ce5735
Compare
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.
One last comment while we wait for the release of rc6.post1
:)
pyproject.toml
Outdated
@@ -96,6 +96,7 @@ dev-pytest = [ | |||
# For checking docstring code examples | |||
"frequenz-sdk[dev-examples]", | |||
"hypothesis == 6.100.0", | |||
"sybil == 6.0.3", |
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 should not be necessary anymore, we fixed it in repo-config.
@idlir-shkurti-frequenz Could you rebase this PR please? |
f881291
to
8f2eb4a
Compare
…models Signed-off-by: Idlir Shkurti <[email protected]>
bd595f7
to
e5f833a
Compare
Done! Also addressed the custom exception point suggested by Luca. |
Looks like the commit wasn't signed, someone might have to create a new PR, ideally with a shorter commit message. |
Ok, then I will do some testing with this and re-create it afterwards. |
Didn't get what's going on, it needs to be re-created because Idlir can't do it himself now? We can still amend this PR and force-push to it. Also I don't get the comment about the commit message length. |
a shorter one that doesn't fold on gh would be nice. |
Oh, OK, so unrelated to the signing part, I thought it was related. 👍 |
Created a backup here: #968 |
This PR adds a simple model manager module which implements the logic needed to load, update and monitor machine learning models.
Currently there are two model repository structures:
This PR is heavily based (but slimmed down) on #397