Skip to content

Commit

Permalink
updates to verifier get compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPatrie committed Aug 6, 2024
1 parent ddfdc1b commit 36f2a28
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 3 deletions.
17 changes: 15 additions & 2 deletions bio_check/verifier.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
from time import sleep
from typing import Union, List, Tuple, Any

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -210,7 +211,7 @@ def get_verify_output(self, job_id: str) -> Union[Dict[str, Union[str, Dict]], R
except Exception as e:
return RequestError(error=str(e))

def get_compatible(self, file: str, versions: bool = False) -> Dict:
def get_compatible(self, file: str, versions: bool = False) -> Union[list[tuple[Any, ...]], RequestError]:
"""Get all simulators and optionally their versions for a given file. The File is expected to be either an OMEX/COMBINE archive
or SBML file.
Expand All @@ -235,7 +236,19 @@ def get_compatible(self, file: str, versions: bool = False) -> Dict:
try:
response = requests.post(url=endpoint, headers=headers, data=multidata, params=query_params)
self._check_response(response)
return response.json()
response = response.json()

output = []
for sim_data in response['simulators']:
name = sim_data['name']
version = sim_data.get('version')
if version is not None:
data = tuple([name, version])
output.append(data)
else:
output.append(name)

return output
except Exception as e:
return RequestError(error=str(e))

Expand Down
41 changes: 40 additions & 1 deletion demos/verification_service_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,52 @@
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
"display_name": "Python 3 (ipykernel)",
"language": "python"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"metadata": {
"ExecuteTime": {
"end_time": "2024-08-06T12:02:48.780343Z",
"start_time": "2024-08-06T12:02:48.221561Z"
}
},
"cell_type": "code",
"source": [
"from bio_check import Verifier\n",
"\n",
"verifier = Verifier()\n",
"\n",
"\n",
"\n",
"verifier.get_compatible(file='../model-examples/sbml-core/Elowitz-Nature-2000-Repressilator/BIOMD0000000012_url.xml', versions=False)"
],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'bio-check-message': 'Hello from the Verification Service API!'}\n"
]
},
{
"data": {
"text/plain": [
"['copasi', 'tellurium']"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"execution_count": 3
},
{
"cell_type": "markdown",
"source": [
Expand Down

0 comments on commit 36f2a28

Please sign in to comment.