Skip to content

Commit

Permalink
Merge pull request #7 from biosimulators/main
Browse files Browse the repository at this point in the history
updated ignore
  • Loading branch information
AlexPatrie authored Mar 6, 2024
2 parents 73d4237 + c56d7a4 commit bb8bcf2
Show file tree
Hide file tree
Showing 28 changed files with 294 additions and 1,444 deletions.
686 changes: 0 additions & 686 deletions .THIS-IS-FOR-CONTAINER-DEV-ONLY

This file was deleted.

25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,26 @@
buildImage.yaml
.python-version
__pycache__/
.idea/
*.ipynb_checkpoints/
dist/
.DS_Store
*.egg-info/
refresh-env.sh
smoldyn-2.72-mac/
build/
commit.sh
install.sh
push-image.sh
release.sh
run.sh
ray_job.sh
__pycache__
.pytest_cache
submit-biosimulators-container.sh
.vagrant
._vagrant
.THIS-IS-FOR-CONTAINER-DEV-ONLY
buildDockerImage.yml
.env

8 changes: 0 additions & 8 deletions .idea/.gitignore

This file was deleted.

12 changes: 0 additions & 12 deletions .idea/biosimulator-processes.iml

This file was deleted.

116 changes: 0 additions & 116 deletions .idea/inspectionProfiles/Project_Default.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/inspectionProfiles/profiles_settings.xml

This file was deleted.

7 changes: 0 additions & 7 deletions .idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

33 changes: 16 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
# TODO: Use a more specific tag instead of latest for reproducibility
FROM ubuntu:latest

ENV DEBIAN_FRONTEND=noninteractive \
XVFB_RES="1920x1080x24" \
XVFB_ARGS="" \
PATH="/app/.venv/bin:$PATH" \
CONFIG_ENV_FILE="/app/config/config.env" \
SECRET_ENV_FILE="/app/secret/secret.env" \
STORAGE_GCS_CREDENTIALS_FILE="/app/secret/gcs_credentials.json" \
STORAGE_LOCAL_CACHE_DIR="/app/scratch"
ENV DEBIAN_FRONTEND=noninteractive
# XVFB_RES="1920x1080x24" \
# XVFB_ARGS="" \
# PATH="/app/.venv/bin:$PATH" \
# CONFIG_ENV_FILE="/app/config/config.env" \
# SECRET_ENV_FILE="/app/secret/secret.env" \
# STORAGE_GCS_CREDENTIALS_FILE="/app/secret/gcs_credentials.json" \
# STORAGE_LOCAL_CACHE_DIR="/app/scratch"

WORKDIR /app

# copy and make dirs
COPY ./biosimulator_processes /app/biosimulator_processes
COPY ./notebooks /app/notebooks
COPY notebooks /app/notebooks

# copy files
COPY ./pyproject.toml ./poetry.lock ./data ./scripts/trust-notebooks.sh /app/
COPY ./scripts/xvfb-startup.sh /xvfb-startup.sh
COPY pyproject.toml poetry.lock ./data ./scripts/trust-notebooks.sh /app/
# COPY ./scripts/xvfb-startup.sh /xvfb-startup.sh

VOLUME /app/data

RUN apt-get update && apt-get install -y --no-install-recommends \
python3.10 \
ca-certificates \
python3-pip \
python3-dev \
build-essential \
Expand All @@ -43,20 +44,18 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
libice6 \
libpython3.10 \
wget \
xvfb \
&& mkdir /tmp/.X11-unix \
&& chmod 1777 /tmp/.X11-unix \
&& rm -rf /var/lib/apt/lists/* \
&& pip install --upgrade pip && pip install poetry \
&& poetry config virtualenvs.in-project true \
# && poetry run pip install psutil \
&& poetry update \
&& poetry install \
&& chmod +x ./trust-notebooks.sh \
&& ./trust-notebooks.sh \
&& rm ./trust-notebooks.sh
&& rm ./trust-notebooks.sh \
&& apt-get clean \
&& apt-get autoclean

CMD ["poetry", "run", "jupyter", "lab", "--port=8888", "--no-browser", "--allow-root"]
# CMD ["poetry", "run", "jupyter", "lab", "--port=8888", "--no-browser", "--allow-root"]


# PLEASE NOTE: We do not need to add a USER in the Dockerfile as Singularity will handle
Expand Down
Binary file modified biosimulator_processes/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file modified biosimulator_processes/__pycache__/data_model.cpython-310.pyc
Binary file not shown.
14 changes: 6 additions & 8 deletions biosimulator_processes/data_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class BaseModel(_BaseModel):

class ModelParameter(BaseModel):
name: str
feature: str
value: Union[float, int, str]
scope: str

Expand Down Expand Up @@ -197,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 @@ -234,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
Binary file not shown.
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
Binary file not shown.
Binary file not shown.
15 changes: 7 additions & 8 deletions biosimulator_processes/steps/parameter_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def update(self, input):
pass


class DeterministicTimeCourseParameterScan(ParameterScan):
class DeterministicTimeCourseParameterScan(Step):
"""Using CopasiProcess as the primary TimeCourse simulator.
# TODO: enable multiple Simulator types.
Expand All @@ -61,20 +61,19 @@ class DeterministicTimeCourseParameterScan(ParameterScan):
used to run during update
"""
config_schema = {
'process_config': {
'_default': TimeCourseProcessConfigSchema().model_dump(),
'_type': 'tree[string]'},
'process_config': TimeCourseProcessConfigSchema().model_dump(),
'n_iterations': 'int',
'iter_stop': 'float',
'iter_start': 'maybe[float]',
'perturbation_magnitude': 'float',
'parameters': 'list[object]'}

def __init__(self, config=None):
super().__init__(config=config)
def __init__(self):
self.process = CopasiProcess(config=self.config.get('process_config'))
self.params_to_scan: List[ModelParameter] = self.config.get('parameters', [])
self.n_iterations = self.config['n_iterations']
self.iter_start = self.config.get('iter_start', 0.0)
self.iter_stop = self.config['iter_stop']


def initial_state(self):
Expand All @@ -98,8 +97,8 @@ def update(self, input):
results = {}
scan_range = np.linspace(
start=self.iter_start,
stop=self.n_iterations,
num=self.config['perturbation_magnitude']).tolist()
stop=self.iter_stop,
num=self.n_iterations).tolist()

for index, perturbed in enumerate(scan_range):
interval = input['time']
Expand Down
2 changes: 1 addition & 1 deletion commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ read -r msg
# echo "Notebooks not fixed."
# fi

poetry run python3 ./scripts/fix_notebooks.py
python3 ./scripts/fix_notebooks.py
git add --all
git commit -m "${msg}"
git push origin "${branch}"
Expand Down
Loading

0 comments on commit bb8bcf2

Please sign in to comment.