Skip to content

Commit

Permalink
updates to api and workers for simularium kwargs
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPatrie committed Aug 16, 2024
1 parent 8592fda commit 741fdbc
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
4 changes: 4 additions & 0 deletions compose_api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,8 @@ async def generate_simularium_file(
uploaded_file: UploadFile = File(..., description="A file containing results that can be parse by Simularium (spatial)."),
box_size: float = Query(..., description="Size of the simulation box as a floating point number."),
filename: str = Query(default=None, description="Name desired for the simularium file. NOTE: pass only the file name without an extension."),
translate_output: bool = Query(default=True, description="Whether to translate the output trajectory prior to converting to simularium. See simulariumio documentation for more details."),
validate_output: bool = Query(default=True, description="Whether to validate the outputs for the simularium file. See simulariumio documentation for more details.")
):
job_id = "files-generate-simularium-file" + str(uuid.uuid4())
_time = db_connector.timestamp()
Expand All @@ -443,6 +445,8 @@ async def generate_simularium_file(
path=uploaded_file_location,
filename=filename,
box_size=box_size,
translate_output=translate_output,
validate_output=validate_output
)
gen_id = new_job_submission.get('_id')
if gen_id is not None:
Expand Down
18 changes: 9 additions & 9 deletions compose_worker/test.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@
{
"metadata": {
"ExecuteTime": {
"end_time": "2024-08-16T17:27:17.112917Z",
"start_time": "2024-08-16T17:27:17.107988Z"
"end_time": "2024-08-16T17:28:27.035927Z",
"start_time": "2024-08-16T17:28:27.030441Z"
}
},
"cell_type": "code",
Expand All @@ -292,8 +292,8 @@
{
"metadata": {
"ExecuteTime": {
"end_time": "2024-08-16T17:27:18.048018Z",
"start_time": "2024-08-16T17:27:17.113991Z"
"end_time": "2024-08-16T17:28:28.475098Z",
"start_time": "2024-08-16T17:28:27.621723Z"
}
},
"cell_type": "code",
Expand All @@ -309,12 +309,12 @@
{
"metadata": {
"ExecuteTime": {
"end_time": "2024-08-16T17:27:18.487430Z",
"start_time": "2024-08-16T17:27:18.049090Z"
"end_time": "2024-08-16T17:28:29.508622Z",
"start_time": "2024-08-16T17:28:29.004458Z"
}
},
"cell_type": "code",
"source": "result = await generate_simularium_file(input_fp=fp, dest_dir='../model-examples/smoldyn', box_size=10.0, write_json=False, run_validation=False)",
"source": "result = await generate_simularium_file(input_fp=fp, dest_dir='../model-examples/smoldyn', box_size=10.0, write_json=True, run_validation=True)",
"id": "c3e8ddfffb7e0ac9",
"outputs": [
{
Expand All @@ -323,8 +323,8 @@
"text": [
"Reading Smoldyn Data -------------\n",
"Filtering: translation -------------\n",
"Converting Trajectory Data to Binary -------------\n",
"Writing Binary -------------\n",
"Converting Trajectory Data to JSON -------------\n",
"Writing JSON -------------\n",
"saved to ../model-examples/smoldyn/modelouttxt-simulation.simularium\n"
]
}
Expand Down
4 changes: 3 additions & 1 deletion compose_worker/workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,9 @@ async def run(self):

async def _run_simularium(self, job_id: str, input_path: str, dest: str):
box_size = self.job_params['box_size']
result = await generate_simularium_file(input_fp=input_path, dest_dir=dest, box_size=box_size)
translate = self.job_params['translate_output']
validate = self.job_params['validate_output']
result = await generate_simularium_file(input_fp=input_path, dest_dir=dest, box_size=box_size, translate_output=translate, run_validation=validate)

results_file = result.get('simularium_file')
uploaded_file_location = None
Expand Down
Binary file modified model-examples/smoldyn/modelouttxt-simulation.simularium
Binary file not shown.
1 change: 0 additions & 1 deletion model-examples/smoldyn/simulation.simularium.simularium

This file was deleted.

0 comments on commit 741fdbc

Please sign in to comment.