Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions meorg_client/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,22 +325,27 @@ def create_new_model_output(


@click.command("query")
@click.argument("model_id")
def model_output_query(model_id: str):
@click.option("--name", required=False, help="Name of model output entity.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SeanBryan51, what happens if neither is supplied?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I've updated the command to output the help text if no arguments are supplied with click's no_args_is_help in 0e54b47

@click.argument("model_id", required=False)
def model_output_query(model_id: str, name: str):
"""
Get details for a specific new model output entity

Parameters
----------
model_id : str
Model Output ID.

name : str
Name of model output entity.

Prints the `id` modeloutput, and JSON representation for the remaining metadata if in dev mode.
"""
client = _get_client()

response = _call(client.model_output_query, model_id=model_id)
if name:
response = _call(client.model_output_query, name=name)
else:
response = _call(client.model_output_query, model_id=model_id)

if client.success():

Expand Down
4 changes: 2 additions & 2 deletions meorg_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ def model_output_create(
json=dict(model=mod_prof_id, name=name) | config_params,
)

def model_output_query(self, model_id: str) -> Union[dict, requests.Response]:
def model_output_query(self, model_id: str = None, name: bool = None) -> Union[dict, requests.Response]:
"""
Get details for a specific new model output entity
Parameters
Expand All @@ -495,7 +495,7 @@ def model_output_query(self, model_id: str) -> Union[dict, requests.Response]:
return self._make_request(
method=mcc.HTTP_GET,
endpoint=endpoints.MODEL_OUTPUT_QUERY,
url_params=dict(id=model_id),
url_params=dict(name=name) if name else dict(id=model_id),
)

def model_output_update(
Expand Down
16 changes: 11 additions & 5 deletions meorg_client/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,21 @@ def test_create_model_output(
model_output_id = response.get("data").get("modeloutput")
assert model_output_id is not None

self.test_model_output_query(client, model_output_id)

def test_model_output_query(self, client: Client, model_output_id: str):
def test_model_output_query(self, client: Client, model_output_name: str, model_output_generator):
"""Test Existing Model output."""
response = client.model_output_query(model_output_id)

id = model_output_generator(model_output_name)
response = client.model_output_query(model_id=id)
assert client.success()

response_model_output_data = response.get("data").get("modeloutput")
assert response_model_output_data.get("id") == id

response = client.model_output_query(model_output_name, name=model_output_name)
assert client.success()

response_model_output_data = response.get("data").get("modeloutput")
assert response_model_output_data.get("id") == model_output_id
assert response_model_output_data.get("id") == id

def test_model_output_update(
self,
Expand Down
Loading