Skip to content

Commit

Permalink
updated builder and datamodel for spec
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPatrie committed Mar 6, 2024
1 parent 086ca1d commit 548f8a3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
20 changes: 19 additions & 1 deletion biosimulator_processes/data_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
'BaseModel',
'TimeCourseProcessConfigSchema',
'ModelParameter',
'ProcessConfig'
'ProcessConfig',
'Port',
'State'
]


Expand Down Expand Up @@ -195,6 +197,22 @@ def set_value(cls):


# --- TYPE REGISTRY
class ProcessConfig(BaseModel):
value: Dict


class Port(BaseModel):
value: Dict


class State(BaseModel):
# THINK: builder_api LN.120: add_process. TODO: This should be parsable by the builder in add process.
_type: str
address: str
config: ProcessConfig
inputs: Port
outputs: Port


# --- PROCESSES
class ProcessConfigSchema(BaseModel):
Expand Down
15 changes: 10 additions & 5 deletions biosimulator_processes/processes/copasi_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"""


from typing import Dict
from typing import Dict, Union
from pandas import DataFrame
from basico import *
# from basico import (
Expand Down Expand Up @@ -81,12 +81,17 @@ class CopasiProcess(Process):

config_schema = TimeCourseProcessConfigSchema().model_dump()

def __init__(self, config: ProcessConfig=None, core=None):
def __init__(self,
config: Union[CopasiProcessConfig, Dict] = None,
core=None):
super().__init__(config, core)


model_source = self.config['model']['model_source']['value']
self.model_changes = self.config['model'].get('model_changes', {})
if isinstance(self.config, dict):
model_source = self.config['model']['model_source']['value']
self.model_changes = self.config['model'].get('model_changes', {})
elif isinstance(self.config, CopasiProcessConfig):
model_source = self.config.model.model_source.value
self.model_changes = self.config.model.model_changes or {}

# A. enter with model_file
if '/' in model_source:
Expand Down

0 comments on commit 548f8a3

Please sign in to comment.