Skip to content

Commit

Permalink
update scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPatrie committed Nov 6, 2024
1 parent c483d34 commit ab959f8
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 10 deletions.
4 changes: 2 additions & 2 deletions assets/dev/scripts/install-smoldyn-mac-silicon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ tarball_name=smoldyn-2.73-mac.tgz
dist_dir=${tarball_name%.tgz}

# uninstall existing version
poetry run pip uninstall smoldyn || return
conda run pip uninstall smoldyn || return

# download the appropriate distribution from smoldyn
wget $dist_url
Expand All @@ -23,7 +23,7 @@ rm $tarball_name
# install smoldyn from the source
cd $dist_dir || return

if poetry run sudo -H ./install.sh; then
if conda run sudo -H ./install.sh; then
cd ..
# remove the smoldyn dist
rm -r $dist_dir
Expand Down
44 changes: 44 additions & 0 deletions worker/service/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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)
# APP_PROCESS_REGISTRY.process_registry.register('output-generator', OutputGenerator)

9 changes: 4 additions & 5 deletions worker/service/bigraph/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
from simulariumio import InputFileData, UnitData, DisplayData, DISPLAY_TYPE
from simulariumio.smoldyn import SmoldynData

from worker.service.io_worker import get_sbml_species_mapping
from worker.service.verification import SBML_EXECUTORS

try:
import smoldyn as sm
from smoldyn._smoldyn import MolecState
Expand All @@ -26,8 +23,10 @@
'on installing Smoldyn.'
)

from worker.service.simularium_utils import calculate_agent_radius, translate_data_object, write_simularium_file
from worker import APP_PROCESS_REGISTRY
from service.io_worker import get_sbml_species_mapping
from service.verification import SBML_EXECUTORS
from service.simularium_utils import calculate_agent_radius, translate_data_object, write_simularium_file
from service import APP_PROCESS_REGISTRY

process_registry = APP_PROCESS_REGISTRY.process_registry

Expand Down
7 changes: 4 additions & 3 deletions worker/service/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

from dotenv import load_dotenv

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


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

0 comments on commit ab959f8

Please sign in to comment.