Skip to content

Commit

Permalink
feat: added justed process example to ntbk
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPatrie committed Mar 15, 2024
1 parent 5f303c6 commit 87273f9
Show file tree
Hide file tree
Showing 6 changed files with 1,505 additions and 38 deletions.
19 changes: 16 additions & 3 deletions biosimulator_processes/biosimulator_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,27 @@ def execute(self, num: int = None, duration: int = None, **run_params) -> None:
self.start(num)
return self.run(duration, **run_params)

def write_bigraph(self, fp: str, output_dir='out'):
"""Use the builder instance attribute to write out the bigraph document to a fp."""
return self.builder_instance.write(filename=fp, outdir=output_dir)

def wipe_builder(self):
self.builder_instance = None
print(f'Builder flushed! This is verified because builder is: {self.builder_instance}')

def flush(self, out_dir='out'):
def flush(self, out_dir='out', fp: str = None, write: bool = True) -> None:
"""Optionally write the bigraph to document and wipe the current builder_instance instance.
Args:
out_dir:`str`: destination to which we save the document.
fp:`str`: path by which to save if write is true. Defaults to None.
write:`bool`: whether to write out the document before wiping. Defaults to `True`.
"""
from datetime import datetime
fp = f"BUILD_FLUSH_{str(datetime.now()).replace(' ', '__').replace(':', '_')}"
self.builder_instance.write(fp, out_dir)
if write:
if fp is None:
fp = f"BUILD_FLUSH_{str(datetime.now()).replace(' ', '__').replace(':', '_')}"
self.write_bigraph(fp, out_dir)
return self.wipe_builder()

def visualize_bigraph(self):
Expand Down
12 changes: 11 additions & 1 deletion biosimulator_processes/data_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,16 +214,26 @@ def set_model_source_info(self, **kwargs):

@dataclass
class TimeCourseModel(SedModel):
"""The data model declaration for process configuration schemas that support SED.
Attributes:
model_id: `str`
model_source: `Union[biosimulator_processes.data_model.ModelFilepath, biosimulator_processes.data_model.BiomodelId]`
model_language: `str`
model_name: `str`
model_changes: `biosimulator_processes.data_model.TimeCourseModelChanges`
"""
model_language: str = None,
model_changes: TimeCourseModelChanges = None,
model_units: ModelUnits = None

def __init__(self,
model_source: Union[BiomodelID, ModelFilepath, str],
model_changes=model_changes,
model_id=None,
model_name=None):
"""Class which inherits SedModel."""
super().__init__(model_source, model_id, model_name)
super().__init__(model_source, model_id, model_name, model_changes)
# TODO: extract functionality for algorithms related to UTC sims
self.model_id = self.set_id(model_id)
self.model_name = self.set_name(model_name)
Expand Down
Loading

0 comments on commit 87273f9

Please sign in to comment.