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

Commit

Permalink
updated data model for config
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPatrie committed Mar 6, 2024
1 parent 8b07048 commit 4861061
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
13 changes: 5 additions & 8 deletions biosimulator_processes/data_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,13 @@ class ProcessConfigSchema(BaseModel):
config: Dict = Field(default={})


class CopasiProcessConfigSchema(BaseModel):
class ProcessConfig(BaseModel):
process_name: str
method: str = Field(default='deterministic')
model: Union[TimeCourseModel, Dict]

def __init__(self, **data):
super().__init__(**data)
if isinstance(self.model, TimeCourseModel):
self.model = self.model.model_dump()

class CopasiProcessConfig(ProcessConfig):
method: str = Field(default='deterministic')
model: TimeCourseModel

# @field_serializer('model', when_used='json')
# @classmethod
Expand Down Expand Up @@ -235,7 +233,6 @@ class ProcessInstance(BaseModel):
config: Union[CopasiProcessConfigSchema, ProcessConfigSchema]
inputs: PortSchema
outputs: PortSchema
emitter: Union[EmitterInstance, NoneType] = Field(default=None)

@classmethod
@field_validator('address')
Expand Down
4 changes: 2 additions & 2 deletions biosimulator_processes/processes/copasi_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
# )
from process_bigraph import Process, Composite, pf
from biosimulator_processes.utils import fetch_biomodel
from biosimulator_processes.data_model import TimeCourseProcessConfigSchema
from biosimulator_processes.data_model import TimeCourseProcessConfigSchema, CopasiProcessConfig


class CopasiProcess(Process):
Expand Down Expand Up @@ -81,7 +81,7 @@ class CopasiProcess(Process):

config_schema = TimeCourseProcessConfigSchema().model_dump()

def __init__(self, config=None, core=None):
def __init__(self, config: CopasiProcessConfig=None, core=None):
super().__init__(config, core)

model_source = self.config['model']['model_source']['value']
Expand Down

0 comments on commit 4861061

Please sign in to comment.