Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Commit

Permalink
fix: correct routing for new model config in constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPatrie committed Feb 28, 2024
1 parent 3fa0355 commit b41f341
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 16 deletions.
5 changes: 2 additions & 3 deletions biosimulator_processes/processes/copasi_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,8 @@ class CopasiProcess(Process):
'_type': 'string',
'_default': 'lsoda'
},
'units': 'tree[string]'

# 'model_file': 'string',
'units': 'tree[string]',
# 'model_file': 'string'
# 'reactions': 'tree[string]',
# 'model_changes': 'tree[string]',
}
Expand Down
48 changes: 35 additions & 13 deletions notebooks/copasi_process_composer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"cell_type": "markdown",
"source": [
"\n",
"As per the `CopasiProcess` constructor, there are three primary methods of entry:\n",
"##### **As per the `CopasiProcess` constructor, there are three primary methods of entry:**\n",
" \n",
"\n",
" # Parse values from the process `config` attribute dictionary:\n",
Expand Down Expand Up @@ -116,23 +116,24 @@
"id": "63a90540d44034e1"
},
{
"cell_type": "code",
"outputs": [],
"source": [],
"cell_type": "markdown",
"source": [
"##### Here we define the schema for a single process based on the provided entrypoint."
],
"metadata": {
"collapsed": false
},
"id": "f7c6d7411f54392c"
"id": "c2537269b7efeee0"
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 7,
"id": "77636dbde3fa6b74",
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-02-28T16:07:45.729583Z",
"start_time": "2024-02-28T16:07:45.725266Z"
"end_time": "2024-02-28T16:55:01.622694Z",
"start_time": "2024-02-28T16:55:01.616799Z"
}
},
"outputs": [],
Expand All @@ -145,7 +146,9 @@
" '_type': 'process',\n",
" 'address': 'local:copasi',\n",
" 'config': {\n",
" 'model_file': model_path,\n",
" 'model': {\n",
" 'model_source': model_path\n",
" }\n",
" },\n",
" 'inputs': {\n",
" 'floating_species': ['floating_species_store'],\n",
Expand Down Expand Up @@ -187,16 +190,35 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 8,
"id": "4c2ef631b005be61",
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-02-27T21:23:20.402456Z",
"start_time": "2024-02-27T21:23:20.365137Z"
"end_time": "2024-02-28T16:55:02.826058Z",
"start_time": "2024-02-28T16:55:02.781306Z"
}
},
"outputs": [],
"outputs": [
{
"ename": "KeyError",
"evalue": "'model_file'",
"output_type": "error",
"traceback": [
"\u001B[0;31m---------------------------------------------------------------------------\u001B[0m",
"\u001B[0;31mKeyError\u001B[0m Traceback (most recent call last)",
"Cell \u001B[0;32mIn[8], line 1\u001B[0m\n\u001B[0;32m----> 1\u001B[0m workflow \u001B[38;5;241m=\u001B[39m \u001B[43mComposite\u001B[49m\u001B[43m(\u001B[49m\u001B[43m{\u001B[49m\n\u001B[1;32m 2\u001B[0m \u001B[43m \u001B[49m\u001B[38;5;124;43m'\u001B[39;49m\u001B[38;5;124;43mstate\u001B[39;49m\u001B[38;5;124;43m'\u001B[39;49m\u001B[43m:\u001B[49m\u001B[43m \u001B[49m\u001B[43minstance\u001B[49m\n\u001B[1;32m 3\u001B[0m \u001B[43m}\u001B[49m\u001B[43m)\u001B[49m\n",
"File \u001B[0;32m~/Library/Caches/pypoetry/virtualenvs/biosimulator-processes-KVuYbFzt-py3.10/lib/python3.10/site-packages/process_bigraph/composite.py:411\u001B[0m, in \u001B[0;36mComposite.__init__\u001B[0;34m(self, config, local_types)\u001B[0m\n\u001B[1;32m 408\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mglobal_time\u001B[39m\u001B[38;5;124m'\u001B[39m \u001B[38;5;129;01mnot\u001B[39;00m \u001B[38;5;129;01min\u001B[39;00m initial_state:\n\u001B[1;32m 409\u001B[0m initial_state[\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mglobal_time\u001B[39m\u001B[38;5;124m'\u001B[39m] \u001B[38;5;241m=\u001B[39m \u001B[38;5;241m0.0\u001B[39m\n\u001B[0;32m--> 411\u001B[0m composition, state \u001B[38;5;241m=\u001B[39m \u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mcore\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mcomplete\u001B[49m\u001B[43m(\u001B[49m\n\u001B[1;32m 412\u001B[0m \u001B[43m \u001B[49m\u001B[43minitial_composition\u001B[49m\u001B[43m,\u001B[49m\n\u001B[1;32m 413\u001B[0m \u001B[43m \u001B[49m\u001B[43minitial_state\u001B[49m\u001B[43m)\u001B[49m\n\u001B[1;32m 415\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mcomposition \u001B[38;5;241m=\u001B[39m copy\u001B[38;5;241m.\u001B[39mdeepcopy(\n\u001B[1;32m 416\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mcore\u001B[38;5;241m.\u001B[39maccess(composition))\n\u001B[1;32m 418\u001B[0m \u001B[38;5;66;03m# TODO: add flag to self.core.access(copy=True)\u001B[39;00m\n",
"File \u001B[0;32m~/Library/Caches/pypoetry/virtualenvs/biosimulator-processes-KVuYbFzt-py3.10/lib/python3.10/site-packages/bigraph_schema/type_system.py:1251\u001B[0m, in \u001B[0;36mTypeSystem.complete\u001B[0;34m(self, initial_schema, initial_state)\u001B[0m\n\u001B[1;32m 1245\u001B[0m state \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mhydrate(\n\u001B[1;32m 1246\u001B[0m full_schema,\n\u001B[1;32m 1247\u001B[0m initial_state)\n\u001B[1;32m 1249\u001B[0m \u001B[38;5;66;03m# fill in the parts of the composition schema\u001B[39;00m\n\u001B[1;32m 1250\u001B[0m \u001B[38;5;66;03m# determined by the state\u001B[39;00m\n\u001B[0;32m-> 1251\u001B[0m schema, state \u001B[38;5;241m=\u001B[39m \u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43minfer_schema\u001B[49m\u001B[43m(\u001B[49m\n\u001B[1;32m 1252\u001B[0m \u001B[43m \u001B[49m\u001B[43mfull_schema\u001B[49m\u001B[43m,\u001B[49m\n\u001B[1;32m 1253\u001B[0m \u001B[43m \u001B[49m\u001B[43mstate\u001B[49m\u001B[43m)\u001B[49m\n\u001B[1;32m 1255\u001B[0m final_state \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mfill(schema, state)\n\u001B[1;32m 1257\u001B[0m \u001B[38;5;66;03m# TODO: add flag to types.access(copy=True)\u001B[39;00m\n",
"File \u001B[0;32m~/Library/Caches/pypoetry/virtualenvs/biosimulator-processes-KVuYbFzt-py3.10/lib/python3.10/site-packages/process_bigraph/type_system.py:243\u001B[0m, in \u001B[0;36mProcessTypes.infer_schema\u001B[0;34m(self, schema, state, top_state, path)\u001B[0m\n\u001B[1;32m 240\u001B[0m inner_path \u001B[38;5;241m=\u001B[39m path \u001B[38;5;241m+\u001B[39m (key,)\n\u001B[1;32m 241\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m get_path(schema, inner_path) \u001B[38;5;129;01mis\u001B[39;00m \u001B[38;5;28;01mNone\u001B[39;00m \u001B[38;5;129;01mor\u001B[39;00m get_path(state, inner_path) \u001B[38;5;129;01mis\u001B[39;00m \u001B[38;5;28;01mNone\u001B[39;00m \u001B[38;5;129;01mor\u001B[39;00m (\n\u001B[1;32m 242\u001B[0m \u001B[38;5;28misinstance\u001B[39m(value, \u001B[38;5;28mdict\u001B[39m) \u001B[38;5;129;01mand\u001B[39;00m \u001B[38;5;124m'\u001B[39m\u001B[38;5;124m_type\u001B[39m\u001B[38;5;124m'\u001B[39m \u001B[38;5;129;01min\u001B[39;00m value):\n\u001B[0;32m--> 243\u001B[0m schema, top_state \u001B[38;5;241m=\u001B[39m \u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43minfer_schema\u001B[49m\u001B[43m(\u001B[49m\n\u001B[1;32m 244\u001B[0m \u001B[43m \u001B[49m\u001B[43mschema\u001B[49m\u001B[43m,\u001B[49m\n\u001B[1;32m 245\u001B[0m \u001B[43m \u001B[49m\u001B[43mvalue\u001B[49m\u001B[43m,\u001B[49m\n\u001B[1;32m 246\u001B[0m \u001B[43m \u001B[49m\u001B[43mtop_state\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43mtop_state\u001B[49m\u001B[43m,\u001B[49m\n\u001B[1;32m 247\u001B[0m \u001B[43m \u001B[49m\u001B[43mpath\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[43minner_path\u001B[49m\u001B[43m)\u001B[49m\n\u001B[1;32m 249\u001B[0m \u001B[38;5;28;01melif\u001B[39;00m \u001B[38;5;28misinstance\u001B[39m(state, \u001B[38;5;28mstr\u001B[39m):\n\u001B[1;32m 250\u001B[0m \u001B[38;5;28;01mpass\u001B[39;00m\n",
"File \u001B[0;32m~/Library/Caches/pypoetry/virtualenvs/biosimulator-processes-KVuYbFzt-py3.10/lib/python3.10/site-packages/process_bigraph/type_system.py:195\u001B[0m, in \u001B[0;36mProcessTypes.infer_schema\u001B[0;34m(self, schema, state, top_state, path)\u001B[0m\n\u001B[1;32m 192\u001B[0m state_type \u001B[38;5;241m=\u001B[39m state[\u001B[38;5;124m'\u001B[39m\u001B[38;5;124m_type\u001B[39m\u001B[38;5;124m'\u001B[39m]\n\u001B[1;32m 193\u001B[0m state_schema \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39maccess(state_type)\n\u001B[0;32m--> 195\u001B[0m hydrated_state \u001B[38;5;241m=\u001B[39m \u001B[38;5;28;43mself\u001B[39;49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mdeserialize\u001B[49m\u001B[43m(\u001B[49m\u001B[43mstate_schema\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mstate\u001B[49m\u001B[43m)\u001B[49m\n\u001B[1;32m 196\u001B[0m top_state \u001B[38;5;241m=\u001B[39m set_path(\n\u001B[1;32m 197\u001B[0m top_state,\n\u001B[1;32m 198\u001B[0m path,\n\u001B[1;32m 199\u001B[0m hydrated_state)\n\u001B[1;32m 201\u001B[0m schema \u001B[38;5;241m=\u001B[39m set_path(\n\u001B[1;32m 202\u001B[0m schema,\n\u001B[1;32m 203\u001B[0m path,\n\u001B[1;32m 204\u001B[0m {\u001B[38;5;124m'\u001B[39m\u001B[38;5;124m_type\u001B[39m\u001B[38;5;124m'\u001B[39m: state_type})\n",
"File \u001B[0;32m~/Library/Caches/pypoetry/virtualenvs/biosimulator-processes-KVuYbFzt-py3.10/lib/python3.10/site-packages/bigraph_schema/type_system.py:605\u001B[0m, in \u001B[0;36mTypeSystem.deserialize\u001B[0;34m(self, schema, encoded)\u001B[0m\n\u001B[1;32m 602\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m encoded \u001B[38;5;129;01mis\u001B[39;00m \u001B[38;5;28;01mNone\u001B[39;00m:\n\u001B[1;32m 603\u001B[0m encoded \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mdefault(schema)\n\u001B[0;32m--> 605\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[43mdeserialize_function\u001B[49m\u001B[43m(\u001B[49m\n\u001B[1;32m 606\u001B[0m \u001B[43m \u001B[49m\u001B[43mencoded\u001B[49m\u001B[43m,\u001B[49m\n\u001B[1;32m 607\u001B[0m \u001B[43m \u001B[49m\u001B[43mfound\u001B[49m\u001B[43m,\u001B[49m\n\u001B[1;32m 608\u001B[0m \u001B[43m \u001B[49m\u001B[38;5;28;43mself\u001B[39;49m\u001B[43m)\u001B[49m\n\u001B[1;32m 610\u001B[0m \u001B[38;5;28;01melif\u001B[39;00m \u001B[38;5;28misinstance\u001B[39m(encoded, \u001B[38;5;28mdict\u001B[39m):\n\u001B[1;32m 611\u001B[0m result \u001B[38;5;241m=\u001B[39m {}\n",
"File \u001B[0;32m~/Library/Caches/pypoetry/virtualenvs/biosimulator-processes-KVuYbFzt-py3.10/lib/python3.10/site-packages/process_bigraph/type_system.py:86\u001B[0m, in \u001B[0;36mdeserialize_process\u001B[0;34m(encoded, schema, core)\u001B[0m\n\u001B[1;32m 81\u001B[0m interval \u001B[38;5;241m=\u001B[39m core\u001B[38;5;241m.\u001B[39mdeserialize(\n\u001B[1;32m 82\u001B[0m \u001B[38;5;124m'\u001B[39m\u001B[38;5;124minterval\u001B[39m\u001B[38;5;124m'\u001B[39m,\n\u001B[1;32m 83\u001B[0m encoded\u001B[38;5;241m.\u001B[39mget(\u001B[38;5;124m'\u001B[39m\u001B[38;5;124minterval\u001B[39m\u001B[38;5;124m'\u001B[39m))\n\u001B[1;32m 85\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;129;01mnot\u001B[39;00m \u001B[38;5;124m'\u001B[39m\u001B[38;5;124minstance\u001B[39m\u001B[38;5;124m'\u001B[39m \u001B[38;5;129;01min\u001B[39;00m deserialized:\n\u001B[0;32m---> 86\u001B[0m process \u001B[38;5;241m=\u001B[39m \u001B[43minstantiate\u001B[49m\u001B[43m(\u001B[49m\u001B[43mconfig\u001B[49m\u001B[43m)\u001B[49m\n\u001B[1;32m 87\u001B[0m deserialized[\u001B[38;5;124m'\u001B[39m\u001B[38;5;124minstance\u001B[39m\u001B[38;5;124m'\u001B[39m] \u001B[38;5;241m=\u001B[39m process\n\u001B[1;32m 89\u001B[0m deserialized[\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mconfig\u001B[39m\u001B[38;5;124m'\u001B[39m] \u001B[38;5;241m=\u001B[39m config\n",
"File \u001B[0;32m~/Desktop/uchc_work/biosimulator-processes/notebooks/../biosimulator_processes/processes/copasi_process.py:142\u001B[0m, in \u001B[0;36m__init__\u001B[0;34m(self, config, core)\u001B[0m\n\u001B[1;32m 139\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m \u001B[38;5;21m__init__\u001B[39m(\u001B[38;5;28mself\u001B[39m, config\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mNone\u001B[39;00m, core\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mNone\u001B[39;00m):\n\u001B[1;32m 140\u001B[0m \u001B[38;5;28msuper\u001B[39m()\u001B[38;5;241m.\u001B[39m\u001B[38;5;21m__init__\u001B[39m(config, core)\n\u001B[0;32m--> 142\u001B[0m model_file \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mconfig\u001B[38;5;241m.\u001B[39mget(\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mmodel\u001B[39m\u001B[38;5;124m'\u001B[39m)\u001B[38;5;241m.\u001B[39mget(\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mmodel_source\u001B[39m\u001B[38;5;124m'\u001B[39m)\n\u001B[1;32m 143\u001B[0m sed_model_id \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mconfig\u001B[38;5;241m.\u001B[39mget(\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mmodel\u001B[39m\u001B[38;5;124m'\u001B[39m)\u001B[38;5;241m.\u001B[39mget(\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mmodel_id\u001B[39m\u001B[38;5;124m'\u001B[39m)\n\u001B[1;32m 144\u001B[0m biomodel_id \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mconfig\u001B[38;5;241m.\u001B[39mget(\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mbiomodel_id\u001B[39m\u001B[38;5;124m'\u001B[39m)\n",
"\u001B[0;31mKeyError\u001B[0m: 'model_file'"
]
}
],
"source": [
"workflow = Composite({\n",
" 'state': instance\n",
Expand Down

0 comments on commit b41f341

Please sign in to comment.