Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
panacota
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Amandine PERRIN
panacota
Commits
6e93f85f
Commit
6e93f85f
authored
4 years ago
by
Amandine PERRIN
Browse files
Options
Downloads
Patches
Plain Diff
Use utils argparse checking instead of a local one
parent
f6510f0d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
PanACoTA/subcommands/align.py
+2
-20
2 additions, 20 deletions
PanACoTA/subcommands/align.py
with
2 additions
and
20 deletions
PanACoTA/subcommands/align.py
+
2
−
20
View file @
6e93f85f
...
@@ -157,25 +157,7 @@ def build_parser(parser):
...
@@ -157,25 +157,7 @@ def build_parser(parser):
"""
"""
import
argparse
import
argparse
import
multiprocessing
import
multiprocessing
from
PanACoTA
import
utils_argparse
def
thread_num
(
param
):
try
:
param
=
int
(
param
)
except
Exception
:
msg
=
"
argument --threads threads: invalid int value: {}
"
.
format
(
param
)
raise
argparse
.
ArgumentTypeError
(
msg
)
nb_cpu
=
multiprocessing
.
cpu_count
()
if
param
>
nb_cpu
:
msg
=
(
"
You have {} threads on your computer, you cannot ask for more:
"
"
invalid value: {}
"
).
format
(
nb_cpu
,
param
)
raise
argparse
.
ArgumentTypeError
(
msg
)
elif
param
<
0
:
msg
=
(
"
Please provide a positive number of threads (or 0 for all threads):
"
"
Invalid value: {}
"
).
format
(
param
)
raise
argparse
.
ArgumentTypeError
(
msg
)
elif
param
==
0
:
return
nb_cpu
return
param
# Create command-line parser for all options and arguments to give
# Create command-line parser for all options and arguments to give
required
=
parser
.
add_argument_group
(
'
Required arguments
'
)
required
=
parser
.
add_argument_group
(
'
Required arguments
'
)
...
@@ -200,7 +182,7 @@ def build_parser(parser):
...
@@ -200,7 +182,7 @@ def build_parser(parser):
help
=
"
Output directory, where all results must be saved
"
)
help
=
"
Output directory, where all results must be saved
"
)
optional
=
parser
.
add_argument_group
(
'
Optional arguments
'
)
optional
=
parser
.
add_argument_group
(
'
Optional arguments
'
)
optional
.
add_argument
(
"
--threads
"
,
dest
=
"
threads
"
,
default
=
1
,
type
=
thread_num
,
optional
.
add_argument
(
"
--threads
"
,
dest
=
"
threads
"
,
default
=
1
,
type
=
utils_argparse
.
thread_num
,
help
=
(
"
add this option if you want to parallelize on several threads.
"
help
=
(
"
add this option if you want to parallelize on several threads.
"
"
Indicate on how many threads you want to parallelize.
"
"
Indicate on how many threads you want to parallelize.
"
"
By default, it uses 1 thread. Put 0 if you want to use
"
"
By default, it uses 1 thread. Put 0 if you want to use
"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment