Skip to content

Commit

Permalink
setting default values of num_workers to 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Saiyam26 committed Jan 6, 2025
1 parent 14627fb commit df6a8db
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion scalr/data/preprocess/_preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def process_data(self,
full_data: Union[AnnData, AnnCollection],
sample_chunksize: int,
dirpath: str,
num_workers: int = None):
num_workers: int = 1):
"""A function to process the entire data chunkwise and write the processed data
to disk.
Expand Down
5 changes: 3 additions & 2 deletions scalr/feature/feature_subsetting.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self,
mappings: dict,
dirpath: str = None,
device: str = 'cpu',
num_workers: int = None,
num_workers: int = 1,
sample_chunksize: int = None):
"""Initialize required parameters for feature subset training.
Expand All @@ -52,7 +52,8 @@ def __init__(self,
num_workers (int, optional): Number of parallel processes to launch to train multiple
feature subsets simultaneously. Defaults to using single
process.
sample_chunksize (int): Chunks of samples to be loaded in memory at once.
sample_chunksize (int, optional): Chunks of samples to be loaded in memory at once.
Required when `num_workers` > 1.
"""
self.feature_subsetsize = feature_subsetsize
self.chunk_model_config = chunk_model_config
Expand Down
2 changes: 1 addition & 1 deletion scalr/feature_extraction_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def feature_subsetted_model_training(self) -> list[nn.Module]:

self.feature_subsetsize = self.feature_selection_config.get(
'feature_subsetsize', len(self.val_data.var_names))
self.num_workers = self.feature_selection_config.get('num_workers')
self.num_workers = self.feature_selection_config.get('num_workers', 1)

chunk_model_config = self.feature_selection_config.get('model')
chunk_model_train_config = self.feature_selection_config.get(
Expand Down
3 changes: 1 addition & 2 deletions scalr/utils/file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def write_chunkwise_data(full_data: Union[AnnData, AnnCollection],
sample_inds: list[int] = None,
feature_inds: list[int] = None,
transform: callable = None,
num_workers: int = None):
num_workers: int = 1):
"""This function writes data subsets iteratively in a chunkwise manner, to ensure
only at most `sample_chunksize` samples are loaded at a time.
Expand Down Expand Up @@ -152,7 +152,6 @@ def transform_and_write_data(data: AnnData, chunk_number: int):
num_workers)) if num_workers else sample_chunksize

# Execute parallel jobs for transformation and witing of data.
# In case of `num_workers = None`, single process is used.
parallel = Parallel(n_jobs=num_workers)
parallel(
delayed(transform_and_write_data)(
Expand Down

0 comments on commit df6a8db

Please sign in to comment.