Skip to content

Commit 7f3ca57

Browse files
authored
Merge pull request #101 from ArcanaFramework/relative-copy-check
Update to match refactor of Pydra API
2 parents 1b6f3e0 + 4dce0e1 commit 7f3ca57

File tree

11 files changed

+44
-48
lines changed

11 files changed

+44
-48
lines changed

.github/workflows/ci-cd.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
- name: Install Extras Package
4848
run: python3 -m pip install -e ./extras[test]
4949
- name: Install development Pydra
50-
run: pip install --no-deps git+https://github.com/nipype/pydra.git@new-syntax
50+
run: pip install --no-deps git+https://github.com/nipype/pydra.git@develop
5151
- name: MyPy
5252
run: mypy --install-types --non-interactive --no-warn-unused-ignores .
5353
- name: Pytest

extras/fileformats/extras/application/archive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import tarfile
66
import zipfile
77
from pathlib import Path
8-
from pydra.design import python
8+
from pydra.compose import python
99
from fileformats.generic import FsObject
1010
from fileformats.core.utils import set_cwd
1111
from fileformats.core.typing import PathType

extras/fileformats/extras/application/serialization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import typing as ty
33
import tempfile
44
import yaml
5-
from pydra.design import python
5+
from pydra.compose import python
66
from fileformats.core import FileSet, converter, extra_implementation
77
from fileformats.application import TextSerialization, Json, Yaml
88
from fileformats.application.serialization import SerializationType

extras/fileformats/extras/generic/converters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import tempfile
22
from pathlib import Path
33
import typing as ty
4-
from pydra.design import python
4+
from pydra.compose import python
55
from fileformats.core import converter, FileSet
66
from fileformats.generic import DirectoryOf, SetOf, TypedDirectory, TypedSet
77

extras/fileformats/extras/image/converters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from pathlib import Path
22
import typing as ty
33
import tempfile
4-
from pydra.design import python
4+
from pydra.compose import python
55
from fileformats.core import converter
66
from fileformats.image.raster import RasterImage, Bitmap, Gif, Jpeg, Png, Tiff
77

fileformats/core/converter_helpers.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from .datatype import DataType
77

88
if ty.TYPE_CHECKING:
9-
from pydra.engine.specs import TaskDef
9+
from pydra.compose.base import Task
1010
import fileformats.core
1111
from . import mixin
1212

