Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

VukW
Copy link
Contributor

@VukW VukW commented Nov 27, 2023

Solution for #496 : add --valid flag for entity listing:

medperf mlcube ls --valid
medperf dataset ls --valid
medperf benchmark ls --valid
medperf result ls --valid

Waits for #509 to implement is_valid flag for Result entity

@VukW VukW requested a review from a team as a code owner November 27, 2023 17:28
@VukW VukW had a problem deploying to testing-external-code November 27, 2023 17:28 — with GitHub Actions Failure
Copy link
Contributor

github-actions bot commented Nov 27, 2023

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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:

  1. Entity list command - to declare that applicable objects should be both DeployableSchema and Entity.
  2. for Entity list test purposes
    However, placing implementation here breaks code design a bit: it make schemas.py dependable from interface.py. Maybe it's worth to move this class definition to other place?

Copy link
Contributor

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),
]
Copy link
Contributor Author

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

@VukW VukW had a problem deploying to testing-external-code November 28, 2023 12:10 — with GitHub Actions Failure
Copy link
Contributor

@aristizabal95 aristizabal95 left a 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])
Copy link
Contributor

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):
Copy link
Contributor

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
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants