Skip to content

Commit 5b24357

Browse files
committed
updates to documentation
1 parent 889f8c9 commit 5b24357

File tree

10 files changed

+225
-190
lines changed

10 files changed

+225
-190
lines changed

bio_compose/data_model.py

+19-15
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,19 @@ def to_dict(self):
1313
return asdict(self)
1414

1515

16-
class Api:
17-
endpoint_root: str
18-
data: Dict
19-
submitted_jobs: List[Dict]
16+
class Api(object):
17+
"""
18+
Base class inherited by the domain-specific polymorphisms native to this package: ``verifier.Verifier``, ``composer.Composer``, and ``runner.SimulationRunner``.
19+
20+
Params:
21+
- **endpoint_root**: `str`: default base endpoint used by this packaging.
22+
- **data**: `dict`: default historical collection of data fetched by the given instance of this class.
23+
- **submitted_jobs**: `list[dict]`: default list of jobs submitted by the given instance.
24+
"""
2025

2126
def __init__(self):
22-
"""Generic base instance which is inherited by any flavor (tag group) of the BioCompose REST API.
23-
Each the methods of polymorphism of this base class should pertain entirely to the tag group
24-
domain with which it is associated (e.g., 'execute-simulations', 'verification', etc.)
27+
"""
28+
Generic base instance which is inherited by any flavor (tag group) of the BioCompose REST API. Polymorphism of this base class should pertain entirely to the tag group domain with which it is associated (e.g., 'execute-simulations', 'verification', etc.)
2529
"""
2630
self.endpoint_root = "https://biochecknet.biosimulations.org"
2731
self._test_root()
@@ -60,16 +64,16 @@ def _test_root(self) -> Dict:
6064
return {'bio-check-error': f"A connection to that endpoint could not be established: {e}"}
6165

6266
def get_output(self, job_id: str, download_dest: str = None, filename: str = None) -> Union[Dict[str, Union[str, Dict]], RequestError]:
63-
"""Fetch the current state of the job referenced with `job_id`. If the job has not yet been processed, it will return a `status` of `PENDING`. If the job is being processed by
64-
the service at the time of return, `status` will read `IN_PROGRESS`. If the job is complete, the job state will be returned, optionally with included result data (either JSON or downloadable file data).
67+
"""
68+
Fetch the current state of the job referenced with `job_id`. If the job has not yet been processed, it will return a `status` of `PENDING`. If the job is being processed by the service at the time of return, `status` will read `IN_PROGRESS`. If the job is complete, the job state will be returned, optionally with included result data (either JSON or downloadable file data).
6569
66-
Args:
67-
job_id:`str`: The id of the job submission.
68-
download_dest:`Optional[str]`: Optional directory where the file will be downloaded if the output is a file. Defaults to the current directory.
69-
filename:`Optional[str]`: Optional filename to save the downloaded file as if the output is a file. If not provided, the filename will be extracted from the Content-Disposition header.
70+
Args:
71+
- **job_id**: `str`: The id of the job submission.
72+
- **download_dest**: `Optional[str]`: Optional directory where the file will be downloaded if the output is a file. Defaults to the current directory.
73+
- **filename**: `Optional[str]`: Optional filename to save the downloaded file as if the output is a file. If not provided, the filename will be extracted from the Content-Disposition header.
7074
71-
Returns:
72-
If the output is a JSON response, return the parsed JSON as a dictionary. If the output is a file, download the file and return the filepath. If an error occurs, return a RequestError.
75+
Returns:
76+
If the output is a JSON response, return the parsed JSON as a dictionary. If the output is a file, download the file and return the filepath. If an error occurs, return a RequestError.
7377
"""
7478
piece = f'get-output/{job_id}'
7579
endpoint = self._format_endpoint(piece)

bio_compose/runner.py

+25-21
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,22 @@ class SimulationRunner(Api):
1414
submitted_jobs: List[Dict]
1515

