-
Notifications
You must be signed in to change notification settings - Fork 30
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
Added filtering option for entities listing #513
base: main
Are you sure you want to change the base?
Conversation
MLCommons CLA bot All contributors have signed the MLCommons CLA ✍️ ✅ |
@@ -5,15 +5,14 @@ | |||
class Entity(ABC): | |||
@abstractmethod | |||
def all( | |||
cls, local_only: bool = False, comms_func: callable = None | |||
cls, local_only: bool = False, filters: dict = None |
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 fix was not connected to ls valid feature, just a bugfix: making abstract function signature relevant to a real implementations
@@ -105,3 +106,6 @@ def default_status(cls, v): | |||
if v is not None: | |||
status = Status(v) | |||
return status | |||
|
|||
class DeployableEntity(DeployableSchema, Entity): | |||
pass |
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 "implementation" is necessary at two places:
- Entity list command - to declare that applicable objects should be both DeployableSchema and Entity.
- for Entity list test purposes
However, placing implementation here breaks code design a bit: it makeschemas.py
dependable frominterface.py
. Maybe it's worth to move this class definition to other place?
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 see your point. Maybe this could live in the interface file instead? I also think that, just for clarity, entities that apply to this description should inherit from this DeployableEntity class.
|
||
# generate_cube(id=103, is_valid=True, owner=12345), | ||
# generate_cube(id=104, is_valid=False, owner=12345), | ||
] |
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 current behavior is not to filter local cubes by owner. I didn't change it, instead I anchored it in this test case. In future, once we elaborate & implement new ls
behavior, these tests have to be changed
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 good! I left a few comments. The only important change I would consider valuable is to the tests definition for the list method.
mocker.patch.object(entity_object, "display_dict", side_effect=display_dicts) | ||
mocker.patch("medperf.commands.list.get_medperf_user_data", return_value={"id": 1}) | ||
|
||
# spies | ||
generated_entities = [entity_object for _ in display_dicts] | ||
print([e.is_valid for e in generated_entities]) |
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 print is probably not needed
@pytest.mark.parametrize("local_only", [False, True]) | ||
@pytest.mark.parametrize("mine_only", [False, True]) | ||
@pytest.mark.parametrize("valid_only", [False, True]) | ||
def test_run_list_mlcubes(mocker, comms, ui, local_only, mine_only, valid_only): |
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 test is way too complex. Is there a way we can split it into multiple tests? It is considered best practice to have atomic, DAMP unit tests
@@ -105,3 +106,6 @@ def default_status(cls, v): | |||
if v is not None: | |||
status = Status(v) | |||
return status | |||
|
|||
class DeployableEntity(DeployableSchema, Entity): | |||
pass |
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 see your point. Maybe this could live in the interface file instead? I also think that, just for clarity, entities that apply to this description should inherit from this DeployableEntity class.
Solution for #496 : add
--valid
flag for entity listing:Waits for #509 to implement
is_valid
flag forResult
entity