diff --git a/.gitignore b/.gitignore index f64e26a..3eeb5a0 100644 --- a/.gitignore +++ b/.gitignore @@ -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/ diff --git a/biosim_client/try_easy.py b/biosim_client/example.py similarity index 59% rename from biosim_client/try_easy.py rename to biosim_client/example.py index b7936f7..302a077 100644 --- a/biosim_client/try_easy.py +++ b/biosim_client/example.py @@ -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}") diff --git a/biosim_client/foo.py b/biosim_client/foo.py deleted file mode 100644 index 8b7396d..0000000 --- a/biosim_client/foo.py +++ /dev/null @@ -1,17 +0,0 @@ -def foo(bar: str) -> str: - """Summary line. - - Extended description of function. - - Args: - bar: Description of input argument. - - Returns: - Description of return value - """ - - return bar - - -if __name__ == "__main__": # pragma: no cover - pass diff --git a/biosim_client/sim_results.py b/biosim_client/sim_data.py similarity index 98% rename from biosim_client/sim_results.py rename to biosim_client/sim_data.py index 3cd0857..dca08dc 100644 --- a/biosim_client/sim_results.py +++ b/biosim_client/sim_data.py @@ -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 diff --git a/biosim_client/client.py b/biosim_client/simdataclient.py similarity index 80% rename from biosim_client/client.py rename to biosim_client/simdataclient.py index aba8962..7b34454 100644 --- a/biosim_client/client.py +++ b/biosim_client/simdataclient.py @@ -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") @@ -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) diff --git a/scripts/generate_clients.sh b/scripts/generate_clients.sh index 4599716..d588248 100755 --- a/scripts/generate_clients.sh +++ b/scripts/generate_clients.sh @@ -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 diff --git a/tests/test_foo.py b/tests/test_foo.py deleted file mode 100644 index 0795a8c..0000000 --- a/tests/test_foo.py +++ /dev/null @@ -1,5 +0,0 @@ -from biosim_client.foo import foo - - -def test_foo(): - assert foo("foo") == "foo" diff --git a/tests/test_simdataclient.py b/tests/test_simdataclient.py new file mode 100644 index 0000000..62ac3af --- /dev/null +++ b/tests/test_simdataclient.py @@ -0,0 +1,5 @@ +from biosim_client.simdataclient import SimdataClient + + +def test_foo() -> None: + assert SimdataClient().get_health() == "{'status': }"