diff --git a/.gitignore b/.gitignore index 5a226a96..47d4337a 100644 --- a/.gitignore +++ b/.gitignore @@ -51,4 +51,4 @@ MANIFEST # Singularity Images **/*.simg -**/*.sif \ No newline at end of file +**/*.sif diff --git a/README.rst b/README.rst index 0ac6dc98..d6ab09a8 100644 --- a/README.rst +++ b/README.rst @@ -42,30 +42,30 @@ Usage [--tag TAG] [--working_dir PATH] [-v] [-vv] {run,utils,version,group,gradients,tsconcat,pull,upgrade,enter,bash,shell,parse-resources,parse_resources,crash} ... - - cpac: a Python package that simplifies using C-PAC containerized images. - + + cpac: a Python package that simplifies using C-PAC containerized images. + This commandline interface package is designed to minimize repetition. As such, nearly all arguments are optional. - - When launching a container, this package will try to bind any paths mentioned in + + When launching a container, this package will try to bind any paths mentioned in • the command • the data configuration - + An example minimal run command: cpac run /path/to/data /path/for/outputs - + An example run command with optional arguments: cpac -B /path/to/data/configs:/configs \ --image fcpindi/c-pac --tag latest \ run /path/to/data /path/for/outputs \ --data_config_file /configs/data_config.yml \ --save_working_dir - + Each command can take "--help" to provide additonal usage information, e.g., - + cpac run --help - + Known issues: - Some Docker containers unexpectedly persist after cpac finishes. To clear them, run 1. `docker ps` to list the containers @@ -73,7 +73,7 @@ Usage 2. `docker attach ` 3. `exit` - https://github.com/FCP-INDI/cpac/issues - + positional arguments: {run,utils,version,group,gradients,tsconcat,pull,upgrade,enter,bash,shell,parse-resources,parse_resources,crash} run Run C-PAC. See @@ -87,7 +87,7 @@ Usage "cpac [--platform {docker,apptainer,singularity}] [--image IMAGE] [--tag TAG] group --help" for more information. gradients Run ba_timeseries_gradients. See - "cpac [--platform "{docker,singularity}] gradients --help" + "cpac [--platform "{docker,singularity}] gradients --help" for more information. tsconcat Run ba-tsconcat (<0.2.0,>=0.1.2) pull (upgrade) Upgrade your local C-PAC version to the latest version @@ -98,7 +98,7 @@ Usage Enter a new C-PAC container via BASH. parse-resources (parse_resources) . - + When provided with a `callback.log` file, this utility can sort through the memory `runtime` usage, `estimate`, and associated `efficiency`, to identify the `n` tasks with the `highest` or `lowest` of each of these @@ -106,13 +106,13 @@ Usage "parse-resources" is intended to be run outside a C-PAC container. See "cpac parse-resources --help" for more information. crash Convert a crash pickle to plain text (C-PAC < 1.8.0). - + options: -h, --help show this help message and exit --version show program's version number and exit -o OPT, --container_option OPT, --container_options OPT parameters and flags to pass through to Docker or Singularity - + This flag can take multiple arguments so cannot be the final argument before the command argument (i.e., run or any other command that does not start with - or --) @@ -123,7 +123,7 @@ Usage real_path:container_path (eg, /home/C-PAC/run5/outputs:/outputs). Use absolute paths for both paths. - + This flag can take multiple arguments so cannot be the final argument before the command argument (i.e., run or any other command that does not start with - or --) @@ -134,7 +134,7 @@ Usage --image IMAGE path to Apptainer/Singularity image file OR name of Docker image (eg, "fcpindi/c-pac"). Will attempt to pull from Singularity Hub or Docker Hub if not provided. If image is specified but platform is not, platform is - assumed to be Apptainer/Singularity if image is a path or + assumed to be Apptainer/Singularity if image is a path or Docker if image is an image name. --tag TAG tag of the Docker image to use (eg, "latest" or "nightly"). --working_dir PATH working directory diff --git a/src/cpac/__init__.py b/src/cpac/__init__.py index bf8bc36a..99fe3059 100644 --- a/src/cpac/__init__.py +++ b/src/cpac/__init__.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- """Init file for cpac.""" + from importlib.metadata import distribution, PackageNotFoundError DIST_NAME = __name__ diff --git a/src/cpac/backends/apptainer/__init__.py b/src/cpac/backends/apptainer/__init__.py index 842f7d67..82d99673 100644 --- a/src/cpac/backends/apptainer/__init__.py +++ b/src/cpac/backends/apptainer/__init__.py @@ -1,4 +1,5 @@ """Backend for Apptainer images.""" + from .apptainer import Apptainer __all__ = ["Apptainer"] diff --git a/src/cpac/backends/apptainer/apptainer.py b/src/cpac/backends/apptainer/apptainer.py index de48da15..1a874f19 100644 --- a/src/cpac/backends/apptainer/apptainer.py +++ b/src/cpac/backends/apptainer/apptainer.py @@ -1,4 +1,5 @@ """Backend for Apptainer images.""" + from spython import main as spython_main from spython.main.base import command diff --git a/src/cpac/backends/apptainer/spython.py b/src/cpac/backends/apptainer/spython.py index b34674e6..5e841f32 100644 --- a/src/cpac/backends/apptainer/spython.py +++ b/src/cpac/backends/apptainer/spython.py @@ -2,6 +2,7 @@ # Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed # with this file, You can obtain one at http://mozilla.org/MPL/2.0/. """Modifications to ``spython`` run Apptainer instead of Singularity.""" + from spython.main import get_client as get_spython_client diff --git a/src/cpac/helpers/__init__.py b/src/cpac/helpers/__init__.py index 86c55c03..ab343c9c 100644 --- a/src/cpac/helpers/__init__.py +++ b/src/cpac/helpers/__init__.py @@ -1,4 +1,5 @@ """Hepler functions for cpac Python package.""" + from itertools import chain import re diff --git a/src/cpac/helpers/cpac_parse_resources.py b/src/cpac/helpers/cpac_parse_resources.py index a4e562a5..3c1ba58d 100755 --- a/src/cpac/helpers/cpac_parse_resources.py +++ b/src/cpac/helpers/cpac_parse_resources.py @@ -7,6 +7,7 @@ categories. `cpac_parse_resources` is intended to be run outside a C-PAC container. """ + from argparse import ArgumentParser import configparser import json diff --git a/src/cpac/utils/checks.py b/src/cpac/utils/checks.py index 3a49441a..6c5c7a5e 100644 --- a/src/cpac/utils/checks.py +++ b/src/cpac/utils/checks.py @@ -1,4 +1,5 @@ """Functions to check things like the in-container C-PAC version.""" + from packaging.version import Version from semver import VersionInfo diff --git a/tests/.pylintrc b/tests/.pylintrc index 1396bdcb..cfd62021 100644 --- a/tests/.pylintrc +++ b/tests/.pylintrc @@ -1,2 +1,2 @@ [MAIN] -ignore-imports=y \ No newline at end of file +ignore-imports=y diff --git a/tests/conftest.py b/tests/conftest.py index ef4d02f4..bdbc0754 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -5,6 +5,7 @@ Read more about conftest.py under: https://pytest.org/latest/plugins.html """ + import logging import pytest # pylint: disable=import-error diff --git a/tests/test_cpac.py b/tests/test_cpac.py index 019a3b8b..40d8bb6c 100644 --- a/tests/test_cpac.py +++ b/tests/test_cpac.py @@ -1,4 +1,5 @@ """Tests for top-level cpac cli.""" + from contextlib import redirect_stderr, redirect_stdout from io import BytesIO, StringIO, TextIOWrapper import sys diff --git a/tests/test_cpac_gradients.py b/tests/test_cpac_gradients.py index 1e47a3be..3ad8052d 100644 --- a/tests/test_cpac_gradients.py +++ b/tests/test_cpac_gradients.py @@ -1,4 +1,5 @@ """Unit tests for the command-line interface module of ``ba-timeseries-gradients``.""" + from argparse import Namespace import logging from pathlib import Path diff --git a/tests/test_cpac_run.py b/tests/test_cpac_run.py index 8dca5a98..e71cab9f 100644 --- a/tests/test_cpac_run.py +++ b/tests/test_cpac_run.py @@ -1,4 +1,5 @@ """Test actually running C-PAC with cpac.""" + from datetime import date, timedelta import os from pathlib import Path diff --git a/tests/test_wrapped.py b/tests/test_wrapped.py index dde7c910..2740581c 100644 --- a/tests/test_wrapped.py +++ b/tests/test_wrapped.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- """Test bare-wrapped commands.""" + from subprocess import call from pytest import mark, skip