Skip to content

Commit 150f8d6

Browse files
authored
Merge pull request #54 from ArcanaFramework/forward-ref-to-mime
Adds FileSet.move method
2 parents c622f2a + 30d6f0a commit 150f8d6

File tree

11 files changed

+347
-100
lines changed

11 files changed

+347
-100
lines changed

.github/workflows/ci-cd.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ jobs:
4141
- name: Update build tools
4242
run: python3 -m pip install --upgrade pip
4343
- name: Install Package
44-
run: python3 -m pip install -e .[test] -e ./extras[test]
44+
run: python3 -m pip install -e .[test]
45+
- name: Install Extras Package
46+
run: python3 -m pip install -e ./extras[test]
47+
- name: Change out of root directory
48+
run: cd docs
4549
- name: Pytest
4650
run: pytest -vvs --cov fileformats --cov-config .coveragerc --cov-report xml .
4751
- name: Upload coverage to Codecov
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
from ..core import __version__
1+
from fileformats.core import __version__
22
from .converters import *
33
from .readwrite import *

fileformats/application/serialization.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
import typing as ty
33
from random import Random
44
from pathlib import Path
5-
from ..core import hook, DataType, FileSet
6-
from ..core.mixin import WithClassifiers
5+
from fileformats.core import hook, DataType, FileSet
6+
from fileformats.core.mixin import WithClassifiers
77
from ..generic import File
8-
from ..core.exceptions import FormatMismatchError
9-
from ..core.utils import gen_filename
8+
from fileformats.core.exceptions import FormatMismatchError
9+
from fileformats.core.utils import gen_filename
1010

1111

1212
class Schema(DataType):

fileformats/core/converter.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
from abc import ABCMeta
22
import typing as ty
3+
import logging
34
import attrs
4-
from .utils import describe_task
5+
from .utils import describe_task, matching_source
56
from .exceptions import FileFormatsError
67

78
if ty.TYPE_CHECKING:
89
from .datatype import DataType
910

11+
logger = logging.getLogger("fileformats")
12+
1013

1114
@attrs.define
1215
class ConverterWrapper:
@@ -106,11 +109,10 @@ def register_converter(
106109
----------
107110
source_format : type
108111
the source format to register a converter from
109-
task_spec : ty.Callable
110-
a callable that resolves to a Pydra task
111-
converter_kwargs : dict
112-
additional keyword arguments to be passed to the task spec at initialisation
113-
time
112+
converter_tuple
113+
a tuple consisting of a `task_spec` callable that resolves to a Pydra task
114+
and a dictionary of keyword arguments to be passed to the task spec at
115+
initialisation time
114116
115117
Raises
116118
------
@@ -134,12 +136,19 @@ def register_converter(
134136
]
135137
assert len(prev_registered) <= 1
136138
if prev_registered:
137-
prev = prev_registered[0]
138-
prev_task = cls.converters[prev][0]
139+
prev_tuple = cls.converters[prev_registered[0]]
140+
task, task_kwargs = converter_tuple
141+
prev_task, prev_kwargs = prev_tuple
142+
if matching_source(task, prev_task) and task_kwargs == prev_kwargs:
143+
logger.warning(
144+
"Ignoring duplicate registrations of the same converter %s",
145+
describe_task(task),
146+
)
147+
return # actually the same task but just imported twice for some reason
139148
raise FileFormatsError(
140-
f"There is already a converter registered from {prev} "
141-
f"to the generic type '{tuple(prev.wildcard_classifiers())[0]}':"
142-
f"{describe_task(prev_task)}"
149+
f"Cannot register converter from {source_format} to the generic type "
150+
f"'{tuple(prev_task.wildcard_classifiers())[0]}', {describe_task(task)} "
151+
f"because there is already one registered, {describe_task(prev_task)}"
143152
)
144153

145154
cls.converters[source_format] = converter_tuple

0 commit comments

Comments
 (0)