Skip to content

Commit

Permalink
update env creation
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPatrie committed Nov 7, 2024
1 parent 2690172 commit 78b8a68
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 77 deletions.
22 changes: 9 additions & 13 deletions assets/dev/scripts/create_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,19 @@ function construct_env {
arm_platform=$(uname -a | grep "Darwin")
echo "Creating environment from ./environment.yml on $arm_platform..."
source /Users/alexanderpatrie/miniconda3/etc/profile.d/conda.sh

# update base pip
conda run pip3 install --upgrade pip
conda run pip install --upgrade pip

# create and activate env
conda env create -f ./environment.yml -y
conda activate bio-compose-server

# install pysces and poetry deps
conda install -n bio-compose-server -c conda-forge -c pysces pysces -y
poetry config virtualenvs.create false
sudo conda run -n bio-compose-server poetry env use 3.10
sudo conda run -n bio-compose-server poetry lock
sudo conda run -n bio-compose-server poetry install --only=dev
conda run -n bio-compose-server pip3 install --upgrade pip
conda run -n bio-compose-server pip install --upgrade pip
./assets/dev/scripts/install-smoldyn-mac-silicon.sh || poetry run pip3 install smoldyn
sudo conda run -n bio-compose-server poetry run pip3 install amici biosimulators-amici biosimulators-pysces
conda run -n bio-compose-server pip3 install amici biosimulators-amici # biosimulators-pysces
# conda install -n bio-compose-server -c conda-forge -c pysces pysces -y
# poetry config virtualenvs.create false
# sudo conda run -n bio-compose-server poetry env use 3.10
# sudo conda run -n bio-compose-server poetry lock
# sudo conda run -n bio-compose-server poetry install --only=dev
.
# poetry run pip install ./api ./worker

echo "Environment created!"
Expand Down
49 changes: 25 additions & 24 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,28 @@ dependencies:
- python=3.10
- poetry
- pysces
# - pip:
# - pip-autoremove
# - requests-toolbelt
# - python-dotenv
# - google-cloud-storage
# - python-multipart
# - fastapi
# - toml
# - typing-extensions
# - pymongo
# - pydantic-settings
# - pydantic
# - uvicorn
# - pyyaml
# - simulariumio
# - copasi-basico
# - tellurium
# - biosimulators-copasi
# - biosimulators-tellurium
# - seaborn
# - jupyterlab
# - process-bigraph
# - bigraph-schema
# - pytest
- pip:
- pip-autoremove
- requests-toolbelt
- python-dotenv
- google-cloud-storage
- python-multipart
- fastapi
- toml
- typing-extensions
- pymongo
- pydantic-settings
- pydantic
- uvicorn
- pyyaml
- simulariumio
- copasi-basico
- tellurium
- biosimulators-copasi
- biosimulators-tellurium
- biosimulators-pysces
- seaborn
- jupyterlab
- process-bigraph
- bigraph-schema
- pytest
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ classifiers=[
]
keywords=['systems', 'biology', 'modeling', 'simulation']


[tool.poetry.dependencies]
python = "^3.10"

Expand Down
Binary file removed smoldyn-2.73-mac.tgz.2
Binary file not shown.
38 changes: 0 additions & 38 deletions worker/service/__init__.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,4 @@
from typing import List, Tuple

from process_bigraph import ProcessTypes


APP_PROCESS_REGISTRY = ProcessTypes()
IMPLEMENTATIONS = [
('output-generator', 'steps.OutputGenerator'),
('time-course-output-generator', 'steps.TimeCourseOutputGenerator'),
('smoldyn_step', 'steps.SmoldynStep'),
('simularium_smoldyn_step', 'steps.SimulariumSmoldynStep'),
('mongo-emitter', 'steps.MongoDatabaseEmitter')
]


def register_module(
items_to_register: List[Tuple[str, str]],
verbose=False
) -> None:
for process_name, path in items_to_register:
module_name, class_name = path.rsplit('.', 1)
try:
import_statement = f'worker.bigraph.{module_name}'

module = __import__(
import_statement, fromlist=[class_name])

# Get the class from the module
bigraph_class = getattr(module, class_name)

# Register the process
APP_PROCESS_REGISTRY.process_registry.register(process_name, bigraph_class)
print(f'Registered {process_name}') if verbose else None
except Exception as e:
print(f"Cannot register {class_name}. Error:\n**\n{e}\n**") if verbose else None
continue


register_module(IMPLEMENTATIONS)


# APP_PROCESS_REGISTRY.process_registry.register('time-course-output-generator', TimeCourseOutputGenerator)
Expand Down
38 changes: 37 additions & 1 deletion worker/service/main.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,51 @@
import os
import asyncio
import logging
from typing import List, Tuple

from process_bigraph import ProcessTypes
from dotenv import load_dotenv

from service import APP_PROCESS_REGISTRY
from service.shared_worker import MongoDbConnector
from service.log_config import setup_logging
from service.job import Supervisor


def register_module(
items_to_register: List[Tuple[str, str]],
core: ProcessTypes,
verbose=False
) -> None:
for process_name, path in items_to_register:
module_name, class_name = path.rsplit('.', 1)
try:
import_statement = f'worker.service.bigraph.{module_name}'

module = __import__(
import_statement, fromlist=[class_name])

# Get the class from the module
bigraph_class = getattr(module, class_name)

# Register the process
core.process_registry.register(process_name, bigraph_class)
print(f'Registered {process_name}') if verbose else None
except Exception as e:
print(f"Cannot register {class_name}. Error:\n**\n{e}\n**") if verbose else None
continue


APP_PROCESS_REGISTRY = ProcessTypes()
IMPLEMENTATIONS = [
('output-generator', 'steps.OutputGenerator'),
('time-course-output-generator', 'steps.TimeCourseOutputGenerator'),
# ('smoldyn_step', 'steps.SmoldynStep'),
('simularium_smoldyn_step', 'steps.SimulariumSmoldynStep'),
('mongo-emitter', 'steps.MongoDatabaseEmitter')
]
register_module(IMPLEMENTATIONS, APP_PROCESS_REGISTRY, verbose=True)


load_dotenv('../../assets/dev/config/.env_dev')

# logging TODO: implement this.
Expand Down
1 change: 1 addition & 0 deletions worker/service/shared_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

# -- globally-shared content-- #


load_dotenv('../../assets/dev/config/.env_dev')

DB_TYPE = "mongo" # ie: postgres, etc
Expand Down

0 comments on commit 78b8a68

Please sign in to comment.