Skip to content

fix: OPTIC-945: Improve the bundling strategy and ship a single entrypoint with a common vendor chunk across all libs #6152

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

Merged
merged 98 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 90 commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
282a181
chore: Move the FE builds to strictly create one entrypoint and utili…
bmartel May 9, 2024
c13ab41
remove the scripts to set EDITOR and DM assets
bmartel May 9, 2024
2b446a6
fix nx
bmartel Jul 25, 2024
562baa8
putting back the build command of each lib now that the deps are not …
bmartel Jul 26, 2024
b0785d9
Merge branch 'develop' into fb-optic-945
yyassi-heartex Jul 26, 2024
c976c83
generating common ui lib
bmartel Jul 26, 2024
e6edc50
fixing tsconfig
bmartel Jul 26, 2024
f0301cb
splitting the build
yyassi-heartex Jul 26, 2024
4167169
making dynamic imports work
bmartel Jul 26, 2024
1554465
fix button conflicts
bmartel Jul 29, 2024
eac1053
fix label conflicts
bmartel Jul 29, 2024
e9d43b9
fixing pagination
yyassi-heartex Jul 29, 2024
801901e
Merge branch 'fb-optic-945' of github.com:heartexlabs/label-studio in…
yyassi-heartex Jul 29, 2024
295c82e
fixing outliner
yyassi-heartex Jul 29, 2024
b412d14
cleaning up lsf buttons usage
yyassi-heartex Jul 29, 2024
595dd49
addressing spinner issue
yyassi-heartex Jul 29, 2024
7b6d371
cleaning up LSF and DM components
yyassi-heartex Jul 29, 2024
8e13749
Merge branch 'fb-optic-945' of github.com:HumanSignal/label-studio in…
bmartel Jul 29, 2024
330a0e0
fix editor dropdown, radio-group and pagination conflicts
bmartel Jul 29, 2024
a96ddb6
fix dm pagination to take same approach as other deconflict component…
bmartel Jul 29, 2024
f0542a2
fix dm tabs
bmartel Jul 29, 2024
78f89c0
fix dm dropdown
bmartel Jul 29, 2024
cfe887e
fix watch command
bmartel Jul 29, 2024
abd8b67
cleaning up some child components for LSF and DM
yyassi-heartex Jul 29, 2024
b7ed9b0
Merge branch 'fb-optic-945' of github.com:heartexlabs/label-studio in…
yyassi-heartex Jul 29, 2024
f4b6f40
cleaning up minor differences
yyassi-heartex Jul 29, 2024
354c1dc
cleaning out long standing console.log
yyassi-heartex Jul 29, 2024
08a9147
cleaning up radio-groups
yyassi-heartex Jul 29, 2024
74e36b4
fixing DM dropdown
yyassi-heartex Jul 29, 2024
7af7ba3
fix bundle strategy to use common chunk vendor
bmartel Jul 30, 2024
040a6eb
fix comment
bmartel Jul 30, 2024
0dfe6f2
fix webhooks add button padding and spacing
bmartel Jul 30, 2024
27a29b2
fix preview loading
bmartel Jul 30, 2024
6becba1
turn off the local FF for memory leak fix as it is not needed and col…
bmartel Jul 30, 2024
9b93c7a
cleaning up LS Pagination
yyassi-heartex Jul 30, 2024
a1a8d6b
Merge remote-tracking branch 'origin/develop' into fb-optic-945
bmartel Jul 30, 2024
74588d7
Merge branch 'fb-optic-945' of github.com:HumanSignal/label-studio in…
bmartel Jul 30, 2024
c022f6f
fix all_urls.json to remove the unused frontend js/css urls
bmartel Jul 30, 2024
786c2a7
re-establish the test/dev build of LSF standalone
bmartel Jul 30, 2024
c3a58a7
outliner old - fixed
yyassi-heartex Jul 30, 2024
52307cb
Merge branch 'fb-optic-945' of github.com:heartexlabs/label-studio in…
yyassi-heartex Jul 30, 2024
cf2edd0
outliner old standardizaation with prefix
yyassi-heartex Jul 30, 2024
1e84503
fixing unit tests with updated class names
yyassi-heartex Jul 30, 2024
41a8c47
fixing e2e test
yyassi-heartex Jul 30, 2024
11a1ec2
outliner whack-a-mole + e2e test
yyassi-heartex Jul 30, 2024
17f613a
fix tree node tests
bmartel Jul 30, 2024
17b10d2
image-list e2e
yyassi-heartex Jul 30, 2024
fa8f0ff
Merge branch 'fb-optic-945' of github.com:heartexlabs/label-studio in…
yyassi-heartex Jul 30, 2024
fbd7938
fix pagination tests
bmartel Jul 30, 2024
c65c08e
fix pagination tests
bmartel Jul 30, 2024
3e63ad6
more pagination test update
yyassi-heartex Jul 30, 2024
047af6d
fix remaining lsf integration tests
bmartel Jul 30, 2024
2234492
Merge branch 'fb-optic-945' of github.com:HumanSignal/label-studio in…
bmartel Jul 30, 2024
79cb81c
fix outliner e2e
bmartel Jul 31, 2024
00c00ef
need this to stay until LSE updates as well
bmartel Jul 31, 2024
8bdd6e2
Update label_studio/templates/base.html
bmartel Jul 31, 2024
b629c44
fix script inclusions
bmartel Jul 31, 2024
8e2ff52
Merge remote-tracking branch 'origin/fb-optic-945' into fb-optic-945
bmartel Jul 31, 2024
fc44a13
fix paragraphs e2e
bmartel Jul 31, 2024
b39eca6
fixing labels e2e test
yyassi-heartex Jul 31, 2024
f194fe3
control bar element selection tweaked to use cn
yyassi-heartex Jul 31, 2024
b06dcdd
leveraging bem to handle class prefix
yyassi-heartex Jul 31, 2024
f1eb59c
removing the script defs as they are now included as temp overrides i…
bmartel Jul 31, 2024
f1e9ea8
mainContent cn inside the class component
yyassi-heartex Jul 31, 2024
914d1f2
updating to use the unified prefix
yyassi-heartex Jul 31, 2024
95c01c1
removing need for global in 1 spot
yyassi-heartex Jul 31, 2024
f23e9f0
moving className declaration up in the component class
yyassi-heartex Jul 31, 2024
52def72
toClassName doesnt add the .
yyassi-heartex Jul 31, 2024
53d68d0
fixing selectors
yyassi-heartex Jul 31, 2024
404b1a1
Merge branch 'develop' into 'fb-optic-945'
yyassi-heartex Aug 1, 2024
6869d9f
fix dm data view conflict
bmartel Aug 1, 2024
30cdd72
Merge branch 'fb-optic-945' of github.com:HumanSignal/label-studio in…
bmartel Aug 1, 2024
57f0c41
fix conflicts in toggle, tag, and checkbox
bmartel Aug 1, 2024
92e5ffe
fix conflicts in menu
bmartel Aug 1, 2024
75ef2ef
fix filters sidebar conflict
bmartel Aug 1, 2024
de58198
fix menu and textarea conflicts
bmartel Aug 1, 2024
8a602ff
put back this experiment as it still needs to exist for LSE until fur…
bmartel Aug 1, 2024
7bc206e
Merge remote-tracking branch 'origin/develop' into fb-optic-945
bmartel Aug 2, 2024
62be4d6
don't need the standalone editor setup in development mode of the app
bmartel Aug 2, 2024
8f0feec
fix badge conflict in dm
bmartel Aug 2, 2024
8152afc
Merge branch 'develop' into fb-optic-945
yyassi-heartex Aug 7, 2024
3ab7d53
clearing out some minor exceptions + making sure we use cn where poss…
yyassi-heartex Aug 7, 2024
73fc352
e2e and lint fixes
yyassi-heartex Aug 7, 2024
ae47396
fixing integration test
yyassi-heartex Aug 7, 2024
36ea728
switching default fflag_fix_front_lsdv_4620_memory_leaks_100723_short…
yyassi-heartex Aug 8, 2024
d428c41
fixed an error affecting submit dropdown trigger
yyassi-heartex Aug 8, 2024
7d893eb
addressing an issue around component overlap affecting UserPic
yyassi-heartex Aug 8, 2024
6956ccf
Merge branch 'develop' into 'fb-optic-945'
yyassi-heartex Aug 8, 2024
1e8fca5
forcing update in LSE by pushing dist folder changes
yyassi-heartex Aug 8, 2024
f79d4a0
Update label_studio/templates/base.html
yyassi-heartex Aug 9, 2024
15a2e74
applying changes based on feedback
yyassi-heartex Aug 9, 2024
629d7c4
Merge branch 'fb-optic-945' of github.com:heartexlabs/label-studio in…
yyassi-heartex Aug 9, 2024
dd024ce
adding stale flag
yyassi-heartex Aug 9, 2024
9505f71
minor fix addresses big boom
yyassi-heartex Aug 9, 2024
db8ac02
lint cleanup
yyassi-heartex Aug 9, 2024
4c9a72c
minor tweak to get unit tests to work
yyassi-heartex Aug 9, 2024
7134200
Merge branch 'develop' into fb-optic-945
yyassi-heartex Aug 12, 2024
d9874d4
removing dist files that are no longer being used
yyassi-heartex Aug 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import json
import os
import re
from urllib.parse import quote

