-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IWF-157: Fix typo IdReusePolicy of ALLOW_IF_PREVIOUS_EXISTS_ABNORMALLY (
#33) * IWF-157: Fix typo IdReusePolicy of ALLOW_IF_PREVIOUS_EXISTS_ABNORMALLY * IWF-157: Fixing linter warnings * IWF-157: Poetry install fix * IWF-157: Poetry install fix * IWF-157: Updating poetry.lock * IWF-157: Adding ALLOW_IF_PREVIOUS_EXITS_ABNORMALLY unit test * IWF-157: Fixing linter warning * IWF-157: Fixing linter warning * IWF-157: Attempting poetry deps fix * IWF-157: Attempting poetry deps fix * IWF-157: Poetry dep fix * IWF-157: Poetry dep fix * IWF-157: Poetry dep fix * IWF-157: Poetry dep fix * IWF-157: adding additional args to poetry install
- Loading branch information
1 parent
d9d41dc
commit de39f87
Showing
10 changed files
with
436 additions
and
328 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,10 +11,10 @@ jobs: | |
uses: actions/setup-python@v3 | ||
with: | ||
python-version: '3.9' | ||
- name: Install deps | ||
uses: knowsuchagency/poetry-install@v1 | ||
env: | ||
POETRY_VIRTUALENVS_CREATE: false | ||
- name: Install Poetry | ||
uses: snok/install-poetry@v1 | ||
- name: Install Dependencies | ||
run: poetry install --no-interaction --no-root | ||
- name: Run linters | ||
uses: pre-commit/[email protected] | ||
pytest: | ||
|
@@ -27,10 +27,10 @@ jobs: | |
uses: actions/setup-python@v3 | ||
with: | ||
python-version: '3.9' | ||
- name: Install deps | ||
uses: knowsuchagency/poetry-install@v1 | ||
env: | ||
POETRY_VIRTUALENVS_CREATE: false | ||
- name: Install Poetry | ||
uses: snok/install-poetry@v1 | ||
- name: Install Dependencies | ||
run: poetry install --no-interaction --no-root | ||
- name: Run pytest check # sleep 30s to wait for the server to be ready | ||
run: echo "[run]">>.coveragerc && echo "omit = iwf/iwf_api/">>.coveragerc && sleep 30 && poetry run pytest -vv --cov-config=.coveragerc --cov="iwf/" . | ||
- name: Dump docker logs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
# Marker file for PEP 561 | ||
# Marker file for PEP 561 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import inspect | ||
import time | ||
import unittest | ||
from typing import Union | ||
|
||
from iwf.client import Client | ||
from iwf.command_results import CommandResults | ||
from iwf.communication import Communication | ||
from iwf.errors import WorkflowFailed | ||
from iwf.iwf_api.models import RetryPolicy | ||
from iwf.iwf_api.models.id_reuse_policy import IDReusePolicy | ||
from iwf.persistence import Persistence | ||
from iwf.state_decision import StateDecision | ||
from iwf.state_schema import StateSchema | ||
from iwf.tests.test_basic_workflow import BasicWorkflow | ||
from iwf.tests.worker_server import registry | ||
from iwf.workflow import ObjectWorkflow | ||
from iwf.workflow_context import WorkflowContext | ||
from iwf.workflow_options import WorkflowOptions | ||
from iwf.workflow_state import T, WorkflowState | ||
from iwf.workflow_state_options import WorkflowStateOptions | ||
|
||
|
||
class AbnormalExitState1(WorkflowState[Union[int, str]]): | ||
def execute( | ||
self, | ||
ctx: WorkflowContext, | ||
input: T, | ||
command_results: CommandResults, | ||
persistence: Persistence, | ||
communication: Communication, | ||
) -> StateDecision: | ||
raise RuntimeError("abnormal exit state") | ||
|
||
def get_state_options(self) -> WorkflowStateOptions: | ||
return WorkflowStateOptions( | ||
execute_api_retry_policy=RetryPolicy(maximum_attempts=1) | ||
) | ||
|
||
|
||
class AbnormalExitWorkflow(ObjectWorkflow): | ||
def get_workflow_states(self) -> StateSchema: | ||
return StateSchema.with_starting_state(AbnormalExitState1()) | ||
|
||
|
||
abnormal_exit_wf = AbnormalExitWorkflow() | ||
registry.add_workflow(abnormal_exit_wf) | ||
client = Client(registry) | ||
|
||
|
||
class TestAbnormalWorkflow(unittest.TestCase): | ||
def test_abnormal_exit_workflow(self): | ||
wf_id = f"{inspect.currentframe().f_code.co_name}-{time.time_ns()}" | ||
startOptions = WorkflowOptions( | ||
workflow_id_reuse_policy=IDReusePolicy.ALLOW_IF_PREVIOUS_EXITS_ABNORMALLY | ||
) | ||
|
||
client.start_workflow(AbnormalExitWorkflow, wf_id, 100, "input", startOptions) | ||
with self.assertRaises(WorkflowFailed): | ||
client.get_simple_workflow_result_with_wait(wf_id, str) | ||
|
||
# Starting a workflow with the same ID should be allowed since the previous failed abnormally | ||
client.start_workflow(BasicWorkflow, wf_id, 100, "input", startOptions) | ||
res = client.get_simple_workflow_result_with_wait(wf_id, str) | ||
assert res == "done" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.