-
Notifications
You must be signed in to change notification settings - Fork 12
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 to to_dict functions to Destination and TagSetManager classes #119
Conversation
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.
@pauldg Would you be able to add a test for this? Something like:
original_entity = # some original entity
serialized_entity = original_entity.to_dict()
deserialized_entity = Entity.from_dict(serialized_entity)
assert deserialized_entity == original_entity
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 these changes @pauldg. Some minor issues, I'll try to fix them tomorrow unless you get to them first.
tests/test_entity.py
Outdated
deserialized_destination = Destination.from_dict(loader, serialized_destination) | ||
# make sure the deserialized destination is the same as the original | ||
self.assertEqual(deserialized_destination, destination) | ||
assert deserialized_destination == destination |
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.
The assertEqual above should do the same thing, so I think it's ok to remove this.
assert deserialized_destination == destination |
tpv/core/entities.py
Outdated
'min_accepted_cores': self.min_accepted_cores, | ||
'min_accepted_mem': self.min_accepted_mem, | ||
'min_accepted_gpus': self.min_accepted_gpus, | ||
'max_accepted_cores': self.max_accepted_cores, | ||
'max_accepted_mem': self.max_accepted_mem, | ||
'max_accepted_gpus': self.max_accepted_gpus, |
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 needs to be split I think, otherwise, the superclass method will be aware of its subclasses. The min_accepted
related fields should go to the Destination
class, and rules should go to the EntityWithRules
class.
0b611e7
to
1e400f6
Compare
These functions allow a dict representation of Destination objects which is convenient for example for serializebility