-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ENH] turn
--action
into subcommands (#215)
* speed up CLI and pin docker dependencies * add more flake8 * update CLI * split parser and cli * use sub commands * fix doc * fix imports * update linting * fixes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix * fix * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix * fix * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
de73e5b
commit 4f40c49
Showing
26 changed files
with
1,034 additions
and
373 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,15 @@ | ||
[flake8] | ||
max-line-length = 90 | ||
count = True | ||
show-source = True | ||
statistics = True | ||
exclude = | ||
*build | ||
.git | ||
__pycache__ | ||
tests/* | ||
_version.py | ||
versioneer.py | ||
tests_.*.py | ||
version.*.py | ||
setup.py | ||
max-complexity = 10 | ||
ignore = D100, D103, W503 | ||
per-file-ignores = | ||
setup.py:E121 | ||
max-line-length = 90 | ||
max_complexity = 15 | ||
max_function_length = 150 | ||
max_parameters_amount = 15 | ||
max_returns_amount = 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
"""Define the command line interface.""" | ||
|
||
from __future__ import annotations | ||
|
||
import sys | ||
from typing import Any | ||
|
||
from rich_argparse import RichHelpFormatter | ||
|
||
from bidsmreye._parsers import common_parser, download_parser | ||
from bidsmreye.bidsmreye import bidsmreye | ||
from bidsmreye.defaults import default_log_level, log_levels | ||
from bidsmreye.download import download | ||
from bidsmreye.logging import bidsmreye_log | ||
|
||
log = bidsmreye_log(name="bidsmreye") | ||
|
||
|
||
def cli(argv: Any = sys.argv) -> None: | ||
"""Run the bids app. | ||
:param argv: _description_, defaults to sys.argv | ||
:type argv: _type_, optional | ||
""" | ||
parser = common_parser(formatter_class=RichHelpFormatter) | ||
|
||
args = parser.parse_args(argv[1:]) | ||
|
||
log.debug(f"args:\n{args}") | ||
|
||
# TODO integrate as part of base config | ||
# https://stackoverflow.com/a/53293042/14223310 | ||
log_level = log_levels().index(default_log_level()) | ||
# For each "-v" flag, adjust the logging verbosity accordingly | ||
# making sure to clamp off the value from 0 to 4, inclusive of both | ||
for adjustment in args.log_level or (): | ||
log_level = min(len(log_levels()) - 1, max(log_level + adjustment, 0)) | ||
log_level_name = log_levels()[log_level] | ||
|
||
model_weights_file = None | ||
if getattr(args, "model", None) is not None: | ||
model_weights_file = str(getattr(args, "model")) | ||
|
||
bidsmreye( | ||
bids_dir=args.bids_dir[0], | ||
output_dir=args.output_dir[0], | ||
analysis_level=args.analysis_level[0], | ||
action=args.command, | ||
participant_label=args.participant_label or None, | ||
space=args.space or None, | ||
task=args.task or None, | ||
run=args.run or None, | ||
debug=args.debug, | ||
model_weights_file=model_weights_file, | ||
reset_database=args.reset_database, | ||
bids_filter_file=args.bids_filter_file, | ||
non_linear_coreg=bool(getattr(args, "non_linear_coreg", False)), | ||
log_level_name=log_level_name, | ||
) | ||
|
||
|
||
def cli_download(argv: Any = sys.argv) -> None: | ||
"""Download the models from OSF. | ||
:return: _description_ | ||
:rtype: _type_ | ||
""" | ||
parser = download_parser(formatter_class=RichHelpFormatter) | ||
args = parser.parse_args(argv[1:]) | ||
|
||
download(model_name=args.model_name, output_dir=args.output_dir) |
Oops, something went wrong.