Skip to content
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

Add PersistentSubShell-feature #596

Merged
merged 30 commits into from
Apr 18, 2024
Merged

Add PersistentSubShell-feature #596

merged 30 commits into from
Apr 18, 2024

Commits on Feb 26, 2024

  1. add bufsize parameter to iterable subprocesses

    This commit adds the parameter `bufsize` to
    `iterable_subprocesses` and to `iter_subproc`.
    Its value is passed into `subprocess.Popen`.
    
    This change is necessary to implement
    interactions with interactive subprocesses,
    for example a remote shell. These
    processes usually require a buffer size
    of zero, because each "request", i.e. an
    input to an interactive process, results
    in a "response" of unknown size and
    structure. In an interactive communication,
    each repsonse has to be interpreted before
    the next request can be sent. Therefore
    every byte that an interactive process emits
    has to be sent to the client, which
    processes it and assembles a response.
    
    In addition this commit makes the previously
    internal class `OutputFrom` (defined in
    `datalad_next.iterable_subprocess.iterable_subprocess`)
    available as
    `datalad_next.iterable_subprocess.OutputFrom`.
    
    This commit is in preparation for an
    interactive shell-class that will be
    used, for example, in RIA stores.
    christian-monch committed Feb 26, 2024
    Configuration menu
    Copy the full SHA
    4261fdf View commit details
    Browse the repository at this point in the history
  2. improve align_pattern performance

    This commit improves the performance
    of `align_pattern` by using a compiled
    regular expression to match pattern
    prefixes at the end of chunks. This
    increases the performance of
    `align_pattern`, roughly by
    the factor 8.
    christian-monch committed Feb 26, 2024
    Configuration menu
    Copy the full SHA
    f592614 View commit details
    Browse the repository at this point in the history
  3. add datalad_next.shell.shell context manager

    The `shell` context manager
    opens a connection to a shell. Typically
    the shell is executed remotely via ssh,
    but it might also be a local shell, e.g. `bash`.
    It allows to send commands to the shell,
    read the output of `stdout` and determines
    the return code of the command.
    When the context is left, the shell is
    closed, by closing its `stdin`.
    
    The `shell` context manager is extensible
    through the concept of "Response Generators".
    New response generator-classes can be used
    to support new operating system, differing
    command line syntax, or different behavior
    of commands on different operating system.
    Currently it supports `bash` and `PowerShell`.
    
    The commit also includes a number of
    "convenience" functions for Linux and OSX
    that can be executed on a `shell`-context.
    
     - download files
     - upload files
     - delete files
    
    This commit incoroporates
    fixes and suggestions from:
    
    Adina Wagner <[email protected]>
    Michael Hanke <[email protected]>
    
    Many thanks for that.
    christian-monch committed Feb 26, 2024
    Configuration menu
    Copy the full SHA
    025c18a View commit details
    Browse the repository at this point in the history

Commits on Mar 7, 2024

  1. Configuration menu
    Copy the full SHA
    68c22af View commit details
    Browse the repository at this point in the history

Commits on Mar 8, 2024

  1. add safe_read wrapper to fix a bug

    This commit adds a safe_read wrapper to prevent
    a `ValueError`-exception if the thread
    `iterable_subprocess.<locals>.input_to` tries
    to read from a closed file.
    
    A situation that triggers this error is
    described here:
    
    <datalad#596 (comment)>
    christian-monch committed Mar 8, 2024
    Configuration menu
    Copy the full SHA
    d57f533 View commit details
    Browse the repository at this point in the history

Commits on Mar 11, 2024

  1. Configuration menu
    Copy the full SHA
    45c5fac View commit details
    Browse the repository at this point in the history

Commits on Mar 12, 2024

  1. update docstring

    christian-monch committed Mar 12, 2024
    Configuration menu
    Copy the full SHA
    81d8554 View commit details
    Browse the repository at this point in the history
  2. raise CommandError if shell commands fail

    This commit modifies the code to always raise
    a `CommandError`, if a command that is
    executed in a shell fails. This is in line
    with the behavior of the other runner-tools.
    christian-monch committed Mar 12, 2024
    Configuration menu
    Copy the full SHA
    6cb2b7c View commit details
    Browse the repository at this point in the history

Commits on Mar 13, 2024

  1. fix type definitions

    christian-monch committed Mar 13, 2024
    Configuration menu
    Copy the full SHA
    2b6917c View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    c5c776e View commit details
    Browse the repository at this point in the history