1616
def __init__(self):
17-
"""A new instance of the Verifier class. NOTE: this may clash with your record keeping in a notebook, so it is highly recommended that users treat instances of this class as quasi-singletons, although not necessary for fundamental interaction.
17+
"""
18+
A new instance of the Verifier class. NOTE: this may clash with your record keeping in a notebook, so it is highly recommended that users treat instances of this class as quasi-singletons, although not necessary for fundamental interaction.
1819
"""
1920
super().__init__()
2021

21-
def run_smoldyn_simulation(self, smoldyn_configuration_filepath: str, duration: int = None, dt: float = None) -> Dict[str, Any]:
22-
"""Run a smoldyn simulation using a standard Smoldyn configuration file. Please see https://www.smoldyn.org/SmoldynManual.pdf for more information on running simulations with Smoldyn.
22+
def run_smoldyn_simulation(self, smoldyn_configuration_filepath: str, duration: int = None, dt: float = None) -> Dict:
23+
"""
24+
Run a smoldyn simulation using a standard Smoldyn configuration file. Please see https://www.smoldyn.org/SmoldynManual.pdf for more information on running simulations with Smoldyn.
2325
2426
Args:
25-
smoldyn_configuration_filepath:`str`: The path to the Smoldyn configuration file for the given model simulation.
26-
duration:`int`: The duration of the simulation. If `None` is passed, duration inference will be attempted using `time_stop` parameter within the Smoldyn configuration. Defaults to `None`.
27-
dt:`float`: The timestep to use within the Smoldyn simulation. If `None` is passed, dt inference will be attempted using the `.dt` parameter of the loaded Smoldyn simulation. Defaults to `None`.
27+
- **smoldyn_configuration_filepath**: `str`: The path to the Smoldyn configuration file for the given model simulation.
28+
- **duration**: `int`: The duration of the simulation. If `None` is passed, duration inference will be attempted using `time_stop` parameter within the Smoldyn configuration. Defaults to `None`.
29+
- **dt**: `float`: The timestep to use within the Smoldyn simulation. If `None` is passed, dt inference will be attempted using the `.dt` parameter of the loaded Smoldyn simulation. Defaults to `None`.
2830
2931
Returns:
30-
The response for the Smoldyn simulation submission request.
32+
The response for the Smoldyn simulation submission request.
3133
3234
"""
3335
endpoint = self._format_endpoint(f'run-smoldyn')
@@ -48,18 +50,19 @@ def run_smoldyn_simulation(self, smoldyn_configuration_filepath: str, duration:
4850

4951
return self._execute_request(endpoint=endpoint, headers=headers, multidata=multidata, query_params=query_params)
5052

51-
def run_utc_simulation(self, sbml_filepath: str, start: int, end: int, steps: int, simulator: str) -> Dict[str, Any]:
52-
"""Run a uniform time course simulation of the model specified in `sbml_filepath` with a supported simulator.
53+
def run_utc_simulation(self, sbml_filepath: str, start: int, end: int, steps: int, simulator: str) -> Dict:
54+
"""
55+
Run a uniform time course simulation of the model specified in `sbml_filepath` with a supported simulator.
5356
5457
Args:
55-
sbml_filepath:`str`: The path to a valid SBML file.
56-
start:`int`: The start time of the simulation.
57-
end:`int`: The end time of the simulation.
58-
steps:`int`: The number of steps to record within the ODE.
59-
simulator:`str`: The simulator to use. Currently, simulator choices include: `'amici'`, `'copasi'`, or `'tellurium'`.
58+
- **sbml_filepath**: `str`: The path to a valid SBML file.
59+
- **start**: `int`: The start time of the simulation.
60+
- **end**: `int`: The end time of the simulation.
61+
- **steps**: `int`: The number of steps to record within the ODE.
62+
- **simulator**: `str`: The simulator to use. Currently, simulator choices include: `'amici'`, `'copasi'`, or `'tellurium'`.
6063
6164
Returns:
62-
The response for the UTC simulation submission request.
65+
The response for the UTC simulation submission request.
6366
"""
6467
endpoint = self._format_endpoint(f'run-utc')
6568

@@ -79,16 +82,17 @@ def run_utc_simulation(self, sbml_filepath: str, start: int, end: int, steps: in
7982

8083
return self._execute_request(endpoint=endpoint, headers=headers, multidata=multidata, query_params=query_params)
8184

82-
def generate_simularium_file(self, smoldyn_output_filepath: str, box_size: float, filename: str = None) -> Dict[str, Any]:
83-
"""Run a Smoldyn simulation and generate a Simularium trajectory from the aforementioned simulation's outputs.
85+
def generate_simularium_file(self, smoldyn_output_filepath: str, box_size: float, filename: str = None) -> Dict:
86+
"""
87+
Run a Smoldyn simulation and generate a Simularium trajectory from the aforementioned simulation's outputs.
8488
8589
Args:
86-
smoldyn_output_filepath:`str`: The path to the Smoldyn output file for the given model simulation.
87-
box_size:`float`: The box size to use for the Simularium trajectory.
88-
filename:`str`: The name of the Simularium file that is generated. If `None` is passed, a general `'simulation.simularium'` filename will be used. Defaults to `None`.
90+
- **smoldyn_output_filepath**: `str`: The path to the Smoldyn output file for the given model simulation.
91+
- **box_size**: `float`: The box size to use for the Simularium trajectory.
92+
- **filename**: `str`: The name of the Simularium file that is generated. If `None` is passed, a general `'simulation.simularium'` filename will be used. Defaults to `None`.
8993
9094
Returns:
91-
The response for the Simularium submission request.
95+
The response for the Simularium submission request.
9296
"""
9397
endpoint = self._format_endpoint(f'generate-simularium-file')
9498

0 commit comments

Comments
 (0)