Skip to content

Commit

Permalink
Merge pull request #712 from nipype/pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
pre-commit updates and code fixes
  • Loading branch information
ghisvail authored Feb 2, 2024
2 parents 95f94d5 + 6cbeace commit 69f27ad
Show file tree
Hide file tree
Showing 21 changed files with 36 additions and 17 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/sphinxext/github_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pydra/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
1 change: 1 addition & 0 deletions pydra/engine/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The core of the workflow engine."""

from .submitter import Submitter
from .core import Workflow
from .task import AuditFlag, ShellCommandTask
Expand Down
1 change: 1 addition & 0 deletions pydra/engine/audit.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module to keep track of provenance information."""

import os
import json
import attr
Expand Down
7 changes: 4 additions & 3 deletions pydra/engine/core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Basic processing graph elements."""

import abc
import json
import logging
Expand Down Expand Up @@ -59,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.
"""
Expand Down Expand Up @@ -545,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 = {
Expand Down Expand Up @@ -1251,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)
Expand Down
2 changes: 1 addition & 1 deletion pydra/engine/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand Down
3 changes: 2 additions & 1 deletion pydra/engine/graph.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -498,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",
Expand Down
1 change: 1 addition & 0 deletions pydra/engine/helpers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Administrative support for the engine framework."""

import asyncio
import asyncio.subprocess as asp
from pathlib import Path
Expand Down
1 change: 1 addition & 0 deletions pydra/engine/specs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Task I/O specifications."""

from pathlib import Path
import typing as ty
import inspect
Expand Down
1 change: 1 addition & 0 deletions pydra/engine/state.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Keeping track of mapping and reduce operations over tasks."""

from copy import deepcopy
import itertools
from functools import reduce
Expand Down
1 change: 1 addition & 0 deletions pydra/engine/submitter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Handle execution backends."""

import asyncio
import pickle
from uuid import uuid4
Expand Down
1 change: 1 addition & 0 deletions pydra/engine/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<https://colab.research.google.com/drive/1RRV1gHbGJs49qQB1q1d5tQEycVRtuhw6>`__
"""

from __future__ import annotations

import platform
Expand Down
6 changes: 3 additions & 3 deletions pydra/engine/tests/test_shelltask.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions pydra/engine/workers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Execution workers."""

import asyncio
import sys
import json
Expand Down
1 change: 1 addition & 0 deletions pydra/mark/functions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
""" Decorators to apply to functions used in Pydra workflows """

from functools import wraps


Expand Down
1 change: 1 addition & 0 deletions pydra/tasks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
To create a task package, please fork the `pydra-tasks-template
<https://github.com/nipype/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__)
3 changes: 2 additions & 1 deletion pydra/utils/hash.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Generic object hashing dispatch"""

import os

# import stat
Expand Down Expand Up @@ -99,7 +100,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
pass # pragma: no cover


@singledispatch
Expand Down
9 changes: 6 additions & 3 deletions pydra/utils/messenger.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Messaging of states."""

import abc
import datetime as dt
import enum
Expand Down Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions pydra/utils/profiler.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utilities to keep track of performance and resource utilization."""

from pathlib import Path
import psutil
import threading
Expand Down

0 comments on commit 69f27ad

Please sign in to comment.