diff --git a/Dockerfile b/Dockerfile index c2e531d..012ee82 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # Base OS FROM python:3.9-slim-buster -ARG VERSION="0.0.5" +ARG VERSION="0.0.6" ARG SIMULATOR_VERSION=8.0 # metadata diff --git a/biosimulators_xpp/_version.py b/biosimulators_xpp/_version.py index eead319..fa9c4ec 100644 --- a/biosimulators_xpp/_version.py +++ b/biosimulators_xpp/_version.py @@ -1 +1 @@ -__version__ = '0.0.5' +__version__ = '0.0.6' diff --git a/biosimulators_xpp/core.py b/biosimulators_xpp/core.py index 74d1a19..f156875 100644 --- a/biosimulators_xpp/core.py +++ b/biosimulators_xpp/core.py @@ -97,7 +97,7 @@ def exec_sed_task(task, variables, preprocessed_task=None, log=None, config=None Args: task (:obj:`Task`): task variables (:obj:`list` of :obj:`Variable`): variables that should be recorded - preprocessed_task (:obj:`object`, optional): preprocessed information about the task, including possible + preprocessed_task (:obj:`dict`, optional): preprocessed information about the task, including possible model changes and variables. This can be used to avoid repeatedly executing the same initialization for repeated calls to this method. log (:obj:`TaskLog`, optional): log for the task @@ -127,36 +127,14 @@ def exec_sed_task(task, variables, preprocessed_task=None, log=None, config=None model = task.model sim = task.simulation - if config.VALIDATE_SEDML: - raise_errors_warnings(validation.validate_task(task), - error_summary='Task `{}` is invalid.'.format(task.id)) - raise_errors_warnings(validation.validate_model_language(model.language, ModelLanguage.XPP), - error_summary='Language for model `{}` is not supported.'.format(model.id)) - raise_errors_warnings(validation.validate_model_change_types(model.changes, (ModelAttributeChange, )), - error_summary='Changes for model `{}` are not supported.'.format(model.id)) - raise_errors_warnings(*validation.validate_model_changes(model), - error_summary='Changes for model `{}` are invalid.'.format(model.id)) - raise_errors_warnings(validation.validate_simulation_type(sim, (UniformTimeCourseSimulation, )), - error_summary='{} `{}` is not supported.'.format(sim.__class__.__name__, sim.id)) - raise_errors_warnings(*validation.validate_simulation(sim), - error_summary='Simulation `{}` is invalid.'.format(sim.id)) - - if config.VALIDATE_SEDML_MODELS: - raise_errors_warnings(*validation.validate_model(model, [], working_dir='.'), - error_summary='Model `{}` is invalid.'.format(model.id), - warning_summary='Model `{}` may be invalid.'.format(model.id)) - # read model - _, _, xpp_sim = validate_model(model.source) - - # validate observables - validate_variables(xpp_sim, variables) + xpp_sim = preprocessed_task['xpp_simulation'] # model changes apply_model_changes(xpp_sim, model.changes) # setup simulation - exec_kisao_id = set_up_simulation(sim, xpp_sim['simulation_method'], config=config) + exec_kisao_id = preprocessed_task['algorithm_kisao_id'] # run simulation raw_results = exec_xpp_simulation(model.source, xpp_sim) @@ -181,12 +159,46 @@ def preprocess_sed_task(task, variables, config=None): Args: task (:obj:`Task`): task variables (:obj:`list` of :obj:`Variable`): variables that should be recorded - preprocessed_task (:obj:`PreprocessedTask`, optional): preprocessed information about the task, including possible - model changes and variables. This can be used to avoid repeatedly executing the same initialization for repeated - calls to this method. config (:obj:`Config`, optional): BioSimulators common configuration Returns: :obj:`object`: preprocessed information about the task """ - pass + config = config or get_config() + + # validate task + model = task.model + sim = task.simulation + + if config.VALIDATE_SEDML: + raise_errors_warnings(validation.validate_task(task), + error_summary='Task `{}` is invalid.'.format(task.id)) + raise_errors_warnings(validation.validate_model_language(model.language, ModelLanguage.XPP), + error_summary='Language for model `{}` is not supported.'.format(model.id)) + raise_errors_warnings(validation.validate_model_change_types(model.changes, (ModelAttributeChange, )), + error_summary='Changes for model `{}` are not supported.'.format(model.id)) + raise_errors_warnings(*validation.validate_model_changes(model), + error_summary='Changes for model `{}` are invalid.'.format(model.id)) + raise_errors_warnings(validation.validate_simulation_type(sim, (UniformTimeCourseSimulation, )), + error_summary='{} `{}` is not supported.'.format(sim.__class__.__name__, sim.id)) + raise_errors_warnings(*validation.validate_simulation(sim), + error_summary='Simulation `{}` is invalid.'.format(sim.id)) + + if config.VALIDATE_SEDML_MODELS: + raise_errors_warnings(*validation.validate_model(model, [], working_dir='.'), + error_summary='Model `{}` is invalid.'.format(model.id), + warning_summary='Model `{}` may be invalid.'.format(model.id)) + + # read model + _, _, xpp_sim = validate_model(model.source) + + # validate observables + validate_variables(xpp_sim, variables) + + # setup simulation + exec_kisao_id = set_up_simulation(sim, xpp_sim['simulation_method'], config=config) + + return { + 'xpp_simulation': xpp_sim, + 'algorithm_kisao_id': exec_kisao_id, + }