Skip to content

Commit

Permalink
Fixed pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
spirosmaggioros committed Oct 9, 2024
1 parent 738bf31 commit 0820179
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
10 changes: 6 additions & 4 deletions NiChart_DLMUSE/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand All @@ -130,5 +131,6 @@ def main() -> None:

# run_pipeline(in_data, out_dir, device)


if __name__ == "__main__":
main()
9 changes: 5 additions & 4 deletions NiChart_DLMUSE/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand Down

0 comments on commit 0820179

Please sign in to comment.