Skip to content

Commit 53858c3

Browse files
authored
IWF-836: SDK expects stateWaitUntilFailed flag instead stateStartApiSucceeded (#112)
* add pre-commit hook and no-nexus script * IWF-836: SDK expects stateWaitUntilFailed flag instead stateStartApiSucceeded * updating no-nexus.sh script * Update no-nexus.sh to include descriptive comment
1 parent 695e320 commit 53858c3

File tree

5 files changed

+55
-3
lines changed

5 files changed

+55
-3
lines changed

.githooks/no-nexus.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#! /usr/bin/env bash
2+
3+
# This script ensures that the poetry.lock file does not contain references to the internal Indeed Nexus PyPI repository.
4+
# It is used as a git hook to automatically remove the [package.source] section for Nexus from poetry.lock.
5+
# This is necessary to ensure the lock file is portable and open-source friendly.
6+
# The script uses gsed to remove the Nexus source block and any resulting empty lines, then checks if any changes were made.
7+
# 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.
8+
9+
gsed -i'' \
10+
-e '/./{H;$!d}' \
11+
-e 'x' \
12+
-e 's|\[package.source\]\ntype\s*=\s*\"legacy\"\nurl\s*=\s*\"https://nexus.corp.indeed.com/repository/pypi/simple\"\nreference\s*=\s*\"nexus\"||' \
13+
poetry.lock
14+
15+
gsed -i'' \
16+
-e '1{/^\s*$/d}' \
17+
poetry.lock
18+
19+
gsed -i'' \
20+
-e '/^\s*$/N;/^\s*\n$/D' \
21+
poetry.lock
22+
23+
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)
24+
25+
if [[ $CHANGES -eq 0 ]]; then
26+
exit 0
27+
fi
28+
29+
exit 1

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,9 @@ repos:
4848
pass_filenames: false
4949
args:
5050
- "iwf"
51+
52+
- id: no-nexus
53+
name: Remove nexus references
54+
entry: .githooks/no-nexus.sh
55+
language: script
56+
types: [file] # Example: run on all files, adjust as needed

iwf-idl

iwf/command_results.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import typing
22
from dataclasses import dataclass
3-
from typing import Any, Union
3+
from typing import Any, Union, Optional
44

55
from iwf.errors import WorkflowDefinitionError, NotRegisteredError
66
from iwf.iwf_api.models import (
@@ -40,6 +40,7 @@ class CommandResults:
4040
timer_commands: list[TimerCommandResult]
4141
internal_channel_commands: list[InternalChannelCommandResult]
4242
signal_channel_commands: list[SignalChannelCommandResult]
43+
wait_until_api_succeeded: Optional[bool] = None
4344

4445

4546
def from_idl_command_results(
@@ -48,9 +49,10 @@ def from_idl_command_results(
4849
signal_channel_types: dict[str, typing.Optional[type]],
4950
object_encoder: ObjectEncoder,
5051
) -> CommandResults:
51-
results = CommandResults(list(), list(), list())
52+
results = CommandResults(list(), list(), list(), None)
5253
if isinstance(idl_results, Unset):
5354
return results
55+
5456
if not isinstance(idl_results.timer_results, Unset):
5557
for timer in idl_results.timer_results:
5658
results.timer_commands.append(
@@ -91,4 +93,10 @@ def from_idl_command_results(
9193
sig.command_id,
9294
)
9395
)
96+
97+
if not isinstance(idl_results.state_wait_until_failed, Unset):
98+
# The server will set state_wait_until_failed to true if the waitUntil API failed.
99+
# Hence, flag inversion is needed here to indicate that the waitUntil API succeeded.
100+
results.wait_until_api_succeeded = not idl_results.state_wait_until_failed
101+
94102
return results

iwf/iwf_api/models/command_results.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ class CommandResults:
2323
inter_state_channel_results (Union[Unset, list['InterStateChannelResult']]):
2424
timer_results (Union[Unset, list['TimerResult']]):
2525
state_start_api_succeeded (Union[Unset, bool]):
26+
state_wait_until_failed (Union[Unset, bool]):
2627
"""
2728

2829
signal_results: Union[Unset, list["SignalResult"]] = UNSET
2930
inter_state_channel_results: Union[Unset, list["InterStateChannelResult"]] = UNSET
3031
timer_results: Union[Unset, list["TimerResult"]] = UNSET
3132
state_start_api_succeeded: Union[Unset, bool] = UNSET
33+
state_wait_until_failed: Union[Unset, bool] = UNSET
3234
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
3335

3436
def to_dict(self) -> dict[str, Any]:
@@ -55,6 +57,8 @@ def to_dict(self) -> dict[str, Any]:
5557

5658
state_start_api_succeeded = self.state_start_api_succeeded
5759

60+
state_wait_until_failed = self.state_wait_until_failed
61+
5862
field_dict: dict[str, Any] = {}
5963
field_dict.update(self.additional_properties)
6064
field_dict.update({})
@@ -66,6 +70,8 @@ def to_dict(self) -> dict[str, Any]:
6670
field_dict["timerResults"] = timer_results
6771
if state_start_api_succeeded is not UNSET:
6872
field_dict["stateStartApiSucceeded"] = state_start_api_succeeded
73+
if state_wait_until_failed is not UNSET:
74+
field_dict["stateWaitUntilFailed"] = state_wait_until_failed
6975

7076
return field_dict
7177

@@ -99,11 +105,14 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
99105

100106
state_start_api_succeeded = d.pop("stateStartApiSucceeded", UNSET)
101107

108+
state_wait_until_failed = d.pop("stateWaitUntilFailed", UNSET)
109+
102110
command_results = cls(
103111
signal_results=signal_results,
104112
inter_state_channel_results=inter_state_channel_results,
105113
timer_results=timer_results,
106114
state_start_api_succeeded=state_start_api_succeeded,
115+
state_wait_until_failed=state_wait_until_failed,
107116
)
108117

109118
command_results.additional_properties = d

0 commit comments

Comments
 (0)