Skip to content
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
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ fail_fast: false

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.4
rev: v0.16.1
hooks:
- id: ruff
args: [--fix]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.17.0
rev: v2.3.0
hooks:
- id: mypy
additional_dependencies:
Expand All @@ -25,7 +25,7 @@ repos:
- types-PyYAML
args: [--python-version=3.10, --ignore-missing-imports]
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.15.0
rev: v2.16.0
hooks:
- id: pretty-format-yaml
args:
Expand All @@ -39,7 +39,7 @@ repos:
- --no-sort

- repo: https://github.com/python-poetry/poetry
rev: 2.1.3
rev: 2.4.1
hooks:
- id: poetry-check
- id: poetry-lock
Expand All @@ -59,7 +59,7 @@ repos:
always_run: true

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
- id: check-case-conflict
- id: end-of-file-fixer
Expand Down
1 change: 0 additions & 1 deletion src/cpac/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""Init file for cpac."""

from importlib.metadata import distribution, PackageNotFoundError
Expand Down
10 changes: 3 additions & 7 deletions src/cpac/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Main module for cpac package."""

import argparse
Expand Down Expand Up @@ -82,10 +81,10 @@ def _parser():
parser.add_argument(
"--version",
action="version",
version="cpac (convenience wrapper) version {ver}\nFor C-PAC version, "
version=f"cpac (convenience wrapper) version {__version__}\nFor C-PAC version, "
"run `cpac version` with any cpac options (e.g., "
"`--platform`, `--image`, `--tag`) that you would use "
"while running".format(ver=__version__),
"while running",
)

parser.add_argument(
Expand Down Expand Up @@ -475,10 +474,7 @@ def run():
for i, arg in enumerate(args.copy()):
if i == command_index:
option_value_setting = False
if arg in options:
reordered_args.append(args.pop(args.index(arg)))
option_value_setting = True
elif any(arg.startswith(f"{option}=") for option in options):
if arg in options or any(arg.startswith(f"{option}=") for option in options):
reordered_args.append(args.pop(args.index(arg)))
option_value_setting = True
elif option_value_setting:
Expand Down
12 changes: 7 additions & 5 deletions src/cpac/backends/container_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def __init__(self, **kwargs):
tracking_path = get_or_create_config(udir)
self.volumes += Volume(tracking_path)
else:
raise EnvironmentError(
raise OSError(
"Unable to create tracking "
"configuration. Please run with "
"--tracking_opt-out and C-PAC >= "
Expand Down Expand Up @@ -354,9 +354,11 @@ def _load_logging(self):
textwrap.indent(
tabulate(
table.applymap(
lambda x: ("\n".join(textwrap.wrap(x, 42)))
if isinstance(x, str)
else x
lambda x: (
("\n".join(textwrap.wrap(x, 42)))
if isinstance(x, str)
else x
)
),
headers="keys",
showindex=False,
Expand Down Expand Up @@ -460,7 +462,7 @@ def _set_bindings(self, **kwargs):
self._bind_volume(Volume(bind_parts[0]))
else:
raise SyntaxError(
"I don't know what to do with custom binding {}".format(d)
f"I don't know what to do with custom binding {d}"
)
for d in ["bids_dir", "output_dir"]: # pylint: disable=invalid-name
if d in kwargs and isinstance(kwargs[d], str) and os.path.exists(kwargs[d]):
Expand Down
2 changes: 1 addition & 1 deletion src/cpac/backends/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def __init__(self, container):
self.container = container
[
print(l.decode("utf-8"), end="")
for l in self.container.attach( # noqa: E741
for l in self.container.attach(
logs=True, stderr=True, stdout=True, stream=True
)
]
Expand Down
6 changes: 3 additions & 3 deletions src/cpac/helpers/cpac_parse_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ def display(df):
tmp += [d["id"]]
tmp += [d[runti]]
tmp += [d[estim]]
tmp += ["{0:.2f} %".format(100 * d[runti] * 1.0 / d[estim])]
tmp += [f"{100 * d[runti] * 1.0 / d[estim]:.2f} %"]

tmp = ["{0:.4f}".format(t) if isinstance(t, float) else str(t) for t in tmp]
tmp = [f"{t:.4f}" if isinstance(t, float) else str(t) for t in tmp]
table.add_row(*tmp)
del tmp

Expand All @@ -67,7 +67,7 @@ def get_or_create_config(udir):
def load_runtime_stats(callback):
"""Load stats from a callback log."""
with open(callback) as fhandle:
logs = [json.loads(log) for log in fhandle.readlines()]
logs = [json.loads(log) for log in fhandle]

pruned_logs = []
for log in logs:
Expand Down
4 changes: 1 addition & 3 deletions src/cpac/utils/bare_wrap.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Wrap another Python package without any modifications."""

from argparse import _SubParsersAction, ArgumentParser, HelpFormatter, REMAINDER
Expand Down Expand Up @@ -193,7 +192,6 @@ class WrappedHelpFormatter(HelpFormatter):

def add_arguments(self, actions):
"""Don't add arguments."""
pass


def add_bare_wrapper(parser: _SubParsersAction, command: str) -> None:
Expand Down Expand Up @@ -238,7 +236,7 @@ def call(name: str, command: list) -> None:
raise KeyError(f"Package {name} not defined in dependencies") from ke
marker = getattr(package_info, "marker", None)
if marker and marker.evaluate({"extra": name}) is False:
raise EnvironmentError(
raise OSError(
f"Current environment does not meet requirements ({marker}) for package {name}"
)
try:
Expand Down
1 change: 0 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""conftest.py for cpac.

Read more about conftest.py under:
Expand Down
1 change: 0 additions & 1 deletion tests/test_wrapped.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Test bare-wrapped commands."""

from subprocess import call
Expand Down
Loading