From 43842162f82a6b902d47e72508798316d0e7aeeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Cac=CC=A7ador?= <20863811+samuel27m@users.noreply.github.com> Date: Fri, 13 Jun 2025 18:41:24 +0100 Subject: [PATCH 1/4] add pre-commit hook and no-nexus script --- .githooks/no-nexus.sh | 23 +++++++++++++++++++++++ .pre-commit-config.yaml | 6 ++++++ 2 files changed, 29 insertions(+) create mode 100755 .githooks/no-nexus.sh diff --git a/.githooks/no-nexus.sh b/.githooks/no-nexus.sh new file mode 100755 index 0000000..3accf74 --- /dev/null +++ b/.githooks/no-nexus.sh @@ -0,0 +1,23 @@ +#! /usr/bin/env bash + +sed -i'' \ + -e '/./{H;$!d}' \ + -e 'x' \ + -e 's|\[package.source\]\ntype\s*=\s*\"legacy\"\nurl\s*=\s*\"https://nexus.corp.indeed.com/repository/pypi/simple\"\nreference\s*=\s*\"nexus\"||' \ + poetry.lock + +sed -i'' \ + -e '1{/^\s*$/d}' \ + poetry.lock + +sed -i'' \ + -e '/^\s*$/N;/^\s*\n$/D' \ + poetry.lock + +CHANGES=$(git diff --exit-code poetry.lock | grep -Pzo '\-\[package.source\]\n\-type = "legacy"\n\-url = "https://nexus.corp.indeed.com/repository/pypi/simple"\n\-reference = "nexus"\n' | wc -c) + +if [[ $CHANGES -eq 0 ]]; then + exit 0 +fi + +exit 1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4c72a38..e0530c2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -48,3 +48,9 @@ repos: pass_filenames: false args: - "iwf" + + - id: no-nexus + name: Remove nexus references + entry: .githooks/no-nexus.sh + language: script + types: [file] # Example: run on all files, adjust as needed From 27aabca0fbfa7f398d9413f312304324a54ac515 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Cac=CC=A7ador?= <20863811+samuel27m@users.noreply.github.com> Date: Fri, 13 Jun 2025 18:42:01 +0100 Subject: [PATCH 2/4] IWF-836: SDK expects stateWaitUntilFailed flag instead stateStartApiSucceeded --- iwf-idl | 2 +- iwf/command_results.py | 12 ++++++++++-- iwf/iwf_api/models/command_results.py | 9 +++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/iwf-idl b/iwf-idl index 1c8a078..5a96d62 160000 --- a/iwf-idl +++ b/iwf-idl @@ -1 +1 @@ -Subproject commit 1c8a078d5bae41b6e71c4342129718544d3b3da5 +Subproject commit 5a96d629c6e337cdc8f363dc52a6965e02a1c0ec diff --git a/iwf/command_results.py b/iwf/command_results.py index ee0a0ef..5bc20f4 100644 --- a/iwf/command_results.py +++ b/iwf/command_results.py @@ -1,6 +1,6 @@ import typing from dataclasses import dataclass -from typing import Any, Union +from typing import Any, Union, Optional from iwf.errors import WorkflowDefinitionError, NotRegisteredError from iwf.iwf_api.models import ( @@ -40,6 +40,7 @@ class CommandResults: timer_commands: list[TimerCommandResult] internal_channel_commands: list[InternalChannelCommandResult] signal_channel_commands: list[SignalChannelCommandResult] + wait_until_api_succeeded: Optional[bool] = None def from_idl_command_results( @@ -48,9 +49,10 @@ def from_idl_command_results( signal_channel_types: dict[str, typing.Optional[type]], object_encoder: ObjectEncoder, ) -> CommandResults: - results = CommandResults(list(), list(), list()) + results = CommandResults(list(), list(), list(), None) if isinstance(idl_results, Unset): return results + if not isinstance(idl_results.timer_results, Unset): for timer in idl_results.timer_results: results.timer_commands.append( @@ -91,4 +93,10 @@ def from_idl_command_results( sig.command_id, ) ) + + if not isinstance(idl_results.state_wait_until_failed, Unset): + # The server will set state_wait_until_failed to true if the waitUntil API failed. + # Hence, flag inversion is needed here to indicate that the waitUntil API succeeded. + results.wait_until_api_succeeded = not idl_results.state_wait_until_failed + return results diff --git a/iwf/iwf_api/models/command_results.py b/iwf/iwf_api/models/command_results.py index 9a66c87..51d3290 100644 --- a/iwf/iwf_api/models/command_results.py +++ b/iwf/iwf_api/models/command_results.py @@ -23,12 +23,14 @@ class CommandResults: inter_state_channel_results (Union[Unset, list['InterStateChannelResult']]): timer_results (Union[Unset, list['TimerResult']]): state_start_api_succeeded (Union[Unset, bool]): + state_wait_until_failed (Union[Unset, bool]): """ signal_results: Union[Unset, list["SignalResult"]] = UNSET inter_state_channel_results: Union[Unset, list["InterStateChannelResult"]] = UNSET timer_results: Union[Unset, list["TimerResult"]] = UNSET state_start_api_succeeded: Union[Unset, bool] = UNSET + state_wait_until_failed: Union[Unset, bool] = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: @@ -55,6 +57,8 @@ def to_dict(self) -> dict[str, Any]: state_start_api_succeeded = self.state_start_api_succeeded + state_wait_until_failed = self.state_wait_until_failed + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) @@ -66,6 +70,8 @@ def to_dict(self) -> dict[str, Any]: field_dict["timerResults"] = timer_results if state_start_api_succeeded is not UNSET: field_dict["stateStartApiSucceeded"] = state_start_api_succeeded + if state_wait_until_failed is not UNSET: + field_dict["stateWaitUntilFailed"] = state_wait_until_failed return field_dict @@ -99,11 +105,14 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: state_start_api_succeeded = d.pop("stateStartApiSucceeded", UNSET) + state_wait_until_failed = d.pop("stateWaitUntilFailed", UNSET) + command_results = cls( signal_results=signal_results, inter_state_channel_results=inter_state_channel_results, timer_results=timer_results, state_start_api_succeeded=state_start_api_succeeded, + state_wait_until_failed=state_wait_until_failed, ) command_results.additional_properties = d From c8592b3e579e46ed6a4c835c9cec9b962eeb18a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Cac=CC=A7ador?= <20863811+samuel27m@users.noreply.github.com> Date: Fri, 13 Jun 2025 18:57:15 +0100 Subject: [PATCH 3/4] updating no-nexus.sh script --- .githooks/no-nexus.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.githooks/no-nexus.sh b/.githooks/no-nexus.sh index 3accf74..5d3b135 100755 --- a/.githooks/no-nexus.sh +++ b/.githooks/no-nexus.sh @@ -1,16 +1,16 @@ #! /usr/bin/env bash -sed -i'' \ +gsed -i'' \ -e '/./{H;$!d}' \ -e 'x' \ -e 's|\[package.source\]\ntype\s*=\s*\"legacy\"\nurl\s*=\s*\"https://nexus.corp.indeed.com/repository/pypi/simple\"\nreference\s*=\s*\"nexus\"||' \ poetry.lock -sed -i'' \ +gsed -i'' \ -e '1{/^\s*$/d}' \ poetry.lock -sed -i'' \ +gsed -i'' \ -e '/^\s*$/N;/^\s*\n$/D' \ poetry.lock From ba6caa91e2e73d2ad9bde9cd9cca6154bdb13b72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20Cac=CC=A7ador?= <20863811+samuel27m@users.noreply.github.com> Date: Mon, 16 Jun 2025 13:34:26 +0100 Subject: [PATCH 4/4] Update no-nexus.sh to include descriptive comment --- .githooks/no-nexus.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.githooks/no-nexus.sh b/.githooks/no-nexus.sh index 5d3b135..117e02f 100755 --- a/.githooks/no-nexus.sh +++ b/.githooks/no-nexus.sh @@ -1,5 +1,11 @@ #! /usr/bin/env bash +# This script ensures that the poetry.lock file does not contain references to the internal Indeed Nexus PyPI repository. +# It is used as a git hook to automatically remove the [package.source] section for Nexus from poetry.lock. +# This is necessary to ensure the lock file is portable and open-source friendly. +# The script uses gsed to remove the Nexus source block and any resulting empty lines, then checks if any changes were made. +# If Nexus references are found and removed, the script exits with 1 to prevent the commit, so we can stage the changes made by the script before committing again. + gsed -i'' \ -e '/./{H;$!d}' \ -e 'x' \