-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[KED-3002] Live update runs list from subscription (#703)
- Loading branch information
Showing
14 changed files
with
275 additions
and
17 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -9,3 +9,4 @@ addopts=--verbose -ra | |
--ignore package/tests | ||
--no-cov-on-fail | ||
-ra | ||
--asyncio-mode auto |
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
102 changes: 102 additions & 0 deletions
102
package/tests/test_api/test_graphql/test_subscriptions.py
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,102 @@ | ||
import json | ||
|
||
from kedro_viz.api.graphql import schema | ||
from kedro_viz.models.experiments_tracking import RunModel | ||
|
||
|
||
class TestRunsAddedSubscription: | ||
async def test_runs_added_subscription_with_no_existing_run( | ||
self, data_access_manager_with_no_run | ||
): | ||
query = """ | ||
subscription { | ||
runsAdded { | ||
id | ||
bookmark | ||
gitSha | ||
timestamp | ||
title | ||
} | ||
} | ||
""" | ||
|
||
# start subscription | ||
subscription = await schema.subscribe(query) | ||
|
||
example_new_run_id = "test_id" | ||
run = RunModel( | ||
id=example_new_run_id, | ||
blob=json.dumps( | ||
{ | ||
"session_id": example_new_run_id, | ||
"cli": {"command_path": "kedro run"}, | ||
} | ||
), | ||
) | ||
data_access_manager_with_no_run.runs.add_run(run) | ||
|
||
# assert subscription result | ||
async for result in subscription: | ||
assert not result.errors | ||
assert result.data == { | ||
"runsAdded": [ | ||
{ | ||
"id": example_new_run_id, | ||
"bookmark": False, | ||
"gitSha": None, | ||
"timestamp": example_new_run_id, | ||
"title": example_new_run_id, | ||
} | ||
] | ||
} | ||
break | ||
|
||
async def test_runs_added_subscription_with_existing_runs( | ||
self, data_access_manager_with_runs | ||
): | ||
query = """ | ||
subscription { | ||
runsAdded { | ||
id | ||
bookmark | ||
gitSha | ||
timestamp | ||
title | ||
} | ||
} | ||
""" | ||
all_runs = data_access_manager_with_runs.runs.get_all_runs() | ||
assert all_runs | ||
|
||
# start subscription | ||
subscription = await schema.subscribe(query) | ||
|
||
# add a new run | ||
example_new_run_id = "new_run" | ||
run = RunModel( | ||
id=example_new_run_id, | ||
blob=json.dumps( | ||
{ | ||
"session_id": example_new_run_id, | ||
"cli": {"command_path": "kedro run"}, | ||
} | ||
), | ||
) | ||
data_access_manager_with_runs.runs.add_run(run) | ||
|
||
# assert subscription result | ||
async for result in subscription: | ||
assert not result.errors | ||
assert result.data == { | ||
"runsAdded": [ | ||
{ | ||
"id": example_new_run_id, | ||
"bookmark": False, | ||
"gitSha": None, | ||
"timestamp": example_new_run_id, | ||
"title": example_new_run_id, | ||
} | ||
] | ||
} | ||
assert data_access_manager_with_runs.runs.last_run_id == example_new_run_id | ||
break |
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
Oops, something went wrong.