From c9152521e34f3157c58207031c46f28f5dc281b2 Mon Sep 17 00:00:00 2001 From: alexPatrie Date: Mon, 4 Mar 2024 11:51:42 -0500 Subject: [PATCH] added exec count fixer in utils --- biosimulator_processes/utils.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/biosimulator_processes/utils.py b/biosimulator_processes/utils.py index ab3915bc0..14266928d 100644 --- a/biosimulator_processes/utils.py +++ b/biosimulator_processes/utils.py @@ -1,6 +1,7 @@ from typing import Dict from basico import biomodels, load_model_from_string from process_bigraph import Composite, pf +import nbformat from pydantic import BaseModel @@ -227,3 +228,16 @@ def generate_sed_model_config_schema( def perturb_parameter(param: str, degree: float, config: Dict): pass + + +def fix_execution_count(notebook_path): + with open(notebook_path, 'r', encoding='utf-8') as f: + nb = nbformat.read(f, as_version=4) + + for cell in nb['cells']: + if cell['cell_type'] == 'code': + if 'execution_count' not in cell: + cell['execution_count'] = None + + with open(notebook_path, 'w', encoding='utf-8') as f: + nbformat.write(nb, f)