Skip to content

Commit

Permalink
fix: load training and inference modules on worker startup
Browse files Browse the repository at this point in the history
  • Loading branch information
dodamih committed May 10, 2024
1 parent bd84a02 commit 8debe89
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions zetta_utils/mazepa_addons/configurations/worker_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import pebble

from zetta_utils import builder, log
from zetta_utils import builder, log, try_load_train_inference
from zetta_utils.mazepa import SemaphoreType, Task, configure_semaphores, run_worker
from zetta_utils.mazepa.task_outcome import OutcomeReport
from zetta_utils.message_queues import FileQueue, SQSQueue
Expand All @@ -34,6 +34,11 @@ def redirect_buffers() -> None: # Do not need to implement 14 passes for typing
sys.stderr = DummyBuffer() # type: ignore


def worker_init() -> None:
redirect_buffers()
try_load_train_inference()


def run_local_worker(
task_queue_name: str, outcome_queue_name: str, local: bool = True, sleep_sec: float = 0.1
) -> None:
Expand All @@ -60,7 +65,7 @@ def setup_local_worker_pool(
pool = pebble.ProcessPool(
max_workers=num_procs,
context=multiprocessing.get_context("spawn"),
initializer=redirect_buffers,
initializer=worker_init,
)
pool.map(
run_local_worker,
Expand Down

0 comments on commit 8debe89

Please sign in to comment.