Skip to content

Commit

Permalink
rf: use runners module from datalad_core library
Browse files Browse the repository at this point in the history
All non-deprecated content of this module has been migrated to
`datalad_core` (and some to `datasalad`).

A deprecation warning it added to the module. All consuming code here
has been adjusted to the new imports.
  • Loading branch information
mih committed Oct 30, 2024
1 parent 7b5d63a commit 7f8826d
Show file tree
Hide file tree
Showing 19 changed files with 95 additions and 390 deletions.
2 changes: 1 addition & 1 deletion datalad_next/annexremotes/tests/test_archivist.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from .. import UnsupportedRequest
from ..archivist import ArchivistRemote
from datalad_next.datasets import Dataset
from datalad_next.runners import CommandError
from datalad_core.runners import CommandError

from datalad_next.tests import assert_result_count

Expand Down
2 changes: 1 addition & 1 deletion datalad_next/constraints/git.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Constraints for Git-related concepts and parameters"""
from __future__ import annotations

from datalad_next.runners import (
from datalad_core.runners import (
CommandError,
call_git,
call_git_oneline,
Expand Down
2 changes: 1 addition & 1 deletion datalad_next/gitremotes/datalad_annex.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
LegacyGitRepo as GitRepo,
)
from datalad_next.exceptions import CapturedException
from datalad_next.runners import (
from datalad_core.runners import (
CommandError,
call_git,
call_git_oneline,
Expand Down
2 changes: 1 addition & 1 deletion datalad_next/iter_collections/annexworktree.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

from datalad_next.consts import on_windows
from datalad_next.repo_utils import has_initialized_annex
from datalad_next.runners import iter_git_subproc
from datalad_core.runners import iter_git_subproc

from .gitworktree import (
GitWorktreeItem,
Expand Down
6 changes: 2 additions & 4 deletions datalad_next/iter_collections/gitdiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@

from datalad_next.consts import PRE_INIT_COMMIT_SHA
from datasalad.gitpathspec import GitPathSpecs
from datalad_next.runners import (
from datalad_core.runners import (
CommandError,
iter_git_subproc,
)
from datalad_next.runners import (
call_git,
call_git_oneline,
iter_git_subproc,
)

from .gittree import (
Expand Down
2 changes: 1 addition & 1 deletion datalad_next/iter_collections/gitstatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
)

from datalad_next.consts import PRE_INIT_COMMIT_SHA
from datalad_next.runners import (
from datalad_core.runners import (
call_git_lines,
)
from datalad_next.repo_utils import (
Expand Down
2 changes: 1 addition & 1 deletion datalad_next/iter_collections/gittree.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
itemize,
)

from datalad_next.runners import iter_git_subproc
from datalad_core.runners import iter_git_subproc

from .utils import PathBasedItem

Expand Down
2 changes: 1 addition & 1 deletion datalad_next/iter_collections/gitworktree.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
itemize,
)

from datalad_next.runners import iter_git_subproc
from datalad_core.runners import iter_git_subproc
from datasalad.gitpathspec import GitPathSpecs
from .utils import (
FileSystemItem,
Expand Down
2 changes: 1 addition & 1 deletion datalad_next/iter_collections/tests/test_itergitstatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pytest

from datalad_next.datasets import Dataset
from datalad_next.runners import (
from datalad_core.runners import (
call_git_success,
)

Expand Down
2 changes: 1 addition & 1 deletion datalad_next/patches/replace_sshremoteio.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

from datalad_next.exceptions import CapturedException
from datalad_next.patches import apply_patch
from datalad_next.runners import CommandError
from datalad_core.runners import CommandError
from datalad_next.shell import (
FixedLengthResponseGeneratorPosix,
shell,
Expand Down
2 changes: 1 addition & 1 deletion datalad_next/repo_utils/annex.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pathlib import Path

from datalad_next.runners import call_git_success
from datalad_core.runners import call_git_success


def has_initialized_annex(
Expand Down
2 changes: 1 addition & 1 deletion datalad_next/repo_utils/tests/test_head.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from datalad_next.runners import call_git
from datalad_core.runners import call_git

from .. import get_worktree_head

Expand Down
2 changes: 1 addition & 1 deletion datalad_next/repo_utils/worktree.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pathlib import Path

from datalad_next.exceptions import CapturedException
from datalad_next.runners import (
from datalad_core.runners import (
CommandError,
call_git_lines,
)
Expand Down
113 changes: 77 additions & 36 deletions datalad_next/runners/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
"""Execution of subprocesses
.. deprecated:: 1.6
This module is deprecated. It has been partially migrated to the
`datalad-core library <https://pypi.org/project/datalad-core>`__. Imports
should be adjusted to ``datalad_core.runners``.
This module provides all relevant components for subprocess execution. The
main work horse is :func:`~datalad_next.runners.iter_subproc`, a context
manager that enables interaction with a subprocess in the form of an iterable
Expand Down Expand Up @@ -63,59 +68,95 @@
StdOutErrCapture
"""

from .iter_subproc import (
iter_subproc,
)
from .git import (
call_git,
call_git_lines,
call_git_oneline,
call_git_success,
iter_git_subproc,
__all__ = [
'call_git',
'call_git_lines',
'call_git_oneline',
'call_git_success',
'iter_git_subproc',
'iter_subproc',
'CommandError',
'GitRunner',
'KillOutput',
'NoCapture',
'Protocol',
'Runner',
'StdErrCapture',
'StdOutCapture',
'StdOutErrCapture',
'STDERR_FILENO',
'STDOUT_FILENO',
'ThreadedRunner',
'LineSplitter',
'GeneratorMixIn',
'NoCaptureGeneratorProtocol',
'StdOutCaptureGeneratorProtocol',
'DEVNULL',
]

import warnings

# TODO: REMOVE FOR V2.0
from subprocess import (
DEVNULL,
)

# runners
# TODO REMOVE FOR V2.0
from datalad.runner import (
GitRunner,
Runner,
)
# TODO REMOVE FOR V2.0
from datalad.runner.nonasyncrunner import ThreadedRunner
# TODO: REMOVE FOR V2.0
# protocols
# TODO REMOVE FOR V2.0
# TODO: REMOVE FOR V2.0
from datalad.runner import (
GitRunner,
KillOutput,
NoCapture,
Protocol,
StdOutCapture,
Runner,
StdErrCapture,
StdOutCapture,
StdOutErrCapture,
)
# TODO REMOVE FOR V2.0
from datalad.runner.protocol import GeneratorMixIn
# TODO REMOVE FOR V2.0
from .protocols import (
NoCaptureGeneratorProtocol,
StdOutCaptureGeneratorProtocol,
)
# exceptions
# The following import supports legacy code that uses `CommandError` from this
# module. If you are writing new code, please use `CommandError` from
# `datalad.support.exceptions`. We intend to remove this import in the future.
from datalad_next.exceptions import CommandError

# TODO: REMOVE FOR V2.0
# utilities
# TODO REMOVE FOR V2.0
# TODO: REMOVE FOR V2.0
from datalad.runner.nonasyncrunner import (
STDOUT_FILENO,
STDERR_FILENO,
STDOUT_FILENO,
ThreadedRunner,
)
# TODO REMOVE FOR V2.0

# TODO: REMOVE FOR V2.0
from datalad.runner.protocol import GeneratorMixIn

# TODO: REMOVE FOR V2.0
from datalad.runner.utils import (
LineSplitter,
)
# TODO REMOVE FOR V2.0
from subprocess import (
DEVNULL,
from datalad_core.runners import (
call_git,
call_git_lines,
call_git_oneline,
call_git_success,
iter_git_subproc,
iter_subproc,
)

# exceptions
# The following import supports legacy code that uses `CommandError` from this
# module. If you are writing new code, please use `CommandError` from
# `datalad_core.runners`. We intend to remove this import in the future.
from datalad_next.exceptions import CommandError

# TODO: REMOVE FOR V2.0
from .protocols import (
NoCaptureGeneratorProtocol,
StdOutCaptureGeneratorProtocol,
)

warnings.warn(
'`datalad_next.runners` has been partially migrated to the '
'datalad-core library, '
'check docs, and adjust imports to `datalad_core.runners`',
DeprecationWarning,
stacklevel=1,
)
Loading

0 comments on commit 7f8826d

Please sign in to comment.