import jira
import requests
from github import Github
from jira import JIRA
from urllib.parse import quote

COMMIT_PATTERN = re.compile(r'^(\w*):\s*(.*?)?:\s*(.*?)\s*(\(#(\d+)\))?$')

Expand Down
12 changes: 0 additions & 12 deletions deploy/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,6 @@ http {
alias /label-studio/label_studio/core/static_build/;
}

# Frontend react
# Source: https://github.com/heartexlabs/label-studio-frontend
location /label-studio-frontend/ {
alias /label-studio/web/dist/libs/editor/;
}

# Data Manager
# Source: https://github.com/heartexlabs/dm2
location /dm/ {
alias /label-studio/web/dist/libs/datamanager/;
}

# LabelStudio frontend
# Source: https://github.com/heartexlabs/label-studio/blob/HEAD/label_studio/frontend/src
location /react-app/ {
Expand Down
14 changes: 0 additions & 14 deletions label_studio/core/utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,20 +207,6 @@ def paginator_help(objects_name, tag):
)


def find_editor_files():
"""Find label studio files"""

# playground uses another LSF build
prefix = '/label-studio/'
editor_dir = settings.EDITOR_ROOT

# find editor files to include in html
editor_js = [prefix + f for f in os.listdir(editor_dir) if f.endswith('.js')]
editor_css = [prefix + f for f in os.listdir(editor_dir) if f.endswith('.css')]

