Commit e6780504 authored by Lukas Jarosch's avatar Lukas Jarosch
Browse files

Add default shard number

parent 77860bb7
...@@ -11,6 +11,7 @@ import json ...@@ -11,6 +11,7 @@ import json
from collections import defaultdict from collections import defaultdict
from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor, as_completed from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor, as_completed
from math import ceil from math import ceil
from multiprocessing import cpu_count
from pathlib import Path from pathlib import Path
from tqdm import tqdm from tqdm import tqdm
...@@ -132,6 +133,13 @@ def main(args): ...@@ -132,6 +133,13 @@ def main(args):
output_db_name = args.output_db_name output_db_name = args.output_db_name
n_shards = args.n_shards n_shards = args.n_shards
n_cpus = cpu_count()
if n_shards > n_cpus:
print(
f"Warning: Your number of shards ({n_shards}) is greater than the number of cores on your machine ({n_cpus}). "
"This may result in slower performance. Consider using a smaller number of shards."
)
# get all chain dirs in alignment_dir # get all chain dirs in alignment_dir
print("Getting chain directories...") print("Getting chain directories...")
all_chain_dirs = sorted([f for f in tqdm(alignment_dir.iterdir())]) all_chain_dirs = sorted([f for f in tqdm(alignment_dir.iterdir())])
...@@ -189,7 +197,10 @@ if __name__ == "__main__": ...@@ -189,7 +197,10 @@ if __name__ == "__main__":
parser.add_argument("output_db_path", type=Path) parser.add_argument("output_db_path", type=Path)
parser.add_argument("output_db_name", type=str) parser.add_argument("output_db_name", type=str)
parser.add_argument( parser.add_argument(
"n_shards", type=int, help="Number of shards to split the database into" "--n_shards",
type=int,
help="Number of shards to split the database into",
default=10,
) )
args = parser.parse_args() args = parser.parse_args()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment