Skip to content

Commit

Permalink
some nicer names
Browse files Browse the repository at this point in the history
  • Loading branch information
jcschaff committed Nov 5, 2024
1 parent 89d6cb6 commit 23f197b
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 39 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,5 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

.idea/
14 changes: 7 additions & 7 deletions biosim_client/try_easy.py → biosim_client/example.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from biosim_client.client import Client
from biosim_client.simdataclient import SimdataClient
from pprint import pprint

client = Client()
represillator_run_id = "61fea4a08c1e3dc95a79802e" # "649b11e033437e21669d5733"
client = SimdataClient()
run_id = "61fea4a08c1e3dc95a79802e" # "649b11e033437e21669d5733"

sim_results = client.get_sim_results(represillator_run_id)
for dataset_name in sim_results.dataset_names():
dataset = sim_results.get_dataset(dataset_name)
simdata = client.get_simdata(run_id)
for dataset_name in simdata.dataset_names():
dataset = simdata.get_dataset(dataset_name)
nparray = dataset.to_numpy()
dataframe = dataset.to_pandas()

print("==================================================================")
print()
print(f" dataset = {dataset_name}")
Expand Down
17 changes: 0 additions & 17 deletions biosim_client/foo.py

This file was deleted.

6 changes: 1 addition & 5 deletions biosim_client/sim_results.py → biosim_client/sim_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@
attribute_value_types = get_args(AttributeValueTypes)


class Hdf5Attribute:
pass


class SimResults:
class SimData:
configuration: Configuration
run_id: str
hdf5_file: HDF5File
Expand Down
8 changes: 4 additions & 4 deletions biosim_client/client.py → biosim_client/simdataclient.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import biosim_client.api_clients.simdata.openapi_client as simdata_client
from biosim_client.api_clients.simdata.openapi_client import StatusResponse, HDF5File
from biosim_client.api_clients.simdata.openapi_client.configuration import Configuration
from biosim_client.sim_results import SimResults
from biosim_client.sim_data import SimData


class Client:
class SimdataClient:

def __init__(self) -> None:
self.configuration = Configuration(host="https://simdata.api.biosimulations.org")
Expand All @@ -15,8 +15,8 @@ def get_health(self) -> str:
api_response: StatusResponse = api_instance.get_health()
return api_response.to_str()

def get_sim_results(self, id: str) -> SimResults:
def get_simdata(self, id: str) -> SimData:
with simdata_client.api_client.ApiClient(self.configuration) as api_client:
api_instance = simdata_client.DefaultApi(api_client)
hdf5_file: HDF5File = api_instance.get_metadata(id)
return SimResults(configuration=self.configuration, run_id=id, hdf5_file=hdf5_file)
return SimData(configuration=self.configuration, run_id=id, hdf5_file=hdf5_file)
5 changes: 4 additions & 1 deletion scripts/generate_clients.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
SPEC_DIR="${SCRIPT_DIR}/../biosim_client/api_specs"
LIB_DIR="${SCRIPT_DIR}/../biosim_client/api_clients"

# Generate client1
# Generate simdata-api client
# TODO: need to customize the package name
# TODO: improve Python typing for Mypy
# TODO: make attributes dictionaries - easier to work with
openapi-generator generate -i ${SPEC_DIR}/simdata.json -g python -o ${LIB_DIR}/simdata

5 changes: 0 additions & 5 deletions tests/test_foo.py

This file was deleted.

5 changes: 5 additions & 0 deletions tests/test_simdataclient.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from biosim_client.simdataclient import SimdataClient


def test_foo() -> None:
assert SimdataClient().get_health() == "{'status': <Status.OK: 'ok'>}"

0 comments on commit 23f197b

Please sign in to comment.