Skip to content

Commit dc0ca44

Browse files
committed
Add --by-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 `--by-name` argument to `meorg output query` which will force the command to query the model output by name rather than by its id.
1 parent 6311596 commit dc0ca44

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

meorg_client/cli.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,22 +325,24 @@ def create_new_model_output(
325325

326326

327327
@click.command("query")
328+
@click.option("--by-name", is_flag=True, default=False, help="Query by name instead of ID.")
328329
@click.argument("model_id")
329-
def model_output_query(model_id: str):
330+
def model_output_query(model_id: str, by_name: bool):
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+
by_name : bool
339+
Whether to query by name instead of ID.
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+
response = _call(client.model_output_query, model_id=model_id, by_name=by_name)
344346

345347
if client.success():
346348

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
data=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, by_name: bool) -> 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=model_id) if by_name else dict(id=model_id),
499499
)
500500

501501
def model_output_update(

0 commit comments

Comments
 (0)