-
-
Notifications
You must be signed in to change notification settings - Fork 753
Yank state machine out of Worker class #6566
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 |
|---|---|---|
|
|
@@ -32,6 +32,7 @@ | |
| TaskState, | ||
| TaskStateState, | ||
| UpdateDataEvent, | ||
| WorkerState, | ||
| merge_recs_instructions, | ||
| ) | ||
|
|
||
|
|
@@ -72,6 +73,74 @@ def test_TaskState__to_dict(): | |
| ] | ||
|
|
||
|
|
||
| def test_WorkerState__to_dict(): | ||
| ws = WorkerState(8) | ||
| ws.address = "127.0.0.1.1234" | ||
| ws.handle_stimulus( | ||
| AcquireReplicasEvent(who_has={"x": ["127.0.0.1:1235"]}, stimulus_id="s1") | ||
| ) | ||
| ws.handle_stimulus( | ||
| UpdateDataEvent(data={"y": object()}, report=False, stimulus_id="s2") | ||
| ) | ||
|
|
||
| actual = recursive_to_dict(ws) | ||
| # Remove timestamps | ||
| for ev in actual["log"]: | ||
| del ev[-1] | ||
| for stim in actual["stimulus_log"]: | ||
| del stim["handled"] | ||
|
|
||
| expect = { | ||
| "address": "127.0.0.1.1234", | ||
| "busy_workers": [], | ||
| "constrained": [], | ||
| "data": {"y": None}, | ||
| "data_needed": ["x"], | ||
| "data_needed_per_worker": {"127.0.0.1:1235": ["x"]}, | ||
| "executing": [], | ||
| "in_flight_tasks": [], | ||
| "in_flight_workers": {}, | ||
| "log": [ | ||
| ["x", "ensure-task-exists", "released", "s1"], | ||
| ["x", "released", "fetch", "fetch", {}, "s1"], | ||
| ["y", "put-in-memory", "s2"], | ||
| ["y", "receive-from-scatter", "s2"], | ||
| ], | ||
| "long_running": [], | ||
| "nthreads": 8, | ||
| "ready": [], | ||
| "running": True, | ||
| "stimulus_log": [ | ||
| { | ||
| "cls": "AcquireReplicasEvent", | ||
| "stimulus_id": "s1", | ||
| "who_has": {"x": ["127.0.0.1:1235"]}, | ||
| }, | ||
| { | ||
| "cls": "UpdateDataEvent", | ||
| "data": {"y": None}, | ||
| "report": False, | ||
| "stimulus_id": "s2", | ||
| }, | ||
| ], | ||
| "tasks": { | ||
| "x": { | ||
| "key": "x", | ||
| "priority": [1], | ||
| "state": "fetch", | ||
| "who_has": ["127.0.0.1:1235"], | ||
| }, | ||
| "y": { | ||
| "key": "y", | ||
| "nbytes": 16, | ||
| "state": "memory", | ||
| }, | ||
| }, | ||
| "transition_counter": 1, | ||
| } | ||
| assert actual == expect | ||
|
Comment on lines
+93
to
+141
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. I think we'll need to change this to be less verbose. no need to block the PR, though.
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. I really like this test though. It gives the reader a very good impression of what a much larger real-life dump looks like.
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. yes, but we'll need to change it for many unrelated reasons. I would like it better to have a developer documentation rendered by sphinx that would print this example instead of having it hard coded in place. |
||
|
|
||
|
|
||
| def traverse_subclasses(cls: type) -> Iterator[type]: | ||
| yield cls | ||
| for subcls in cls.__subclasses__(): | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.