-
-
Notifications
You must be signed in to change notification settings - Fork 762
Pickle worker state machine exceptions #6702
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,8 @@ | |
| GatherDep, | ||
| GatherDepSuccessEvent, | ||
| Instruction, | ||
| InvalidTaskState, | ||
| InvalidTransition, | ||
| PauseEvent, | ||
| RecommendationsConflict, | ||
| RefreshWhoHasEvent, | ||
|
|
@@ -44,6 +46,7 @@ | |
| SerializedTask, | ||
| StateMachineEvent, | ||
| TaskState, | ||
| TransitionCounterMaxExceeded, | ||
| UnpauseEvent, | ||
| UpdateDataEvent, | ||
| merge_recs_instructions, | ||
|
|
@@ -194,6 +197,32 @@ def test_WorkerState_pickle(ws): | |
| assert ws2.data == {"y": 123} | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "cls,kwargs", | ||
| [ | ||
| ( | ||
| InvalidTransition, | ||
| dict(key="x", start="released", finish="waiting", story=[]), | ||
| ), | ||
| ( | ||
| TransitionCounterMaxExceeded, | ||
| dict(key="x", start="released", finish="waiting", story=[]), | ||
| ), | ||
| (InvalidTaskState, dict(key="x", state="released", story=[])), | ||
| ], | ||
| ) | ||
| @pytest.mark.parametrize("positional", [False, True]) | ||
| def test_pickle_exceptions(cls, kwargs, positional): | ||
| if positional: | ||
| e = cls(*kwargs.values()) | ||
| else: | ||
| e = cls(**kwargs) | ||
| e2 = pickle.loads(pickle.dumps(e)) | ||
| assert type(e2) is type(e) | ||
| for k, v in kwargs.items(): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we instead make use of
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exception has a weird design. Yes it would be cleaner to initialise args to the parameters and then offer |
||
| assert getattr(e2, k) == v | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. positional=True passes without any changes to worker_state_machine.py; positional=False crashes with TypeError |
||
|
|
||
|
|
||
| def traverse_subclasses(cls: type) -> Iterator[type]: | ||
| yield cls | ||
| for subcls in cls.__subclasses__(): | ||
|
|
||
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 personally prefer dict literals over their constructors, do we have any rule of thumb around what to use? It looks like nothing enforces one or the other.
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.
These are function parameters, so it felt more natural to use a dict constructor. YMMV.