Skip to content

Commit 0c944eb

Browse files
committed
Add API Spec v2.1.0
1 parent 62d8935 commit 0c944eb

File tree

8 files changed

+557
-4
lines changed

8 files changed

+557
-4
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ jobs:
3434
MEORG_EMAIL: ${{ secrets.MEORG_EMAIL }}
3535
MEORG_PASSWORD: ${{ secrets.MEORG_PASSWORD }}
3636
MEORG_MODEL_OUTPUT_ID: ${{ secrets.MEORG_MODEL_OUTPUT_ID }}
37+
MEORG_MODEL_OUTPUT_NAME: ${{ secrets.MEORG_MODEL_OUTPUT_NAME}}
38+
MEORG_MODEL_PROFILE_ID: ${{ secrets.MEORG_MODEL_PROFILE_ID }}
39+
MEORG_EXPERIMENT_ID: ${{ secrets.MEORG_EXPERIMENT_ID }}
3740
run: |
3841
conda install pytest
3942
pytest -v

meorg_client/cli.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,42 @@ def analysis_start(id: str):
214214
click.echo(analysis_id)
215215

216216

217+
@click.command("create")
218+
@click.argument("model_id")
219+
@click.argument("exp_id")
220+
@click.argument("name")
221+
def create_new_model_output(model_id: str, exp_id: str, name: str):
222+
"""
223+
Create a new model output entity
224+
225+
226+
Parameters
227+
----------
228+
model_id : str
229+
Model profile ID.
230+
231+
exp_id : str
232+
Experiment ID.
233+
234+
name : str
235+
New model output name
236+
237+
Prints modeloutput ID of created object, and whether it already existed or not.
238+
"""
239+
client = _get_client()
240+
241+
response = _call(
242+
client.post_output_entity, model_id=model_id, exp_id=exp_id, name=name
243+
)
244+
245+
if client.success():
246+
output_id = response.get("data").get("modeloutputId")
247+
created = response.get("data").get("created")
248+
click.echo(f"Model Output ID: {output_id}")
249+
click.echo(f"Override (existing) Model Output ID: {created}")
250+
pass
251+
252+
217253
@click.command("status")
218254
@click.argument("id")
219255
def analysis_status(id: str):
@@ -291,6 +327,11 @@ def cli_analysis():
291327
pass
292328

293329

330+
@click.group("output", help="Model output commands.")
331+
def cli_output():
332+
pass
333+
334+
294335
# Add file commands
295336
cli_file.add_command(file_list)
296337
cli_file.add_command(file_upload)
@@ -304,6 +345,9 @@ def cli_analysis():
304345
cli_analysis.add_command(analysis_start)
305346
cli_analysis.add_command(analysis_status)
306347

348+
# Add output command
349+
cli_output.add_command(create_new_model_output)
350+
307351
# Add subparsers to the master
308352
cli.add_command(cli_endpoints)
309353
cli.add_command(cli_file)

meorg_client/client.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,31 @@ def start_analysis(self, id: str) -> Union[dict, requests.Response]:
442442
url_params=dict(id=id),
443443
)
444444

445+
def post_output_entity(
446+
self, model_id: str, exp_id: str, name: str
447+
) -> Union[dict, requests.Response]:
448+
"""
449+
Create a new model output entity
450+
Parameters
451+
----------
452+
model_id : str
453+
Model Profile ID
454+
exp_id : str
455+
Experiment ID
456+
name : _type_
457+
Name of Model Output
458+
459+
Returns
460+
-------
461+
Union[dict, requests.Response]
462+
Response from ME.org.
463+
"""
464+
return self._make_request(
465+
method=mcc.HTTP_POST,
466+
endpoint=endpoints.MODEL_OUTPUT,
467+
data=dict(experiment=exp_id, model=model_id, name=name),
468+
)
469+
445470
def get_analysis_status(self, id: str) -> Union[dict, requests.Response]:
446471
"""Check the status of the analysis chain.
447472

0 commit comments

Comments
 (0)