@@ -120,17 +120,17 @@ def register_converter(
120120
prev_def = cls.converters[prev_registered[0]]
121121
# task, task_kwargs, _ = converter_spec
122122
# prev_task, prev_kwargs = prev_tuple
123-
if converter.task_def == prev_def.task_def:
123+
if converter.task == prev_def.task:
124124
logger.warning(
125125
"Ignoring duplicate registrations of the same converter %s",
126-
converter.task_def,
126+
converter.task,
127127
)
128128
return # actually the same task but just imported twice for some reason
129-
generic_type = tuple(prev_def.task_def.wildcard_classifiers())[0] # type: ignore
129+
generic_type = tuple(prev_def.task.wildcard_classifiers())[0] # type: ignore
130130
raise FormatDefinitionError(
131131
f"Cannot register converter from {source_format} to the generic type "
132-
f"'{generic_type}', {converter.task_def} "
133-
f"because there is already one registered, {prev_def.task_def}"
132+
f"'{generic_type}', {converter.task} "
133+
f"because there is already one registered, {prev_def.task}"
134134
)
135135

136136
cls.converters[source_format] = converter # type: ignore
@@ -140,19 +140,19 @@ class Converter:
140140
"""Specification of a converter task, including the task callable, its arguments and
141141
the classifiers"""
142142

143-
task_def: "TaskDef[ty.Any]"
143+
task: "Task[ty.Any]"
144144
classifiers: ty.Tuple[ty.Type[Classifier], ...]
145145
in_file: str
146146
out_file: str
147147

148148
def __init__(
149149
self,
150-
task_def: "TaskDef[T]",
150+
task: "Task[T]",
151151
classifiers: ty.Tuple[ty.Type[Classifier], ...] = (),
152152
in_file: str = "in_file",
153153
out_file: str = "out_file",
154154
):
155-
self.task_def = task_def
155+
self.task = task
156156
self.classifiers = classifiers
157157
self.in_file = in_file
158158
self.out_file = out_file
@@ -162,7 +162,7 @@ def __eq__(self, other: object) -> bool:
162162

163163
return (
164164
isinstance(other, Converter)
165-
and self.task_def == other.task_def
165+
and self.task == other.task
166166
and hash_function(self.classifiers) == hash_function(other.classifiers)
167167
and self.in_file == other.in_file
168168
and self.out_file == other.out_file

fileformats/core/extras.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from typing import Self
1919

2020
if ty.TYPE_CHECKING:
21-
from pydra.engine.specs import TaskDef
21+
from pydra.compose.base import Task
2222

2323
T = ty.TypeVar("T")
2424
ExtraImplementation = ty.TypeVar("ExtraImplementation", bound=ty.Callable[..., ty.Any])
@@ -190,21 +190,21 @@ def type_match(mtype: ty.Union[str, type], ftype: ty.Union[str, type]) -> bool:
190190

191191

192192
def converter(
193-
task_type: ty.Optional[ty.Type["TaskDef[T]"]] = None,
193+
task_type: ty.Optional[ty.Type["Task[T]"]] = None,
194194
source_format: FormatType = None,
195195
target_format: FormatType = None,
196196
in_file: str = "in_file",
197197
out_file: str = "out_file",
198198
**converter_kwargs: ty.Any,
199199
) -> ty.Union[
200-
ty.Type["TaskDef[T]"], ty.Callable[[ty.Type["TaskDef[T]"]], ty.Type["TaskDef[T]"]]
200+
ty.Type["Task[T]"], ty.Callable[[ty.Type["Task[T]"]], ty.Type["Task[T]"]]
201201
]:
202202
"""Decorator that registers a task as a converter between a source and target format
203203
pair
204204
205205
Parameters
206206
----------
207-
task_type : pydra.engine.core.TaskBase, optional
207+
task_type : pydra.compose.base.Task, optional
208208
the Pydra task to register as a converter, if provided the decorator is assumed
209209
to wrap the task spec directly, otherwise a wrapping decorator is returned instead
210210
source_format: type, optional
@@ -235,8 +235,8 @@ def converter(
235235
converter_kwargs["in_file"] = converter_kwargs.pop("in_file_")
236236

237237
def decorator(
238-
task_type: ty.Type["TaskDef[T]"],
239-
) -> ty.Type["TaskDef[T]"]:
238+
task_type: ty.Type["Task[T]"],
239+
) -> ty.Type["Task[T]"]:
240240
out_file_local = out_file
241241
source: FormatType
242242
target: FormatType

fileformats/core/fileset.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,8 @@ def convert(
525525
assert isinstance(fileset, cls)
526526
return copy(fileset)
527527
kwargs[converter.in_file] = fileset
528-
task_def = attrs.evolve(converter.task_def, **kwargs)
529-
outputs = task_def()
528+
task = attrs.evolve(converter.task, **kwargs)
529+
outputs = task()
530530
out_file = getattr(outputs, converter.out_file)
531531
if not isinstance(out_file, cls):
532532
out_file = cls(out_file)
@@ -584,9 +584,7 @@ def get_converter(
584584
available_converters = [available_converters[0]]
585585
else:
586586
available_converters[0] == available_converters[1]
587-
available_str = "\n".join(
588-
str(a.task_def) for a in available_converters
589-
)
587+
available_str = "\n".join(str(a.task) for a in available_converters)
590588
raise FormatConversionError(
591589
f"Ambiguous converters found between '{cls.mime_like}' and "
592590
f"'{source_format.mime_like}':\n{available_str}"
@@ -684,18 +682,18 @@ def register_converter(
684682
prev_converter = cls.converters[source_format]
685683
# task, task_kwargs = converter_spec
686684
# prev_task, prev_kwargs = prev_tuple
687-
if converter.task_def == prev_converter.task_def:
685+
if converter.task == prev_converter.task:
688686
logger.warning(
689687
"Ignoring duplicate registrations of the same converter %s",
690-
converter.task_def,
688+
converter.task,
691689
)
692690
return # actually the same task but just imported twice for some reason
693691
raise FormatConversionError(
694692
f"Cannot register converter from {source_format.__name__} "
695-
f"to {cls.__name__}, {converter.task_def}, because there is already "
696-
f"one registered from {prev_converter.task_def}:"
697-
f"\n\n{converter.task_def}\n\n"
698-
f"and {prev_converter.task_def}\n\n"
693+
f"to {cls.__name__}, {converter.task}, because there is already "
694+
f"one registered from {prev_converter.task}:"
695+
f"\n\n{converter.task}\n\n"
696+
f"and {prev_converter.task}\n\n"
699697
)
700698
converters_dict[source_format] = converter
701699

fileformats/core/mixin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -661,15 +661,15 @@ def register_converter(
661661
if converter == prev_converter:
662662
logger.warning(
663663
"Ignoring duplicate registrations of the same converter %s",
664-
converter.task_def,
664+
converter.task,
665665
)
666666
return # actually the same task but just imported twice for some reason
667667
prev_unclassified = prev.unclassified
668668
unclassified = cls.unclassified # type: ignore[attr-defined]
669669
raise FormatDefinitionError(
670670
f"Cannot register converter from {prev_unclassified} "
671671
f"to {unclassified} with non-wildcard classifiers "
672-
f"{list(prev.non_wildcard_classifiers())}, {converter.task_def}, "
672+
f"{list(prev.non_wildcard_classifiers())}, {converter.task}, "
673673
f"because there is already one registered, {prev_converter.task}"
674674
)
675675
converters_dict = cls.unclassified.get_converters_dict() # type: ignore[attr-defined]

fileformats/core/tests/test_classifiers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22
import decimal
33
import pytest
4-
from pydra.design import python
4+
from pydra.compose import python
55
from fileformats.core import from_mime, DataType, FileSet
66
from fileformats.core import converter
77
from fileformats.application import Zip

0 commit comments

Comments
 (0)