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

feat: OPTIC-1245: Allow HeidiTips to pull content updates live #6623

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from

Conversation

bmartel
Copy link
Contributor

@bmartel bmartel commented Nov 8, 2024

PR fulfills these requirements

  • Commit message(s) and PR title follows the format [fix|feat|ci|chore|doc]: TICKET-ID: Short description of change made ex. fix: DEV-XXXX: Removed inconsistent code usage causing intermittent errors
  • Tests for the changes have been added/updated (for bug fixes/features)
  • Docs have been added/updated (for bug fixes/features)
  • Best efforts were made to ensure docs/code are concise and coherent (checked for spelling/grammatical errors, commented out code, debug logs etc.)
  • Self-reviewed and ran all changes on a local instance (for bug fixes/features)

Change has impacts in these area(s)

(check all that apply)

  • Product design
  • Backend (Database)
  • Backend (API)
  • Frontend

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

Copy link

netlify bot commented Nov 8, 2024

Deploy Preview for label-studio-docs-new-theme canceled.

Name Link
🔨 Latest commit 948947e
🔍 Latest deploy log https://app.netlify.com/sites/label-studio-docs-new-theme/deploys/6733e12b7d99d0000711c094

@github-actions github-actions bot added the feat label Nov 8, 2024
Copy link

netlify bot commented Nov 8, 2024

Deploy Preview for heartex-docs canceled.

Name Link
🔨 Latest commit 948947e
🔍 Latest deploy log https://app.netlify.com/sites/heartex-docs/deploys/6733e12bda2a7a000863ec76

Copy link

codecov bot commented Nov 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.66%. Comparing base (f33a1d1) to head (948947e).
Report is 3 commits behind head on develop.

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              
Flag Coverage Δ
pytests 76.66% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -169,6 +170,21 @@ def samples_paragraphs(request):
return HttpResponse(json.dumps(result), content_type='application/json')


def heidi_tips(request):
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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'
Copy link
Collaborator

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

Copy link
Contributor Author

@bmartel bmartel Nov 12, 2024

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()
Copy link
Collaborator

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

@bmartel bmartel Nov 12, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants