diff --git a/NiChart_DLMUSE/__main__.py b/NiChart_DLMUSE/__main__.py index 3243c01..a92c551 100644 --- a/NiChart_DLMUSE/__main__.py +++ b/NiChart_DLMUSE/__main__.py @@ -7,11 +7,10 @@ import argparse import os -import multiprocessing import threading from .dlmuse_pipeline import run_pipeline -from .utils import split_data, remove_subfolders +from .utils import remove_subfolders, split_data # VERSION = pkg_resources.require("NiChart_DLMUSE")[0].version VERSION = 1.0 @@ -113,13 +112,15 @@ def main() -> None: os.system("DLMUSE --clear_cache") # Run pipeline - no_threads = 4 # for now + no_threads = 4 # for now subfolders = split_data(in_data, no_threads) threads = [] for i in range(len(subfolders)): curr_out_dir = out_dir + f"split_{i}" - curr_thread = threading.Thread(target=run_pipeline, args=(subfolders[i], curr_out_dir, device)) + curr_thread = threading.Thread( + target=run_pipeline, args=(subfolders[i], curr_out_dir, device) + ) curr_thread.start() threads.append(curr_thread) @@ -130,5 +131,6 @@ def main() -> None: # run_pipeline(in_data, out_dir, device) + if __name__ == "__main__": main() diff --git a/NiChart_DLMUSE/utils.py b/NiChart_DLMUSE/utils.py index 6c07906..550ffcc 100644 --- a/NiChart_DLMUSE/utils.py +++ b/NiChart_DLMUSE/utils.py @@ -127,9 +127,10 @@ def make_img_list(in_data: str) -> pd.DataFrame: # Return out dataframe return df_out + def dir_size(in_dir: str) -> int: """ - Returns the number of images the user passed + Returns the number of images the user passed """ size = 0 for path in os.listdir(in_dir): @@ -141,12 +142,12 @@ def dir_size(in_dir: str) -> int: def split_data(in_dir: str, N: int) -> list: """ - Splits the input data directory into subfolders of size N + Splits the input data directory into subfolders of size N """ - assert(N > 0) + assert N > 0 data_size = dir_size(in_dir) no_files_in_folders = data_size / N if (data_size % N == 0) else (data_size / N) + 1 - assert(no_files_in_folders > 0) + assert no_files_in_folders > 0 subfolders = [] current_folder = 1