diff --git a/assets/dev/scripts/create_env.sh b/assets/dev/scripts/create_env.sh index 764720871..03344f682 100755 --- a/assets/dev/scripts/create_env.sh +++ b/assets/dev/scripts/create_env.sh @@ -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!" diff --git a/environment.yml b/environment.yml index 90ee9e44f..de90d42fc 100644 --- a/environment.yml +++ b/environment.yml @@ -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 \ No newline at end of file + - 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 \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 939b36594..1984ad521 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,6 @@ classifiers=[ ] keywords=['systems', 'biology', 'modeling', 'simulation'] - [tool.poetry.dependencies] python = "^3.10" diff --git a/smoldyn-2.73-mac.tgz.2 b/smoldyn-2.73-mac.tgz.2 deleted file mode 100644 index 6b5b0afd4..000000000 Binary files a/smoldyn-2.73-mac.tgz.2 and /dev/null differ diff --git a/worker/service/__init__.py b/worker/service/__init__.py index 19c001f61..c35f48766 100644 --- a/worker/service/__init__.py +++ b/worker/service/__init__.py @@ -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) diff --git a/worker/service/main.py b/worker/service/main.py index d5eed80af..53a891110 100644 --- a/worker/service/main.py +++ b/worker/service/main.py @@ -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. diff --git a/worker/service/shared_worker.py b/worker/service/shared_worker.py index 52edf075b..f2bf32be3 100644 --- a/worker/service/shared_worker.py +++ b/worker/service/shared_worker.py @@ -17,6 +17,7 @@ # -- globally-shared content-- # + load_dotenv('../../assets/dev/config/.env_dev') DB_TYPE = "mongo" # ie: postgres, etc