-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
feat: OPTIC-1245: Allow HeidiTips to pull content updates live #6623
base: develop
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for label-studio-docs-new-theme canceled.
|
✅ Deploy Preview for heartex-docs canceled.
|
… max timeout expected on the client side
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #6623 +/- ##
===========================================
+ Coverage 76.65% 76.66% +0.01%
===========================================
Files 169 169
Lines 13844 13850 +6
===========================================
+ Hits 10612 10618 +6
Misses 3232 3232
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@@ -169,6 +170,21 @@ def samples_paragraphs(request): | |||
return HttpResponse(json.dumps(result), content_type='application/json') | |||
|
|||
|
|||
def heidi_tips(request): |
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.
any way we can make this optional? I'm concerned if an outage happens this will block pytest checks
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 point, I'm going to look at that because honestly we don't want this in any pytests as there is nothing to test but everything to possibly fail randomly which is not helpful.
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.
At the very least we'd want to mock the requests call.
@@ -169,6 +170,21 @@ def samples_paragraphs(request): | |||
return HttpResponse(json.dumps(result), content_type='application/json') | |||
|
|||
|
|||
def heidi_tips(request): | |||
"""Fetch live tips from github raw liveContent.json to avoid caching and client side CORS issues""" | |||
url = 'https://raw.githubusercontent.com/HumanSignal/label-studio/refs/heads/develop/web/apps/labelstudio/src/components/HeidiTips/liveContent.json' |
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.
are we sure that this domain have wide open CORS policy? asking just in case
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.
There is no CORS in backend code, CORS is a browser security policy to protect the user. This is why it must be proxied from the backend, otherwise this would only fail CORS in the browser all the time as GH does not set the proper headers to allow the call to succeed directly from the browser.
) | ||
|
||
# Raise an exception for bad status codes to avoid caching | ||
response.raise_for_status() |
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.
what would happen if we can't load tips? this should not be a blocker for the app
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.
In that case it just uses whatever loaded most recent in localStorage, and if never loaded from the endpoint it goes to the default which is what we were already using.
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.
We won't block for errors, or even timeouts. I put a strict timeout on the call as I didn't want this loading slow or showing nothing ever. I wanted it to just get and update the data as naturally as possible where the user doesn't notice it's happening at all. As well, for airgapped environments we cannot make that call anyways so it will fail fast and the defaults are all that will be provided.
PR fulfills these requirements
[fix|feat|ci|chore|doc]: TICKET-ID: Short description of change made
ex.fix: DEV-XXXX: Removed inconsistent code usage causing intermittent errors
Change has impacts in these area(s)
(check all that apply)
Describe the reason for change
To ensure HeidiTips can be up to date with the code over time we are going to host the contents in a raw json file within the repository similar to docs. That way just like docs we can align and amend without users having to update their LabelStudio version.
Which logical domain(s) does this change affect?
HeidiTips