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
Only generate model uuid when logging model #5167
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,6 @@ def __init__( | |
flavors=None, | ||
signature=None, # ModelSignature | ||
saved_input_example_info: Dict[str, Any] = None, | ||
model_uuid=None, | ||
**kwargs, | ||
): | ||
# store model id instead of run_id and path to avoid confusion when model gets exported | ||
|
@@ -54,7 +53,7 @@ def __init__( | |
self.flavors = flavors if flavors is not None else {} | ||
self.signature = signature | ||
self.saved_input_example_info = saved_input_example_info | ||
self.model_uuid = uuid.uuid4().hex if model_uuid is None else model_uuid | ||
self.model_uuid = uuid.uuid4().hex | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This basically means every There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Every new constructed model has a different ID, this is desired. |
||
self.__dict__.update(kwargs) | ||
|
||
def __eq__(self, other): | ||
|
@@ -137,7 +136,11 @@ def from_dict(cls, model_dict): | |
model_dict = model_dict.copy() | ||
model_dict["signature"] = ModelSignature.from_dict(model_dict["signature"]) | ||
|
||
return cls(**model_dict) | ||
model_dict = model_dict.copy() | ||
model_uuid = model_dict.pop('model_uuid', None) | ||
model = cls(**model_dict) | ||
model.model_uuid = model_uuid # restore the saved model_uuid | ||
return model | ||
|
||
@classmethod | ||
def log( | ||
|
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.
Instead of removing
model_uuid
from the constructor and modifying the attribute duringload()
, can we define a third type of value formodel_uuid
?model_uuid
should be a function that generates a UUID, e.g.lambda: uuid.uuid4().hex
None
, indicating that the model has no IDIn the constructor, we can check if the input is a function and, if it is, call it to generate an ID. Otherwise, set
self.model_uuid = model_uuid
.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.
sounds good