-
Notifications
You must be signed in to change notification settings - Fork 3
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
IWF-157: Fix typo IdReusePolicy of ALLOW_IF_PREVIOUS_EXISTS_ABNORMALLY #33
Merged
Merged
Changes from 9 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0ffe568
IWF-157: Fix typo IdReusePolicy of ALLOW_IF_PREVIOUS_EXISTS_ABNORMALLY
stevo89519 30dbad5
IWF-157: Fixing linter warnings
stevo89519 5874aca
IWF-157: Poetry install fix
stevo89519 d0a882d
IWF-157: Poetry install fix
stevo89519 75b401e
IWF-157: Updating poetry.lock
stevo89519 80a1d72
IWF-157: Adding ALLOW_IF_PREVIOUS_EXITS_ABNORMALLY unit test
stevo89519 474e40c
IWF-157: Fixing linter warning
stevo89519 b95cc13
IWF-157: Fixing linter warning
stevo89519 27f51ab
IWF-157: Attempting poetry deps fix
stevo89519 2e3563a
IWF-157: Attempting poetry deps fix
stevo89519 c75c721
IWF-157: Poetry dep fix
stevo89519 6016671
IWF-157: Poetry dep fix
stevo89519 52a56d0
IWF-157: Poetry dep fix
stevo89519 c8642e4
IWF-157: Poetry dep fix
stevo89519 5ff23cf
IWF-157: adding additional args to poetry install
stevo89519 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -12,9 +12,9 @@ jobs: | |
with: | ||
python-version: '3.9' | ||
- name: Install deps | ||
uses: knowsuchagency/poetry-install@v1 | ||
env: | ||
POETRY_VIRTUALENVS_CREATE: false | ||
uses: snok/install-poetry@v1 | ||
with: | ||
virtualenvs-create: false | ||
- name: Run linters | ||
uses: pre-commit/[email protected] | ||
pytest: | ||
|
@@ -28,9 +28,9 @@ jobs: | |
with: | ||
python-version: '3.9' | ||
- name: Install deps | ||
uses: knowsuchagency/poetry-install@v1 | ||
env: | ||
POETRY_VIRTUALENVS_CREATE: false | ||
uses: snok/install-poetry@v1 | ||
with: | ||
virtualenvs-create: false | ||
- 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
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied this value from somewhere else but didn't fully understand. do you know why this has to be 'false'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No I don't know. I'm also not sure if calling 'poetry install' here will cause any downsides? It fixed the workflow issues.