return {'editor_js': editor_js, 'editor_css': editor_css}


def string_is_url(url):
try:
url_validator(url)
Expand Down
2 changes: 0 additions & 2 deletions label_studio/data_manager/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""This file and its contents are licensed under the Apache License 2.0. Please see the included NOTICE for copyright information and LICENSE for a copy of the license.
"""
from core.utils.common import find_editor_files
from core.version import get_short_version
from django.contrib.auth.decorators import login_required
from django.shortcuts import render
Expand All @@ -9,5 +8,4 @@
@login_required
def task_page(request, pk):
response = {'version': get_short_version()}
response.update(find_editor_files())
return render(request, 'base.html', response)
2 changes: 1 addition & 1 deletion label_studio/feature_flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -4135,7 +4135,7 @@
},
"fflag_fix_front_lsdv_4620_memory_leaks_100723_short": {
"key": "fflag_fix_front_lsdv_4620_memory_leaks_100723_short",
"on": true,
"on": false,
"prerequisites": [],
"targets": [],
"contextTargets": [],
Expand Down
33 changes: 17 additions & 16 deletions label_studio/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,19 @@
<meta name="msapplication-navbutton-color" content="#272727"> <!-- Windows Phone -->
<meta name="apple-mobile-web-app-status-bar-style" content="#272727"> <!-- iOS Safari -->

<!-- Preload fonts -->
<link rel="preload" href="{{settings.HOSTNAME}}{% static 'fonts/Figtree-Regular.ttf' %}" type="font" crossorigin="anonymous">
<link rel="preload" href="{{settings.HOSTNAME}}{% static 'fonts/Figtree-SemiBold.ttf' %}" type="font" crossorigin="anonymous">

<!-- CSS -->
<link href="{{settings.HOSTNAME}}{% static 'images/favicon.ico' %}" rel="shortcut icon"/>
<link href="{{settings.HOSTNAME}}{% static 'css/uikit.css' %}" rel="stylesheet">
<link href="{{settings.HOSTNAME}}{% static 'css/main.css' %}" rel="stylesheet">
<link href="{{settings.HOSTNAME}}/static/fonts/roboto/roboto.css" rel="stylesheet">
<link href="{{settings.HOSTNAME}}/react-app/main.css?v={{ versions.backend.commit }}" rel="stylesheet">

<script src="{{settings.HOSTNAME}}{% static 'js/jquery.min.js' %}"></script>
<script src="{{settings.HOSTNAME}}{% static 'js/helpers.js' %}"></script>

{% block app-scripts %}
<script nonce="{{request.csp_nonce}}">
EDITOR_JS = `{{settings.HOSTNAME}}/label-studio-frontend/main.js?v={{ versions.lsf.commit }}`;
EDITOR_CSS = `{{settings.HOSTNAME}}/label-studio-frontend/main.css?v={{ versions.lsf.commit }}`;
DM_JS = `{{settings.HOSTNAME}}/dm/main.js?v={{ versions.dm2.commit }}`;
DM_CSS = `{{settings.HOSTNAME}}/dm/main.css?v={{ versions.dm2.commit }}`;
</script>
{% endblock %}


<script
src="https://browser.sentry-cdn.com/5.17.0/bundle.min.js"
integrity="sha384-lowBFC6YTkvMIWPORr7+TERnCkZdo5ab00oH5NkFLeQUAmBTLGwJpFjF6djuxJ/5"
Expand All @@ -49,7 +43,6 @@
{% endblock %}

{% block head-toast %}
<script src="{{settings.HOSTNAME}}{% static 'js/Toast.min.js' %}"></script>
<link href="{{settings.HOSTNAME}}{% static 'css/Toast.min.css' %}" rel="stylesheet">
{% endblock %}

Expand Down Expand Up @@ -119,21 +112,29 @@
</script>

{% block app-js %}
<script src="{{settings.HOSTNAME}}/react-app/runtime.js?v={{ versions.backend.commit }}"></script>
{% comment %}
NOTE: purposely setting this to not cache using backend commit as we do not intend this to change frequently.
If for any reason we need to invalidate the cache, we can do so by changing the version number.
{% endcomment %}
<script src="{{settings.HOSTNAME}}/react-app/vendor.js?v=1"></script>
<script src="{{settings.HOSTNAME}}/react-app/main.js?v={{ versions.backend.commit }}"></script>
{% endblock %}

<div id="dynamic-content">
{% block bottomjs %}
<script src="{{settings.HOSTNAME}}{% static 'js/jquery.min.js' %}"></script>
<script src="{{settings.HOSTNAME}}{% static 'js/helpers.js' %}"></script>
<script src="{{settings.HOSTNAME}}{% static 'js/Toast.min.js' %}"></script>
<script nonce="{{request.csp_nonce}}">
applyCsrf();

$('.message .close').on('click', function () {
$(this).closest('.message').transition('fade');
});
</script>
{% endblock %}

{% block bottomjs %}
{% endblock %}

<div id="dynamic-content">
{% block storage-persistence %}
<script nonce="{{request.csp_nonce}}">
{# storage persistence #}
Expand Down
15 changes: 0 additions & 15 deletions web/apps/labelstudio/src/app/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { initSentry } from "../config/Sentry";
import { ApiProvider } from "../providers/ApiProvider";
import { AppStoreProvider } from "../providers/AppStoreProvider";
import { ConfigProvider } from "../providers/ConfigProvider";
import { LibraryProvider } from "../providers/LibraryProvider";
import { MultiProvider } from "../providers/MultiProvider";
import { ProjectProvider } from "../providers/ProjectProvider";
import { RoutesProvider } from "../providers/RoutesProvider";
Expand Down Expand Up @@ -52,19 +51,6 @@ window.LSH = browserHistory;
initSentry(browserHistory);

const App = ({ content }) => {
const libraries = {
lsf: {
scriptSrc: window.EDITOR_JS,
cssSrc: window.EDITOR_CSS,
checkAvailability: () => !!window.LabelStudio,
},
dm: {
scriptSrc: window.DM_JS,
cssSrc: window.DM_CSS,
checkAvailability: () => !!window.DataManager,
},
};

return (
<ErrorBoundary>
<Router history={browserHistory}>
Expand All @@ -73,7 +59,6 @@ const App = ({ content }) => {
<AppStoreProvider key="app-store" />,
<ApiProvider key="api" />,
<ConfigProvider key="config" />,
<LibraryProvider key="lsf" libraries={libraries} />,
<RoutesProvider key="rotes" />,
<ProjectProvider key="project" />,
<ToastProvider key="toast" />,
Expand Down
33 changes: 17 additions & 16 deletions web/apps/labelstudio/src/config/Sentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,23 @@ import { Integrations } from "@sentry/tracing";
import { Route } from "react-router-dom";

export const initSentry = (history: RouterHistory) => {
setTags();

Sentry.init({
dsn: "https://5f51920ff82a4675a495870244869c6b@o227124.ingest.sentry.io/5838868",
integrations: [
new Integrations.BrowserTracing({
routingInstrumentation: ReactSentry.reactRouterV5Instrumentation(history),
}),
],
environment: process.env.NODE_ENV,
// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 0.25,
release: getVersion(),
});
if (APP_SETTINGS.debug === false) {
setTags();
Sentry.init({
dsn: "https://5f51920ff82a4675a495870244869c6b@o227124.ingest.sentry.io/5838868",
integrations: [
new Integrations.BrowserTracing({
routingInstrumentation: ReactSentry.reactRouterV5Instrumentation(history),
}),
],
environment: process.env.NODE_ENV,
// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 0.25,
release: getVersion(),
});
}
};

const setTags = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,9 @@ styled_scroll()
.editor > .common
flex: 1
max-width: 100%
:global(.lsf-main-view__annotation)
padding: 0
.main-view
&__annotation
padding: 0

// super hack for LSF regions width on sideBottom layout
div[class^=App_menu]>div
Expand Down
91 changes: 45 additions & 46 deletions web/apps/labelstudio/src/pages/CreateProject/Config/Preview.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useCallback, useEffect, useMemo, useRef } from "react";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { Spinner } from "../../../components";
import { useLibrary } from "../../../providers/LibraryProvider";
import { cn } from "../../../utils/bem";
import { FF_DEV_3617, isFF } from "../../../utils/feature-flags";
import "./Config.styl";
Expand All @@ -10,9 +9,11 @@ import { useAPI } from "../../../providers/ApiProvider";

const configClass = cn("configure");

const loadDependencies = async () => import("@humansignal/editor");

export const Preview = ({ config, data, error, loading, project }) => {
const LabelStudio = useLibrary("lsf");
const lsf = useRef(null);
const [resolvingEditor] = useState(loadDependencies);
const rootRef = useRef();
const api = useAPI();

Expand Down Expand Up @@ -48,48 +49,44 @@ export const Preview = ({ config, data, error, loading, project }) => {
return config ?? EMPTY_CONFIG;
}, [config]);

const initLabelStudio = useCallback(
(config, task) => {
if (!LabelStudio) return;
if (!task.data) return;

console.info("Initializing LSF preview", { config, task });

try {
const lsf = new window.LabelStudio(rootRef.current, {
config,
task,
interfaces: ["side-column"],
// with SharedStore we should use more late event
[isFF(FF_DEV_3617) ? "onStorageInitialized" : "onLabelStudioLoad"](LS) {
LS.settings.bottomSidePanel = true;

const initAnnotation = () => {
const as = LS.annotationStore;
const c = as.createAnnotation();

as.selectAnnotation(c.id);
};

if (isFF(FF_DEV_3617)) {
// and even then we need to wait a little even after the store is initialized
setTimeout(initAnnotation);
} else {
initAnnotation();
}
},
});

lsf.on("presignUrlForProject", onPresignUrlForProject);

return lsf;
} catch (err) {
console.error(err);
return null;
}
},
[LabelStudio],
);
const initLabelStudio = useCallback(async (config, task) => {
if (!task.data) return;

await resolvingEditor;

try {
const lsf = new window.LabelStudio(rootRef.current, {
config,
task,
interfaces: ["side-column"],
// with SharedStore we should use more late event
[isFF(FF_DEV_3617) ? "onStorageInitialized" : "onLabelStudioLoad"](LS) {
LS.settings.bottomSidePanel = true;

const initAnnotation = () => {
const as = LS.annotationStore;
const c = as.createAnnotation();

as.selectAnnotation(c.id);
};

if (isFF(FF_DEV_3617)) {
// and even then we need to wait a little even after the store is initialized
setTimeout(initAnnotation);
} else {
initAnnotation();
}
},
});

lsf.on("presignUrlForProject", onPresignUrlForProject);

return lsf;
} catch (err) {
console.error(err);
return null;
}
}, []);

useEffect(() => {
const opacity = loading || error ? 0.6 : 1;
Expand All @@ -100,7 +97,9 @@ export const Preview = ({ config, data, error, loading, project }) => {

useEffect(() => {
if (!lsf.current) {
lsf.current = initLabelStudio(currentConfig, currentTask);
initLabelStudio(currentConfig, currentTask).then((ls) => {
lsf.current = ls;
});
}

return () => {
Expand Down
Loading
Loading