Skip to content

Commit

Permalink
apply auto fixes for whitespace, ruff, and prettier precommit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
jcschaff committed Nov 7, 2024
1 parent d1a0af6 commit de5fc81
Show file tree
Hide file tree
Showing 60 changed files with 958 additions and 1,382 deletions.
1 change: 0 additions & 1 deletion .github/workflows/on-release-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,3 @@ jobs:

- name: Deploy documentation
run: poetry run mkdocs gh-deploy --force

2 changes: 1 addition & 1 deletion .idea/biosim-client.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

46 changes: 9 additions & 37 deletions biosim_client/api_specs/simdata.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,7 @@
}
},
"type": "object",
"required": [
"shape",
"values"
],
"required": ["shape", "values"],
"title": "DatasetData"
},
"HDF5Attribute": {
Expand Down Expand Up @@ -252,10 +249,7 @@
}
},
"type": "object",
"required": [
"key",
"value"
],
"required": ["key", "value"],
"title": "HDF5Attribute"
},
"HDF5Dataset": {
Expand All @@ -280,11 +274,7 @@
}
},
"type": "object",
"required": [
"name",
"shape",
"attributes"
],
"required": ["name", "shape", "attributes"],
"title": "HDF5Dataset"
},
"HDF5File": {
Expand All @@ -310,12 +300,7 @@
}
},
"type": "object",
"required": [
"filename",
"id",
"uri",
"groups"
],
"required": ["filename", "id", "uri", "groups"],
"title": "HDF5File"
},
"HDF5Group": {
Expand All @@ -340,11 +325,7 @@
}
},
"type": "object",
"required": [
"name",
"attributes",
"datasets"
],
"required": ["name", "attributes", "datasets"],
"title": "HDF5Group"
},
"HTTPValidationError": {
Expand All @@ -362,10 +343,7 @@
},
"Status": {
"type": "string",
"enum": [
"ok",
"error"
],
"enum": ["ok", "error"],
"title": "Status"
},
"StatusResponse": {
Expand All @@ -375,9 +353,7 @@
}
},
"type": "object",
"required": [
"status"
],
"required": ["status"],
"title": "StatusResponse"
},
"ValidationError": {
Expand Down Expand Up @@ -406,13 +382,9 @@
}
},
"type": "object",
"required": [
"loc",
"msg",
"type"
],
"required": ["loc", "msg", "type"],
"title": "ValidationError"
}
}
}
}
}
24 changes: 13 additions & 11 deletions biosim_client/dataset.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional, Any
from typing import Any, Optional

import numpy as np
import pandas as pd
Expand All @@ -16,11 +16,13 @@ class Dataset:
column_names: Optional[list[str]]
attributes: Optional[dict[str, Any]]

def __init__(self,
values: list[DatasetValueTypes],
shape: Optional[list[int]] = None,
column_names: Optional[list[str]] = None,
attributes: Optional[dict[str, Any]] = None):
def __init__(
self,
values: list[DatasetValueTypes],
shape: Optional[list[int]] = None,
column_names: Optional[list[str]] = None,
attributes: Optional[dict[str, Any]] = None,
):
if shape is None:
shape = [len(values)]
if attributes is None:
Expand All @@ -41,16 +43,16 @@ def to_pandas(self) -> pd.DataFrame:
return dataframe

@classmethod
def from_api(cls, data: DatasetData, hdf5_dataset: HDF5Dataset) -> 'Dataset':
values = data.to_dict()['values']
def from_api(cls, data: DatasetData, hdf5_dataset: HDF5Dataset) -> "Dataset":
values = data.to_dict()["values"]
shape = hdf5_dataset.shape

attributes: dict[str, Any] = {}
column_names: Optional[list[str]] = None
for attr in hdf5_dataset.attributes:
attr_dict = attr.to_dict()
if attr_dict['key'] == 'sedmlDataSetLabels':
column_names = attr_dict['value']
attributes[attr_dict['key']] = attr_dict['value']
if attr_dict["key"] == "sedmlDataSetLabels":
column_names = attr_dict["value"]
attributes[attr_dict["key"]] = attr_dict["value"]

return Dataset(values=values, shape=shape, column_names=column_names, attributes=attributes)
3 changes: 2 additions & 1 deletion biosim_client/example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from biosim_client.simdataclient import SimdataClient
from pprint import pprint

from biosim_client.simdataclient import SimdataClient

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

Expand Down
18 changes: 11 additions & 7 deletions biosim_client/sim_data.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from typing import Optional, get_args

import biosim_client.simdata_api as simdata_client
from biosim_client.simdata_api import HDF5File, DatasetData, HDF5Dataset, Configuration, \
HDF5Attribute
from biosim_client.dataset import Dataset, AttributeValueTypes
from biosim_client.dataset import AttributeValueTypes, Dataset
from biosim_client.simdata_api import Configuration, DatasetData, HDF5Attribute, HDF5Dataset, HDF5File

attribute_value_types = get_args(AttributeValueTypes)

Expand All @@ -24,8 +23,13 @@ def dataset_names(self) -> list[str]:
return [dataset.name for group in self.hdf5_file.groups for dataset in group.datasets]

def dataset_uris(self) -> list[str]:
return [attr.to_dict()['value'] for group in self.hdf5_file.groups for dataset in group.datasets for attr in
dataset.attributes if attr.to_dict()['key'] == "uri"]
return [
attr.to_dict()["value"]
for group in self.hdf5_file.groups
for dataset in group.datasets
for attr in dataset.attributes
if attr.to_dict()["key"] == "uri"
]

def get_dataset(self, name: str) -> Dataset:
if name in self.datasets:
Expand All @@ -39,7 +43,7 @@ def get_dataset(self, name: str) -> Dataset:
for hdf5_dataset in hdf5_group.datasets:
if hdf5_dataset.name == name:
for hdf5_attribute in hdf5_dataset.attributes:
if hdf5_attribute.to_dict()['key'] == "uri":
if hdf5_attribute.to_dict()["key"] == "uri":
dataset_uri = hdf5_attribute.to_dict()["value"]
break

Expand All @@ -48,7 +52,7 @@ def get_dataset(self, name: str) -> Dataset:
if hdf5_dataset is None:
raise ValueError(f"Dataset '{name}' not found")

with (simdata_client.api_client.ApiClient(self.configuration) as api_client):
with simdata_client.api_client.ApiClient(self.configuration) as api_client:
api_instance = simdata_client.DefaultApi(api_client)
dataset_data: DatasetData = api_instance.read_dataset(run_id=self.run_id, dataset_name=dataset_uri)
dataset = Dataset.from_api(data=dataset_data, hdf5_dataset=hdf5_dataset)
Expand Down
11 changes: 5 additions & 6 deletions biosim_client/simdata_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
# flake8: noqa

"""
simdata-api
simdata-api
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
Do not edit the class manually.
""" # noqa: E501


__version__ = "1.0.0"

# import apis into sdk package
Expand Down
1 change: 0 additions & 1 deletion biosim_client/simdata_api/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@

# import apis into api package
from biosim_client.simdata_api.api.default_api import DefaultApi

Loading

0 comments on commit de5fc81

Please sign in to comment.