From ba38db97b3ede39afea67e14da671388756a6366 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Jan 2024 16:51:21 +0000 Subject: [PATCH 1/4] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.4.0 → v4.5.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.4.0...v4.5.0) - [github.com/psf/black: 23.9.1 → 24.1.1](https://github.com/psf/black/compare/23.9.1...24.1.1) - [github.com/codespell-project/codespell: v2.2.5 → v2.2.6](https://github.com/codespell-project/codespell/compare/v2.2.5...v2.2.6) - [github.com/PyCQA/flake8: 6.1.0 → 7.0.0](https://github.com/PyCQA/flake8/compare/6.1.0...7.0.0) --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7e477d9efa..6ce07231a4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,23 +2,23 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer - id: check-yaml - id: check-added-large-files - repo: https://github.com/psf/black - rev: 23.9.1 + rev: 24.1.1 hooks: - id: black - repo: https://github.com/codespell-project/codespell - rev: v2.2.5 + rev: v2.2.6 hooks: - id: codespell additional_dependencies: - tomli - repo: https://github.com/PyCQA/flake8 - rev: 6.1.0 + rev: 7.0.0 hooks: - id: flake8 From a3a817e3816e6cb79fec0a3a3202af4dd83d4516 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Jan 2024 16:51:44 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- docs/sphinxext/github_link.py | 1 + pydra/__init__.py | 1 + pydra/engine/__init__.py | 1 + pydra/engine/audit.py | 1 + pydra/engine/core.py | 1 + pydra/engine/graph.py | 1 + pydra/engine/helpers.py | 1 + pydra/engine/specs.py | 1 + pydra/engine/state.py | 1 + pydra/engine/submitter.py | 1 + pydra/engine/task.py | 1 + pydra/engine/tests/test_shelltask.py | 2 +- pydra/engine/workers.py | 1 + pydra/mark/functions.py | 1 + pydra/tasks/__init__.py | 1 + pydra/utils/hash.py | 4 ++-- pydra/utils/messenger.py | 9 ++++++--- pydra/utils/profiler.py | 1 + 18 files changed, 24 insertions(+), 6 deletions(-) diff --git a/docs/sphinxext/github_link.py b/docs/sphinxext/github_link.py index 1d19d71b47..b9a5684c20 100644 --- a/docs/sphinxext/github_link.py +++ b/docs/sphinxext/github_link.py @@ -2,6 +2,7 @@ This script comes from scikit-learn: https://github.com/scikit-learn/scikit-learn/blob/master/doc/sphinxext/github_link.py """ + import inspect import os import subprocess diff --git a/pydra/__init__.py b/pydra/__init__.py index 1422e46fd3..f704d670a5 100644 --- a/pydra/__init__.py +++ b/pydra/__init__.py @@ -5,6 +5,7 @@ first-class operations. It forms the core of the Nipype 2.0 ecosystem. """ + # This call enables pydra.tasks to be used as a namespace package when installed # in editable mode. In normal installations it has no effect. __path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/pydra/engine/__init__.py b/pydra/engine/__init__.py index 9f46b7ea37..2eca36ba28 100644 --- a/pydra/engine/__init__.py +++ b/pydra/engine/__init__.py @@ -1,4 +1,5 @@ """The core of the workflow engine.""" + from .submitter import Submitter from .core import Workflow from .task import AuditFlag, ShellCommandTask diff --git a/pydra/engine/audit.py b/pydra/engine/audit.py index 0dca9af18c..7397fad6e6 100644 --- a/pydra/engine/audit.py +++ b/pydra/engine/audit.py @@ -1,4 +1,5 @@ """Module to keep track of provenance information.""" + import os import json import attr diff --git a/pydra/engine/core.py b/pydra/engine/core.py index 67b662741c..1d2734d9ea 100644 --- a/pydra/engine/core.py +++ b/pydra/engine/core.py @@ -1,4 +1,5 @@ """Basic processing graph elements.""" + import abc import json import logging diff --git a/pydra/engine/graph.py b/pydra/engine/graph.py index 7b2724e4eb..30009950cf 100644 --- a/pydra/engine/graph.py +++ b/pydra/engine/graph.py @@ -1,4 +1,5 @@ """Data structure to support :class:`~pydra.engine.core.Workflow` tasks.""" + from copy import copy from pathlib import Path import subprocess as sp diff --git a/pydra/engine/helpers.py b/pydra/engine/helpers.py index c6515b819d..5b411a9a95 100644 --- a/pydra/engine/helpers.py +++ b/pydra/engine/helpers.py @@ -1,4 +1,5 @@ """Administrative support for the engine framework.""" + import asyncio import asyncio.subprocess as asp from pathlib import Path diff --git a/pydra/engine/specs.py b/pydra/engine/specs.py index a8a4a69b79..289eb8d3cd 100644 --- a/pydra/engine/specs.py +++ b/pydra/engine/specs.py @@ -1,4 +1,5 @@ """Task I/O specifications.""" + from pathlib import Path import typing as ty import inspect diff --git a/pydra/engine/state.py b/pydra/engine/state.py index 79e3d5cb34..befbf86b9d 100644 --- a/pydra/engine/state.py +++ b/pydra/engine/state.py @@ -1,4 +1,5 @@ """Keeping track of mapping and reduce operations over tasks.""" + from copy import deepcopy import itertools from functools import reduce diff --git a/pydra/engine/submitter.py b/pydra/engine/submitter.py index e4a2a01023..3906955b2c 100644 --- a/pydra/engine/submitter.py +++ b/pydra/engine/submitter.py @@ -1,4 +1,5 @@ """Handle execution backends.""" + import asyncio import pickle from uuid import uuid4 diff --git a/pydra/engine/task.py b/pydra/engine/task.py index f977a32406..cfe12af3bb 100644 --- a/pydra/engine/task.py +++ b/pydra/engine/task.py @@ -38,6 +38,7 @@ `__ """ + from __future__ import annotations import platform diff --git a/pydra/engine/tests/test_shelltask.py b/pydra/engine/tests/test_shelltask.py index 5129113a09..2221ae6622 100644 --- a/pydra/engine/tests/test_shelltask.py +++ b/pydra/engine/tests/test_shelltask.py @@ -4323,7 +4323,7 @@ def change_name(file): "help_string": "bias field and neck cleanup", }, ), - ) + ), # ("number_classes", int, attr.ib(metadata={"help_string": 'number of tissue-type classes', "argstr": '-n', # "allowed_values": {"min_val": 1, "max_val": 10}})), # ("output_biasfield", bool, diff --git a/pydra/engine/workers.py b/pydra/engine/workers.py index 97be3579ad..155a2800d9 100644 --- a/pydra/engine/workers.py +++ b/pydra/engine/workers.py @@ -1,4 +1,5 @@ """Execution workers.""" + import asyncio import sys import json diff --git a/pydra/mark/functions.py b/pydra/mark/functions.py index 6830b3b34c..e191a61809 100644 --- a/pydra/mark/functions.py +++ b/pydra/mark/functions.py @@ -1,4 +1,5 @@ """ Decorators to apply to functions used in Pydra workflows """ + from functools import wraps diff --git a/pydra/tasks/__init__.py b/pydra/tasks/__init__.py index 0da1a3b130..fae53c2d92 100644 --- a/pydra/tasks/__init__.py +++ b/pydra/tasks/__init__.py @@ -5,6 +5,7 @@ To create a task package, please fork the `pydra-tasks-template `__. """ + # This call enables pydra.tasks to be used as a namespace package when installed # in editable mode. In normal installations it has no effect. __path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/pydra/utils/hash.py b/pydra/utils/hash.py index 8e628527f5..494c536711 100644 --- a/pydra/utils/hash.py +++ b/pydra/utils/hash.py @@ -1,4 +1,5 @@ """Generic object hashing dispatch""" + import os # import stat @@ -98,8 +99,7 @@ def hash_single(obj: object, cache: Cache) -> Hash: @runtime_checkable class HasBytesRepr(Protocol): - def __bytes_repr__(self, cache: Cache) -> Iterator[bytes]: - ... # pragma: no cover + def __bytes_repr__(self, cache: Cache) -> Iterator[bytes]: ... # pragma: no cover @singledispatch diff --git a/pydra/utils/messenger.py b/pydra/utils/messenger.py index 40e1000672..fc70e345f8 100644 --- a/pydra/utils/messenger.py +++ b/pydra/utils/messenger.py @@ -1,4 +1,5 @@ """Messaging of states.""" + import abc import datetime as dt import enum @@ -129,9 +130,11 @@ def send(self, message, **kwargs): r = requests.post( kwargs["post_url"], json=message, - auth=kwargs["auth"]() - if getattr(kwargs["auth"], "__call__", None) - else kwargs["auth"], + auth=( + kwargs["auth"]() + if getattr(kwargs["auth"], "__call__", None) + else kwargs["auth"] + ), ) return r.status_code diff --git a/pydra/utils/profiler.py b/pydra/utils/profiler.py index 7b09887977..f531345c98 100644 --- a/pydra/utils/profiler.py +++ b/pydra/utils/profiler.py @@ -1,4 +1,5 @@ """Utilities to keep track of performance and resource utilization.""" + from pathlib import Path import psutil import threading From 591c23cad2b873814cfe9675d69e462d2a92931b Mon Sep 17 00:00:00 2001 From: Ghislain Vaillant Date: Fri, 2 Feb 2024 09:27:03 +0100 Subject: [PATCH 3/4] MAINT: Fix flake8 errors --- pydra/utils/hash.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pydra/utils/hash.py b/pydra/utils/hash.py index 494c536711..0c5f5f8705 100644 --- a/pydra/utils/hash.py +++ b/pydra/utils/hash.py @@ -99,7 +99,8 @@ def hash_single(obj: object, cache: Cache) -> Hash: @runtime_checkable class HasBytesRepr(Protocol): - def __bytes_repr__(self, cache: Cache) -> Iterator[bytes]: ... # pragma: no cover + def __bytes_repr__(self, cache: Cache) -> Iterator[bytes]: + pass # pragma: no cover @singledispatch From 6cbeace688b7a54e6ad4b427255826da98fe0ef6 Mon Sep 17 00:00:00 2001 From: Ghislain Vaillant Date: Fri, 2 Feb 2024 09:31:06 +0100 Subject: [PATCH 4/4] MAINT: Fix codespell errors --- docs/changes.rst | 2 +- pydra/engine/core.py | 6 +++--- pydra/engine/environments.py | 2 +- pydra/engine/graph.py | 2 +- pydra/engine/tests/test_shelltask.py | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/changes.rst b/docs/changes.rst index 0fb4187e33..4e23840e90 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -9,7 +9,7 @@ Release Notes * adding simple validators to input spec (using ``attr.validator``) * adding ``create_dotfile`` for workflows, that creates graphs as dotfiles (can convert to other formats if dot available) * adding a simple user guide with ``input_spec`` description -* expanding docstrings for ``State``, ``audit`` and ``messanger`` +* expanding docstrings for ``State``, ``audit`` and ``messenger`` * updating syntax to newer python 0.7.0 diff --git a/pydra/engine/core.py b/pydra/engine/core.py index 1d2734d9ea..82400a1beb 100644 --- a/pydra/engine/core.py +++ b/pydra/engine/core.py @@ -60,7 +60,7 @@ class TaskBase: """ A base structure for the nodes in the processing graph. - Tasks are a generic compute step from which both elemntary tasks and + Tasks are a generic compute step from which both elementary tasks and :class:`Workflow` instances inherit. """ @@ -546,7 +546,7 @@ def _run(self, rerun=False, environment=None, **kwargs): self.hooks.post_run_task(self, result) self.audit.finalize_audit(result) save(output_dir, result=result, task=self) - # removing the additional file with the chcksum + # removing the additional file with the checksum (self.cache_dir / f"{self.uid}_info.json").unlink() # # function etc. shouldn't change anyway, so removing orig_inputs = { @@ -1252,7 +1252,7 @@ async def _run(self, submitter=None, rerun=False, **kwargs): self.hooks.post_run_task(self, result) self.audit.finalize_audit(result=result) save(output_dir, result=result, task=self) - # removing the additional file with the chcksum + # removing the additional file with the checksum (self.cache_dir / f"{self.uid}_info.json").unlink() os.chdir(cwd) self.hooks.post_run(self, result) diff --git a/pydra/engine/environments.py b/pydra/engine/environments.py index 3c60927bc5..0c57008058 100644 --- a/pydra/engine/environments.py +++ b/pydra/engine/environments.py @@ -6,7 +6,7 @@ class Environment: """ Base class for environments that are used to execute tasks. - Right now it is asssumed that the environment, including container images, + Right now it is assumed that the environment, including container images, are available and are not removed at the end TODO: add setup and teardown methods """ diff --git a/pydra/engine/graph.py b/pydra/engine/graph.py index 30009950cf..bfa62e0764 100644 --- a/pydra/engine/graph.py +++ b/pydra/engine/graph.py @@ -499,7 +499,7 @@ def _create_dotfile_single_graph(self, nodes, edges): return dotstr def export_graph(self, dotfile, ext="png"): - """exporting dotfile to other format, equires the dot command""" + """exporting dotfile to other formats requires the dot command""" available_ext = [ "bmp", "canon", diff --git a/pydra/engine/tests/test_shelltask.py b/pydra/engine/tests/test_shelltask.py index 2221ae6622..a13bbc52c8 100644 --- a/pydra/engine/tests/test_shelltask.py +++ b/pydra/engine/tests/test_shelltask.py @@ -4815,7 +4815,7 @@ def formatter_3(in1, in3): == str(excinfo.value) ) - # chcking if field value is accessible when None + # checking if field value is accessible when None def formatter_5(field): assert field == "-t test" # formatter must return a string @@ -4832,7 +4832,7 @@ def formatter_5(field): ) assert shelly.cmdline == "exec -t test" - # chcking if field value is accessible when None + # checking if field value is accessible when None def formatter_4(field): assert field is None # formatter must return a string