Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no oversubscription #148

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions genomad/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import multiprocessing
import os
import sys
from pathlib import Path

@@ -247,6 +247,15 @@
}


def get_available_cpus():
try:
# Try to get the number of cores available to this process
CPUS = len(os.sched_getaffinity(0))
except AttributeError:
# Windows / MacOS probably don't have this functionality
CPUS = os.cpu_count()
return CPUS

def use_preset(ctx, param, value):
if value is not None and any(
ctx.get_parameter_source(i).name == "COMMANDLINE"
@@ -378,7 +387,7 @@ def download_database(destination, keep, verbose):
"--threads",
"-t",
type=int,
default=multiprocessing.cpu_count(),
default=get_available_cpus(),
show_default=True,
help="Number of threads to use.",
)
@@ -513,7 +522,7 @@ def annotate(
"--threads",
"-t",
type=int,
default=multiprocessing.cpu_count(),
default=get_available_cpus(),
show_default=True,
help="Number of threads to use.",
)
@@ -687,7 +696,7 @@ def find_proviruses(
"--threads",
"-t",
type=int,
default=multiprocessing.cpu_count(),
default=get_available_cpus(),
show_default=True,
help="Number of threads to use.",
)
@@ -726,7 +735,7 @@ def marker_classification(input, output, database, restart, threads, verbose):
"--threads",
"-t",
type=int,
default=multiprocessing.cpu_count(),
default=get_available_cpus(),
show_default=True,
help="Number of threads to use.",
)
@@ -1026,7 +1035,7 @@ def summary(
"--threads",
"-t",
type=int,
default=multiprocessing.cpu_count(),
default=get_available_cpus(),
show_default=True,
help="Number of threads to use.",
)