-
Notifications
You must be signed in to change notification settings - Fork 196
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
refactor: reduce duplicate workflow update calls #2129
Conversation
69aede9
to
9499741
Compare
5f2005c
to
36b0b77
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2129 +/- ##
=======================================
Coverage 94.95% 94.95%
=======================================
Files 191 191
Lines 20608 20618 +10
Branches 1863 1867 +4
=======================================
+ Hits 19568 19578 +10
Misses 777 777
Partials 263 263
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
8635c6e
to
96f905b
Compare
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.
approved
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.
Update version bump. The rest look good.
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.
great job
96f905b
to
112c8ee
Compare
Previously, anything that requested a workflow would cause a workflow update and refresh. This changes that logic to: 1. Only init workflow API once through load of ORA block (reloaded each time the page / ORA MFE load). 2. On load, update workflow. 3. Calls for workflow info reference cached workflow. 4. Try to update workflow when none found. Note we can still manually refresh workflow info with either get_workflow_info or update_workflow_status.
Within the new MFE calls, we need to consistently leverage the API version of workflow calls to take advantage of the cached workflow state.
112c8ee
to
969ae6e
Compare
* feat: remove duplicate workflow lookups Previously, anything that requested a workflow would cause a workflow update and refresh. This changes that logic to: 1. Only init workflow API once through load of ORA block (reloaded each time the page / ORA MFE load). 2. On load, update workflow. 3. Calls for workflow info reference cached workflow. 4. Try to update workflow when none found. Note we can still manually refresh workflow info with either get_workflow_info or update_workflow_status. * refactor: call the API version of get_workflow_info Within the new MFE calls, we need to consistently leverage the API version of workflow calls to take advantage of the cached workflow state. * docs: typo fixes and docstring updates * feat: remove no-longer-needed function_trace * fix: cache workflow on update_workflow_status * fix: remove unnecessary update in tests * style: more consistent return statements * test: refactor mocking to fix tests * chore: bump ORA to 6.0.28
TL;DR - Reduce the number of duplicate workflow updates from common ORA data load patterns.
What changed?
Asking for a
workflow
from theWorkflowAPI
calledget_workflow_info
which would update the workflow before fetching workflow information. Since many of the other fields onWorkflowAPI
referenced thatworkflow
property, asking for any of this information would cause additional refreshes of the workflow, needlessly.Loading the ORA MFE, I was averaging over 20 workflow refreshes and a local load time of ~500ms.
This PR begins to add a few refactors aimed at reducing how frequently we call a workflow update to (ideally) once per user action, calling cached workflow info any time between those actions.
workflow
property onWorkflowAPI
to return last-fetched workflow data instead of re-updating/fetching.workflow
onWorkflowAPI
init (e.g. XBlock / MFE load)WorkflowAPI
is initialized by memoizingworkflow_data
onOpenassessmentBlock
andORADataAccessor
on fetch / update.workflow
when a workflow is not present (this is not ideal from a performance standpoint but appears to fix a large number of tests).Other changes:
grades
accessor fromWorkflowAPI
.NOTE that this does mean it is more possible to get stale workflows so it is up to each endpoint / caller to determine if they need to refresh the workflow state on a per-action basis.
Developer Checklist
Testing Instructions
Reviewer Checklist
Collectively, these should be completed by reviewers of this PR:
FYI: @openedx/content-aurora