Skip to content

Commit b1f8a1c

Browse files
committed
update
1 parent 8cd83a7 commit b1f8a1c

File tree

4 files changed

+54
-12
lines changed

4 files changed

+54
-12
lines changed

Diff for: bio_compose/_VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.2.2
1+
0.2.3

Diff for: bio_compose/runner.py

+18
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,24 @@ def run_utc_simulation(self, sbml_filepath: str, start: int, end: int, steps: in
5656
headers = {'Content-Type': multidata.content_type}
5757

5858
return self._execute_request(endpoint=endpoint, headers=headers, multidata=multidata, query_params=query_params)
59+
60+
def generate_simularium_file(self, smoldyn_output_filepath: str, box_size: float, filename: str = None):
61+
endpoint = self._format_endpoint(f'generate-simularium-file')
62+
63+
# multipart
64+
input_fp = (smoldyn_output_filepath.split('/')[-1], open(smoldyn_output_filepath, 'rb'), 'application/octet-stream')
65+
encoder_fields = {'uploaded_file': input_fp}
66+
multidata = MultipartEncoder(fields=encoder_fields)
67+
68+
# query
69+
query_params = {'box_size': str(box_size)}
70+
if filename is not None:
71+
query_params['filename'] = filename
72+
73+
# headers
74+
headers = {'Content-Type': multidata.content_type}
75+
76+
return self._execute_request(endpoint=endpoint, headers=headers, multidata=multidata, query_params=query_params)
5977

6078

6179

Diff for: tests/fixtures/smoldyn/modelouttxt-simulation.simularium

+1-1
Large diffs are not rendered by default.

Diff for: tests/tests.ipynb

+34-10
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 3,
5+
"execution_count": 1,
66
"metadata": {},
77
"outputs": [],
88
"source": [
@@ -11,7 +11,7 @@
1111
},
1212
{
1313
"cell_type": "code",
14-
"execution_count": 4,
14+
"execution_count": 2,
1515
"metadata": {},
1616
"outputs": [
1717
{
@@ -28,18 +28,44 @@
2828
},
2929
{
3030
"cell_type": "code",
31-
"execution_count": 9,
31+
"execution_count": 3,
32+
"metadata": {},
33+
"outputs": [
34+
{
35+
"data": {
36+
"text/plain": [
37+
"{'status': 'PENDING',\n",
38+
" 'job_id': 'files-generate-simularium-file75d8bdc8-0bca-4dd4-8983-561a178fecf4',\n",
39+
" 'timestamp': '2024-08-19 12:49:43.291403',\n",
40+
" 'path': 'file_uploads/files-generate-simularium-file75d8bdc8-0bca-4dd4-8983-561a178fecf4/modelout.txt',\n",
41+
" 'filename': 'simulation',\n",
42+
" 'box_size': 10.0,\n",
43+
" 'translate_output': True,\n",
44+
" 'validate_output': True,\n",
45+
" 'agent_parameters': {}}"
46+
]
47+
},
48+
"execution_count": 3,
49+
"metadata": {},
50+
"output_type": "execute_result"
51+
}
52+
],
53+
"source": [
54+
"simularium_job = runner.generate_simularium_file(smoldyn_output_filepath='./fixtures/smoldyn/modelout.txt', box_size=10.0)"
55+
]
56+
},
57+
{
58+
"cell_type": "code",
59+
"execution_count": 4,
3260
"metadata": {},
3361
"outputs": [],
3462
"source": [
35-
"smoldyn_job_id = 'simulation-execution-smoldyn5624b470-ce90-4144-849c-8da896ab1147'\n",
36-
"\n",
37-
"output = runner.get_output(job_id=smoldyn_job_id, download_dest='./fixtures/smoldyn')"
63+
"simularium_job_id = simularium_job['job_id']"
3864
]
3965
},
4066
{
4167
"cell_type": "code",
42-
"execution_count": 12,
68+
"execution_count": 5,
4369
"metadata": {},
4470
"outputs": [
4571
{
@@ -48,16 +74,14 @@
4874
"True"
4975
]
5076
},
51-
"execution_count": 12,
77+
"execution_count": 5,
5278
"metadata": {},
5379
"output_type": "execute_result"
5480
}
5581
],
5682
"source": [
5783
"import os\n",
5884
"\n",
59-
"\n",
60-
"simularium_job_id = 'files-generate-simularium-filee58f06f8-98f3-403e-afc2-e34cb86f4151'\n",
6185
"simularium_output = runner.get_output(job_id=simularium_job_id, download_dest='./fixtures/smoldyn')\n",
6286
"\n",
6387
"os.path.exists(simularium_output['results_file'])"

0 commit comments

Comments
 (0)