Commits on Mar 14, 2024

  1. support str-commands in ShellCommandExecutor

    This commit addressed a reviewer comment that
    auggested to also accept commands given as
    `str`. This leads to an extension of the
    `ShellCommandExecutor.__call__`-interface
    by the new parameter `encoding` that
    defines the encoding that should be used
    when converting `str`-commands into
    `bytes`-commands.
    christian-monch committed Mar 14, 2024
    Configuration menu
    Copy the full SHA
    c1b964a View commit details
    Browse the repository at this point in the history
  2. clean up code and improve names

    `ShellCommandResponseGenerator.get_command_list`
    is renamed to
    `ShellCommandResponseGenerator.get_final_command`
    and its return value is now `bytes` instead of a
    list of bytes.
    
    Some duplicated code in response generators has
    been moved into base classes.
    
    `ShellCommandResponseGenerator.get_number_and_newline`
    was made private since it is only used by
    subclasses of `ShellCommandResponseGenerator`.
    christian-monch committed Mar 14, 2024
    Configuration menu
    Copy the full SHA
    ee4bdf5 View commit details
    Browse the repository at this point in the history
  3. fix an error in str-command handling

    This commit fixed an error in `str`-command
    handling and adds testing for `str`-commands.
    christian-monch committed Mar 14, 2024
    Configuration menu
    Copy the full SHA
    950ec40 View commit details
    Browse the repository at this point in the history
  4. fixed a typo

    christian-monch committed Mar 14, 2024
    Configuration menu
    Copy the full SHA
    f005419 View commit details
    Browse the repository at this point in the history

Commits on Mar 15, 2024

  1. use a queue to signal completion in posix.upload

    This commit adds a queue to upload that is used
    by an iterator to signal the completion of the
    read-operation on the local file. This is a better
    way to prevent the "read() on closed file"-error.
    
    A docstring-error is fixed as well.
    christian-monch committed Mar 15, 2024
    Configuration menu
    Copy the full SHA
    b849323 View commit details
    Browse the repository at this point in the history

Commits on Mar 18, 2024

  1. replace stat with ls in download-op

    This commit uses `ls -dln` instead of
    `stat` to determine the size of a
    file on the connected shell. This is
    supported by more Unix-flavors, e.g.
    by Linux and OSX.
    christian-monch committed Mar 18, 2024
    Configuration menu
    Copy the full SHA
    1f34132 View commit details
    Browse the repository at this point in the history

Commits on Mar 26, 2024

  1. fix a comment

    christian-monch committed Mar 26, 2024
    Configuration menu
    Copy the full SHA
    620bbe1 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    028e752 View commit details
    Browse the repository at this point in the history

Commits on Apr 13, 2024

  1. Configuration menu
    Copy the full SHA
    9d4ae1a View commit details
    Browse the repository at this point in the history

Commits on Apr 17, 2024

  1. address reviewer comments

    TODO: update docstrings
    
    1. make shell.__call__ consume everything
    2. add shell.start
    3. don't raise CommandError by default
    4. add check to enable CommandError-raising
    5. small improvements
    6. extend tests
    christian-monch committed Apr 17, 2024
    Configuration menu
    Copy the full SHA
    d006050 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    1a99586 View commit details
    Browse the repository at this point in the history
  3. update documentation

    christian-monch committed Apr 17, 2024
    Configuration menu
    Copy the full SHA
    ba8985e View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    e68aa0d View commit details
    Browse the repository at this point in the history
  5. Employ shell feature in SSH test fixture

    Previously, this has been a series of SSH calls, each running in its own
    shell. Now a persistent shell is used to interleave remote and local
    checks.
    mih authored and christian-monch committed Apr 17, 2024
    Configuration menu
    Copy the full SHA
    7b5635e View commit details
    Browse the repository at this point in the history
  6. adapt mih's changes to changed code

    This commit adapts the changes made by
    mih in his forked branch to the changes
    that were made in this branch in the
    meantime.
    christian-monch committed Apr 17, 2024
    Configuration menu
    Copy the full SHA
    c1a2dcf View commit details
    Browse the repository at this point in the history
  7. fix a typo

    christian-monch committed Apr 17, 2024
    Configuration menu
    Copy the full SHA
    2117d65 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    04b4140 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    bcb39b8 View commit details
    Browse the repository at this point in the history
  10. fix windows tests

    christian-monch committed Apr 17, 2024
    Configuration menu
    Copy the full SHA
    79436f8 View commit details
    Browse the repository at this point in the history

Commits on Apr 18, 2024

  1. Update datalad_next/shell/operations/posix.py

    Co-authored-by: Michael Hanke <[email protected]>
    christian-monch and mih authored Apr 18, 2024
    Configuration menu
    Copy the full SHA
    ce445a8 View commit details
    Browse the repository at this point in the history