From 4687973d04c2458d3618fff04732d1a6c622cbc0 Mon Sep 17 00:00:00 2001 From: Manuel Giffels Date: Thu, 9 Nov 2023 11:06:29 +0100 Subject: [PATCH 1/5] Fix type of sshexecutor stdin variable --- docs/source/changelog.rst | 2 +- tardis/utilities/executors/sshexecutor.py | 2 +- tests/utilities_t/executors_t/test_sshexecutor.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 81f23278..509c0de4 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -1,4 +1,4 @@ -.. Created by changelog.py at 2023-10-10, command +.. Created by changelog.py at 2023-11-09, command '/Users/giffler/.cache/pre-commit/repor6pnmwlm/py_env-python3.10/bin/changelog docs/source/changes compile --categories Added Changed Fixed Security Deprecated --output=docs/source/changelog.rst' based on the format of 'https://keepachangelog.com/' diff --git a/tardis/utilities/executors/sshexecutor.py b/tardis/utilities/executors/sshexecutor.py index 40c6785c..4331e549 100644 --- a/tardis/utilities/executors/sshexecutor.py +++ b/tardis/utilities/executors/sshexecutor.py @@ -90,7 +90,7 @@ async def run_command(self, command, stdin_input=None): async with self.bounded_connection as ssh_connection: try: response = await ssh_connection.run( - command, check=True, input=stdin_input and stdin_input.encode() + command, check=True, input=stdin_input and stdin_input ) except asyncssh.ProcessError as pe: raise CommandExecutionFailure( diff --git a/tests/utilities_t/executors_t/test_sshexecutor.py b/tests/utilities_t/executors_t/test_sshexecutor.py index ae83f7b5..c0c48674 100644 --- a/tests/utilities_t/executors_t/test_sshexecutor.py +++ b/tests/utilities_t/executors_t/test_sshexecutor.py @@ -43,7 +43,7 @@ async def run(self, command, input=None, **kwargs): elif command != "Test": raise ValueError(f"Unsupported mock command: {command}") return AttributeDict( - stdout=input and input.decode(), stderr="TestError", exit_status=0 + stdout=input and input, stderr="TestError", exit_status=0 ) async def create_process(self): From bda22862b3c07f0a80651f75965a2e22b2e4fccc Mon Sep 17 00:00:00 2001 From: Manuel Giffels Date: Thu, 9 Nov 2023 12:12:43 +0100 Subject: [PATCH 2/5] Add changelog for #314 --- docs/source/changelog.rst | 8 ++++++++ .../changes/314.fix_sshexecutor_stdin_parameter_type.yaml | 8 ++++++++ 2 files changed, 16 insertions(+) create mode 100644 docs/source/changes/314.fix_sshexecutor_stdin_parameter_type.yaml diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 509c0de4..82d10bc2 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -6,6 +6,14 @@ CHANGELOG ######### +[Unreleased] - 2023-11-09 +========================= + +Fixed +----- + +* Fix type of sshexecutor stdin parameter + [0.8.0] - 2023-10-05 ==================== diff --git a/docs/source/changes/314.fix_sshexecutor_stdin_parameter_type.yaml b/docs/source/changes/314.fix_sshexecutor_stdin_parameter_type.yaml new file mode 100644 index 00000000..fc44b1a4 --- /dev/null +++ b/docs/source/changes/314.fix_sshexecutor_stdin_parameter_type.yaml @@ -0,0 +1,8 @@ +category: fixed +summary: "Fix type of sshexecutor stdin parameter" +description: | + In the SSHExecutor it was assumed that asyncssh requires stdin to be in bytes format. + However, according to the documentation it is required to be in string format. Therefore, the type of stdin parameter + has been changed from byte format into string format. +pull requests: +- 314 From 387ece9215cac24b676b2ac4f01475d1057c440c Mon Sep 17 00:00:00 2001 From: Manuel Giffels Date: Thu, 9 Nov 2023 12:27:07 +0100 Subject: [PATCH 3/5] Pin python version of MacOS deployment test to 3.11 --- .github/workflows/deployment-tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deployment-tests.yml b/.github/workflows/deployment-tests.yml index 967c9171..087a72f6 100644 --- a/.github/workflows/deployment-tests.yml +++ b/.github/workflows/deployment-tests.yml @@ -58,9 +58,9 @@ jobs: - uses: actions/checkout@v3 - name: Install dependencies on ${{ matrix.platform }} run: | - python3 -m pip install --upgrade pip - python3 -m pip install .[contrib] - python3 -m pip install coverage codecov + python3.11 -m pip install --upgrade pip + python3.11 -m pip install .[contrib] + python3.11 -m pip install coverage codecov - name: Test with unittest on ${{ matrix.platform }} run: | coverage run -m unittest -v From 392a3e31ec82a9ffb73944139f77702b4e862aa3 Mon Sep 17 00:00:00 2001 From: Manuel Giffels Date: Thu, 9 Nov 2023 19:27:28 +0100 Subject: [PATCH 4/5] Apply change from review --- docs/source/changelog.rst | 4 ++-- tardis/utilities/executors/sshexecutor.py | 2 +- tests/utilities_t/executors_t/test_sshexecutor.py | 4 +--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 82d10bc2..f9e7ec60 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -1,4 +1,4 @@ -.. Created by changelog.py at 2023-11-09, command +.. Created by changelog.py at 2023-11-10, command '/Users/giffler/.cache/pre-commit/repor6pnmwlm/py_env-python3.10/bin/changelog docs/source/changes compile --categories Added Changed Fixed Security Deprecated --output=docs/source/changelog.rst' based on the format of 'https://keepachangelog.com/' @@ -6,7 +6,7 @@ CHANGELOG ######### -[Unreleased] - 2023-11-09 +[Unreleased] - 2023-11-10 ========================= Fixed diff --git a/tardis/utilities/executors/sshexecutor.py b/tardis/utilities/executors/sshexecutor.py index 4331e549..d0d4e2a1 100644 --- a/tardis/utilities/executors/sshexecutor.py +++ b/tardis/utilities/executors/sshexecutor.py @@ -90,7 +90,7 @@ async def run_command(self, command, stdin_input=None): async with self.bounded_connection as ssh_connection: try: response = await ssh_connection.run( - command, check=True, input=stdin_input and stdin_input + command, check=True, input=stdin_input ) except asyncssh.ProcessError as pe: raise CommandExecutionFailure( diff --git a/tests/utilities_t/executors_t/test_sshexecutor.py b/tests/utilities_t/executors_t/test_sshexecutor.py index c0c48674..c789ece6 100644 --- a/tests/utilities_t/executors_t/test_sshexecutor.py +++ b/tests/utilities_t/executors_t/test_sshexecutor.py @@ -42,9 +42,7 @@ async def run(self, command, input=None, **kwargs): await asyncio.sleep(float(duration)) elif command != "Test": raise ValueError(f"Unsupported mock command: {command}") - return AttributeDict( - stdout=input and input, stderr="TestError", exit_status=0 - ) + return AttributeDict(stdout=input, stderr="TestError", exit_status=0) async def create_process(self): @asynccontextmanager From 5bc20d4188744a5a0c1170e4e1fb1ad96424a04f Mon Sep 17 00:00:00 2001 From: Manuel Giffels Date: Fri, 10 Nov 2023 12:43:54 +0100 Subject: [PATCH 5/5] Use Python3.11 for Mac OS deployment tests --- .github/workflows/deployment-tests.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deployment-tests.yml b/.github/workflows/deployment-tests.yml index 087a72f6..196c5be9 100644 --- a/.github/workflows/deployment-tests.yml +++ b/.github/workflows/deployment-tests.yml @@ -58,9 +58,10 @@ jobs: - uses: actions/checkout@v3 - name: Install dependencies on ${{ matrix.platform }} run: | - python3.11 -m pip install --upgrade pip - python3.11 -m pip install .[contrib] - python3.11 -m pip install coverage codecov + export PATH=/Library/Frameworks/Python.framework/Versions/3.11/bin:$PATH + python3 -m pip install --upgrade pip + python3 -m pip install .[contrib] + python3 -m pip install coverage codecov - name: Test with unittest on ${{ matrix.platform }} run: | coverage run -m unittest -v