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

change default value of --process to (number of CPUs)-1 #4104

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ v33.0.0 (next next, roadmap)
license detection and reduce false positives.
See https://github.com/nexB/scancode-toolkit/issues/3300

- default value for `--processes` was previously 1. It was changed
to (number of CPUs)-1.
See https://github.com/aboutcode-org/scancode-toolkit/issues/2980

- File categorization support added, a post scan plugin tagging
files with priority levels for review, and also take advantage
of these in other summary plugins.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/cli-reference/help-text-options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ The Following Help Text is displayed, i.e. This is the help text for Scancode Ve
seconds. [default: 120 seconds]
-n, --processes INT Set the number of parallel processes to use. Disable
parallel processing if 0. Also disable threading if
-1. [default: 1]
-1. [default: (number of CPUs)-1]
-q, --quiet Do not print summary or progress.
-v, --verbose Print progress as file-by-file path instead of a
progress bar. Print verbose scan counters.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/rst_snippets/core_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ All "Core" Scan Options
-----------------------

-n, --processes INTEGER Scan ``<input>`` using n parallel processes.
[Default: 1]
[Default: (number of CPUs)-1]

-v, --verbose Print verbose file-by-file progress messages.

Expand Down
11 changes: 9 additions & 2 deletions src/scancode/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,13 @@ def validate_input_path(ctx, param, value):

return value

def default_processes():
""" return number that is used as a default value for --processes """
cpu_count = os.cpu_count()
if cpu_count > 1:
return cpu_count-1
else:
return 1

@click.command(name='scancode',
epilog=epilog_text,
Expand Down Expand Up @@ -230,10 +237,10 @@ def validate_input_path(ctx, param, value):

@click.option('-n', '--processes',
type=int,
default=1,
default=default_processes(),
metavar='INT',
help='Set the number of parallel processes to use. '
'Disable parallel processing if 0. Also disable threading if -1. [default: 1]',
'Disable parallel processing if 0. Also disable threading if -1. [default: (number of CPUs)-1]',
help_group=cliutils.CORE_GROUP, sort_order=10, cls=PluggableCommandLineOption)

@click.option('--timeout',
Expand Down
2 changes: 1 addition & 1 deletion tests/scancode/data/help/help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ Options:
seconds. [default: 120 seconds]
-n, --processes INT Set the number of parallel processes to use. Disable
parallel processing if 0. Also disable threading if
-1. [default: 1]
-1. [default: (number of CPUs)-1]
-q, --quiet Do not print summary or progress.
-v, --verbose Print progress as file-by-file path instead of a
progress bar. Print verbose scan counters.
Expand Down
2 changes: 1 addition & 1 deletion tests/scancode/data/help/help_linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ Options:
seconds. [default: 120 seconds]
-n, --processes INT Set the number of parallel processes to use. Disable
parallel processing if 0. Also disable threading if
-1. [default: 1]
-1. [default: (number of CPUs)-1]
-q, --quiet Do not print summary or progress.
-v, --verbose Print progress as file-by-file path instead of a
progress bar. Print verbose scan counters.
Expand Down
Loading