-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding io-registration more explicitly #28
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Marc Romeyn <[email protected]>
Signed-off-by: Marc Romeyn <[email protected]>
Signed-off-by: Marc Romeyn <[email protected]>
Signed-off-by: Marc Romeyn <[email protected]>
@@ -36,15 +36,18 @@ | |||
from typing_extensions import Annotated, ParamSpec, Self | |||
|
|||
import nemo_run.exceptions as run_exceptions | |||
from nemo_run.io.api import _IO_REGISTRY, get, register |
Check notice
Code scanning / CodeQL
Cyclic import Note
nemo_run.io.api
import fiddle as fdl | ||
import fiddle._src.experimental.dataclasses as fdl_dc | ||
|
||
from nemo_run.io.capture import _CaptureContext |
Check notice
Code scanning / CodeQL
Cyclic import Note
nemo_run.io.capture
self._context: Optional[_CaptureContext] = None | ||
|
||
@overload | ||
def __call__(self, func: Callable[..., _T]) -> Callable[..., _T]: ... |
Check notice
Code scanning / CodeQL
Statement has no effect Note
def __call__(self, func: Callable[..., _T]) -> Callable[..., _T]: ... | ||
|
||
@overload | ||
def __call__(self) -> "capture": ... |
Check notice
Code scanning / CodeQL
Statement has no effect Note
Returns: | ||
Any: The processed argument. | ||
""" | ||
from nemo_run.config import Config |
Check notice
Code scanning / CodeQL
Cyclic import Note
nemo_run.config
|
||
# If we've reached the top of the inheritance chain, create the Config | ||
if len(capture_context.arg_stack) == len(cls.__mro__) - 1: # -1 to exclude 'object' | ||
from nemo_run.config import Config |
Check notice
Code scanning / CodeQL
Cyclic import Note
nemo_run.config
|
||
with pytest.raises(TestException): | ||
with run.io.capture(): | ||
obj = self.DummyClass(42) |
Check notice
Code scanning / CodeQL
Unused local variable Note test
raise TestException("Test exception") | ||
|
||
# The object should still be captured despite the exception | ||
assert isinstance(run.io.get(obj), run.Config) |
Check warning
Code scanning / CodeQL
Unreachable code Warning test
|
||
with pytest.raises(TestException): | ||
with run.io.capture(): | ||
obj = self.DummyClass(42) |
Check notice
Code scanning / CodeQL
Unused local variable Note test
raise TestException("Test exception") | ||
|
||
# The object should still be captured despite the exception | ||
assert isinstance(run.io.get(obj), run.Config) |
Check warning
Code scanning / CodeQL
Unreachable code Warning test
No description provided.