Skip to content

Commit 3d22183

Browse files
committed
Add --name option to meorg output query
The `/modeloutput` get endpoint requires specifying the `name` key when querying by name and meorg_client is currently fixed to query by id. This change adds a `--name` argument to `meorg output query` which will query the model output by name rather than by its id and changes the `model_id` argument to be optional.
1 parent 05d05ce commit 3d22183

3 files changed

Lines changed: 22 additions & 11 deletions

File tree

meorg_client/cli.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,22 +325,27 @@ def create_new_model_output(
325325

326326

327327
@click.command("query")
328-
@click.argument("model_id")
329-
def model_output_query(model_id: str):
328+
@click.option("--name", required=False, help="Name of model output entity.")
329+
@click.argument("model_id", required=False)
330+
def model_output_query(model_id: str, name: str):
330331
"""
331332
Get details for a specific new model output entity
332333
333334
Parameters
334335
----------
335336
model_id : str
336337
Model Output ID.
337-
338+
name : str
339+
Name of model output entity.
338340
339341
Prints the `id` modeloutput, and JSON representation for the remaining metadata if in dev mode.
340342
"""
341343
client = _get_client()
342344

343-
response = _call(client.model_output_query, model_id=model_id)
345+
if name:
346+
response = _call(client.model_output_query, name=name)
347+
else:
348+
response = _call(client.model_output_query, model_id=model_id)
344349

345350
if client.success():
346351

meorg_client/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ def model_output_create(
479479
json=dict(model=mod_prof_id, name=name) | config_params,
480480
)
481481

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

501501
def model_output_update(

meorg_client/tests/test_client.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,21 @@ def test_create_model_output(
156156
model_output_id = response.get("data").get("modeloutput")
157157
assert model_output_id is not None
158158

159-
self.test_model_output_query(client, model_output_id)
160-
161-
def test_model_output_query(self, client: Client, model_output_id: str):
159+
def test_model_output_query(self, client: Client, model_output_name: str, model_output_generator):
162160
"""Test Existing Model output."""
163-
response = client.model_output_query(model_output_id)
161+
162+
id = model_output_generator(model_output_name)
163+
response = client.model_output_query(model_id=id)
164+
assert client.success()
165+
166+
response_model_output_data = response.get("data").get("modeloutput")
167+
assert response_model_output_data.get("id") == id
168+
169+
response = client.model_output_query(model_output_name, name=model_output_name)
164170
assert client.success()
165171

166172
response_model_output_data = response.get("data").get("modeloutput")
167-
assert response_model_output_data.get("id") == model_output_id
173+
assert response_model_output_data.get("id") == id
168174

169175
def test_model_output_update(
170176
self,

0 commit comments

Comments
 (0)