-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
54 additions
and
121 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
src/modalities/dataloader/preprocessing/queued_processing/process_controller.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import multiprocessing as mp | ||
from dataclasses import dataclass | ||
from typing import Callable | ||
|
||
from modalities.dataloader.preprocessing.queued_processing.queued_processing import Processor | ||
from modalities.utils.logging import get_logger | ||
|
||
|
||
@dataclass | ||
class PipelineStep: | ||
name: str | ||
input_queue: mp.Queue | ||
processors: list[Processor] | ||
|
||
|
||
class ProcessController: | ||
def __init__(self, pipeline_steps: list[PipelineStep], populate_jobs: Callable): | ||
"""Initializes the ProcessController | ||
Each pipeline step contains a list of processors that retrieve the data from the input queue, | ||
process it and if necessary put it into the output queue of the next step. | ||
""" | ||
self._pipeline_steps = pipeline_steps | ||
self._populate_jobs = populate_jobs | ||
|
||
def run(self): | ||
# add the jobs to the input queues | ||
get_logger().info("Populating jobs") | ||
self._populate_jobs() | ||
|
||
# start the processors | ||
for step in self._pipeline_steps: | ||
get_logger().info(f"Starting processors for step {step.name}") | ||
for processor in step.processors: | ||
processor.start() | ||
|
||
# wait for the processors to finish | ||
for step in self._pipeline_steps: | ||
for _ in step.processors: | ||
step.input_queue.put(None) | ||
get_logger().info(f"Waiting for processors in step {step.name} to finish") | ||
|
||
for processor in step.processors: | ||
processor.join() |
113 changes: 0 additions & 113 deletions
113
src/modalities/dataloader/preprocessing/tokenization/create_packed_data.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters