Skip to content
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

[KED-3002] Live update runs list from subscription #703

Merged
merged 47 commits into from
Jan 19, 2022
Merged

Conversation

limdauto
Copy link
Collaborator

@limdauto limdauto commented Jan 18, 2022

Description

This PR adds the capability for the runs list to be automatically updated whenever there is a new Kedro run by the user.

Development notes

QA notes

Checklist

  • Read the contributing guidelines
  • Opened this PR as a 'Draft Pull Request' if it is work-in-progress
  • Updated the documentation to reflect the code changes
  • Added new entries to the RELEASE.md file
  • Added tests to cover my changes

Copy link
Member

@tynandebold tynandebold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JS looks good.

I've added some code style thoughts and one other on a file-structure change, but none of them are too important or blocking.

src/components/experiment-wrapper/experiment-wrapper.js Outdated Show resolved Hide resolved
src/apollo/queries.js Outdated Show resolved Hide resolved
src/apollo/config.js Outdated Show resolved Hide resolved
@limdauto
Copy link
Collaborator Author

@tynandebold thanks. I have adjusted the PR based on your comment.

Copy link
Contributor

@antonymilne antonymilne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks excellent, so far as I understand it 😀

Comment on lines +262 to +269
yield [
format_run(
run.id,
json.loads(run.blob),
data_access_manager.runs.get_user_run_details(run.id),
)
for run in new_runs
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use format_runs here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, such great point. I forgot.

: window.location.host;

const wsLink = new WebSocketLink({
uri: `ws://${wsHost}/graphql`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I go to ws://localhost:4141/graphql does that do anything interesting?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, not in dev. no graphql server there.

self._db_session_class() # type: ignore
.query(RunModel)
.order_by(RunModel.id.desc())
.all()
)
if all_runs:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When does get_all_runs get called? Just wondering why this is the right place to update the last_run_id.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e.g. it already gets updated in runs_added.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the first call when user visits experimentation tracking tab.

@@ -71,6 +76,16 @@ def get_user_run_details(self, run_id: str) -> Optional[UserRunDetailsModel]:
.first()
)

@check_db_session
def get_new_runs(self) -> Optional[Iterable[RunModel]]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: is there some neater way of writing this or combining with get_all_runs, given that when self.last_run_id is None, it's identical to get_all_runs. Do we want two separate functions, get_all_runs and get_new_runs rather than something like get_runs(new_only=False)? No problem with how it is now though, just wondering.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to keep these interfaces separate in case we need to add more logic to each use case. It's an old habit, e.g. if we end up caching all runs somewhere we won't need to go to the DB to fetch them. We will almost always have to do it for new runs.

Copy link
Contributor

@rashidakanchwala rashidakanchwala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great!!

Base automatically changed from feat/breakup-repositories to main January 19, 2022 15:05
Copy link
Contributor

@studioswong studioswong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is brilliant thank you @limdauto !

RELEASE.md Outdated
@@ -11,6 +11,7 @@ Please follow the established format:
## Major features and improvements

- Create the toggle-bookmark journey that allows bookmarking runs and displaying them as a separate list. (#689)
- Auto-update experiment runs list whenever user has a new Kedro run (#703)
Copy link
Contributor

@studioswong studioswong Jan 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion:

Suggested change
- Auto-update experiment runs list whenever user has a new Kedro run (#703)
- Set up web socket and subscription endpoint for auto update of experiment runs list on new Kedro runs (#703)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd really like to leave out implementation details from release note. IMHO user doesn't care whether it uses websocket or anything else.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha yea I kinda knew you would mention this - the main reason I am suggesting this is more for Kedro-viz devs in differentiating this from the previous auto-reload feature, for referencing this release incorporating the actual setup of the web socket mechanism and subscription endpoint.

We can leave out web socket but would still be good to mention enabling subscription in this case ( which web sockets is implied I guess)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Updated.

@limdauto limdauto merged commit d02270d into main Jan 19, 2022
@limdauto limdauto deleted the feat/subscription branch January 19, 2022 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants