Skip to content

Commit

Permalink
Merge branch 'develop' into optic-1353
Browse files Browse the repository at this point in the history
  • Loading branch information
bmartel committed Nov 19, 2024
2 parents 78c9b3b + 2922013 commit 014e4dd
Show file tree
Hide file tree
Showing 80 changed files with 894 additions and 790 deletions.
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.github/ @HumanSignal/devops
deploy/ @HumanSignal/devops
Dockerfile* @HumanSignal/devops
docker-compose* @HumanSignal/devops
docs/.npmignore @hlomzik @Gondragos @nicholasrq
docs/package.json @hlomzik @Gondragos @nicholasrq
docs/yarn.lock @hlomzik @Gondragos @nicholasrq
2 changes: 1 addition & 1 deletion .github/workflows/test_conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
ref: ${{ inputs.head_sha }}

- name: Setup Conda
uses: conda-incubator/setup-miniconda@v3.0.4
uses: conda-incubator/setup-miniconda@v3.1.0
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ jobs:

- name: Upload coverage to Codecov
if: ${{ github.event.pull_request.head.repo.fork == false && github.event.pull_request.user.login != 'dependabot[bot]' }}
uses: codecov/codecov-action@v4.6.0
uses: codecov/codecov-action@v5.0.2
with:
name: codecov-python-${{ matrix.python-version }}
flags: pytests
Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Run Django dev server with Sqlite
run-dev:
DJANGO_DB=sqlite LOG_DIR=tmp DEBUG=true LOG_LEVEL=DEBUG DJANGO_SETTINGS_MODULE=core.settings.label_studio python label_studio/manage.py runserver
DJANGO_DB=sqlite LOG_DIR=tmp DEBUG=true LOG_LEVEL=DEBUG DJANGO_SETTINGS_MODULE=core.settings.label_studio poetry run python label_studio/manage.py runserver

# Run Django dev migrations with Sqlite
migrate-dev:
DJANGO_DB=sqlite LOG_DIR=tmp DEBUG=true LOG_LEVEL=DEBUG DJANGO_SETTINGS_MODULE=core.settings.label_studio python label_studio/manage.py migrate
DJANGO_DB=sqlite LOG_DIR=tmp DEBUG=true LOG_LEVEL=DEBUG DJANGO_SETTINGS_MODULE=core.settings.label_studio poetry run python label_studio/manage.py migrate

# Run Django dev make migrations with Sqlite
makemigrations-dev:
DJANGO_DB=sqlite LOG_DIR=tmp DEBUG=true LOG_LEVEL=DEBUG DJANGO_SETTINGS_MODULE=core.settings.label_studio python label_studio/manage.py makemigrations
DJANGO_DB=sqlite LOG_DIR=tmp DEBUG=true LOG_LEVEL=DEBUG DJANGO_SETTINGS_MODULE=core.settings.label_studio poetry run python label_studio/manage.py makemigrations

# Run Django dev shell environment with Sqlite
shell-dev:
DJANGO_DB=sqlite LOG_DIR=tmp DEBUG=true LOG_LEVEL=DEBUG DJANGO_SETTINGS_MODULE=core.settings.label_studio python label_studio/manage.py shell_plus
DJANGO_DB=sqlite LOG_DIR=tmp DEBUG=true LOG_LEVEL=DEBUG DJANGO_SETTINGS_MODULE=core.settings.label_studio poetry run python label_studio/manage.py shell_plus

env-dev-setup:
if [ ! -f .env ]; then \
Expand Down Expand Up @@ -72,7 +72,7 @@ docker-testing-shell:

# Update urls
update-urls:
DJANGO_DB=sqlite LOG_DIR=tmp DEBUG=true LOG_LEVEL=DEBUG DJANGO_SETTINGS_MODULE=core.settings.label_studio python label_studio/manage.py show_urls --format pretty-json > ./label_studio/core/all_urls.json
DJANGO_DB=sqlite LOG_DIR=tmp DEBUG=true LOG_LEVEL=DEBUG DJANGO_SETTINGS_MODULE=core.settings.label_studio poetry run python label_studio/manage.py show_urls --format pretty-json > ./label_studio/core/all_urls.json

# Format changed files on branch
fmt:
Expand All @@ -96,4 +96,4 @@ configure-hooks:

# Generate swagger.json
generate-swagger:
DJANGO_DB=sqlite LOG_DIR=tmp DEBUG=true LOG_LEVEL=DEBUG DJANGO_SETTINGS_MODULE=core.settings.label_studio python label_studio/manage.py generate_swagger swagger.json
DJANGO_DB=sqlite LOG_DIR=tmp DEBUG=true LOG_LEVEL=DEBUG DJANGO_SETTINGS_MODULE=core.settings.label_studio poetry run python label_studio/manage.py generate_swagger swagger.json
2 changes: 2 additions & 0 deletions docs/scripts/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
var breadcrumb = require("./breadcrumb")(hexo);
var removeContent = require("./removeContent")(hexo);
var replaceContent = require("./replaceContent")(hexo);
var tableOfContent = require("./tableOfContent")(hexo);

hexo.extend.helper.register("breadcrumb", breadcrumb, { async: true });
hexo.extend.helper.register("removeContent", removeContent, { async: true });
hexo.extend.helper.register("replaceContent", replaceContent, { async: true });
hexo.extend.helper.register("tableOfContent", tableOfContent, { async: true });
24 changes: 24 additions & 0 deletions docs/scripts/tableOfContent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const { tocObj } = require('hexo-util');

module.exports = function () {
return function tableOfContent(str, options = {}) {

options = Object.assign({
min_depth: 1,
max_depth: 6,
}, options);

const data = tocObj(str, { min_depth: options.min_depth, max_depth: options.max_depth });


if (!data.length) return '';

let html = '';

data.forEach(item => {
html += `<li class="toc-list-level-${item.level}"><a href="#${item.id}">${item.text}</a></li>`
});

return `<ol class="toc-list">${html}</ol>`;
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This project will help you to get up your LLM to the ChatGPT quality level throu

Through ranking multiple responses based on quality, you can train a reward model that effectively captures human preferences. This reward model plays a crucial role in Reinforcement Learning, optimizing the performance of the fine-tuned foundational model.

### Further Reading and Resources
#### Further Reading and Resources

- [Gathering Human Feedback Tutorial](https://github.com/heartexlabs/RLHF/blob/master/tutorials/RLHF_with_Custom_Datasets.ipynb) A Jupyter Notebook tutorial that will guide you through the step-by-step process of collecting comparison data, establishing human preferences, and incorporating this feedback into the reward model training.
- [RLHF Resources](https://github.com/heartexlabs/RLHF): A collection of links, tutorials and best practices on how collect data and build an end-to-end Reinforcement Learning from Human Feedback (RLHF) system to fine-tune Generative AI models.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/templates/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ cards:
url: "/templates/gallery_generative_ai.html"
- title: LLM Evaluations
categories: generative ai, llm
image: "/images/templates/generative-pairwise-human-preference.png"
image: "/images/templates/response-moderation.png"
url: "/templates/gallery_llm_evals.html"
---
7 changes: 3 additions & 4 deletions docs/themes/v2/layout/page.ejs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<% const isEnterpriseTheme = theme.tier === "enterprise" %>
<% const pageContainsHeadings = page.content.includes("<h2") %>
<% const tocPageTypes = page.type === "guide" || page.type === "blog" || page.type === "templates" || page.type === "tags" %>

<% const showToc = pageContainsHeadings && tocPageTypes %>

<% const formattedContent = removeContent(page.content) %>
<% const tocContent = replaceContent(formattedContent) %>
<% const pageHasHeading = /<h[1-6]\b[^>]*>/i.test(formattedContent); %>
<% const showToc = tocPageTypes && pageHasHeading %>

<div class="content-grid">
<div class="content-markdown">
Expand All @@ -21,7 +20,7 @@
<% if (showToc) { %>
<div class="toc">
<%- partial("component/text", {text: "In this article", tag: "h3", size: "Eyebrow"}) %>
<%- toc(tocContent, {max_depth: 3, list_number: false, class: "toc-list"}) %>
<%- tableOfContent(tocContent, {max_depth: 3}) %>
</div>
<% } %>
<div class="toc-enterprise-cta">
Expand Down
4 changes: 4 additions & 0 deletions docs/themes/v2/source/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -1223,6 +1223,10 @@ ul {
margin-top: 1em;
}

.toc-list-level-2~.toc-list-level-3 {
padding-left: 1em;
}

.toc-list-child {
list-style: none;
padding-left: 0.825em;
Expand Down
6 changes: 3 additions & 3 deletions docs/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1674,9 +1674,9 @@ create-error-class@^3.0.2:
capture-stack-trace "^1.0.0"

cross-spawn@^7.0.0, cross-spawn@^7.0.3:
version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==
version "7.0.5"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.5.tgz#910aac880ff5243da96b728bc6521a5f6c2f2f82"
integrity sha512-ZVJrKKYunU38/76t0RMOulHOnUcbU9GbpWKAOZ0mhjr7CX6FVrH+4FrAapSOekrgFQ3f/8gwMEuIft0aKq6Hug==
dependencies:
path-key "^3.1.0"
shebang-command "^2.0.0"
Expand Down
20 changes: 5 additions & 15 deletions label_studio/core/feature_flags/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
from ldclient.integrations import Files, Redis

from label_studio.core.current_request import get_current_request
from label_studio.core.utils.common import load_func
from label_studio.core.utils.io import find_node
from label_studio.core.utils.params import get_all_env_with_prefix, get_bool_env

from .stale_feature_flags import STALE_FEATURE_FLAGS

logger = logging.getLogger(__name__)

get_user_repr = load_func(settings.FEATURE_FLAGS_GET_USER_REPR)


def get_feature_file_path():
package_name = 'label_studio' if settings.VERSION_EDITION == 'Community' else 'label_studio_enterprise'
Expand Down Expand Up @@ -66,19 +69,6 @@ def get_feature_file_path():
client = ldclient.get()


def _get_user_repr(user):
"""Turn user object into dict with required properties"""
if user.is_anonymous:
return {'key': str(user), 'custom': {'organization': None}}
user_data = {'email': user.email}
user_data['key'] = user_data['email']
if user.active_organization is not None:
user_data['custom'] = {'organization': user.active_organization.created_by.email}
else:
user_data['custom'] = {'organization': None}
return user_data


def flag_set(feature_flag, user=None, override_system_default=None):
"""Use this method to check whether this flag is set ON to the current user, to split the logic on backend
For example,
Expand Down Expand Up @@ -114,7 +104,7 @@ def flag_set(feature_flag, user=None, override_system_default=None):
system_default = override_system_default
else:
system_default = settings.FEATURE_FLAGS_DEFAULT_VALUE
user_dict = _get_user_repr(user)
user_dict = get_user_repr(user)
return client.variation(feature_flag, user_dict, system_default)


Expand All @@ -123,7 +113,7 @@ def all_flags(user):
More on https://docs.launchdarkly.com/sdk/features/bootstrapping#javascript
stale_feature_flags will override any client configuration
"""
user_dict = _get_user_repr(user)
user_dict = get_user_repr(user)
logger.debug(f'Resolve all flags state for user {user_dict}')
state = client.all_flags_state(user_dict)
flags = state.to_json_dict()
Expand Down
2 changes: 0 additions & 2 deletions label_studio/core/feature_flags/stale_feature_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
'fflag_feat_front_lsdv_4661_full_uri_resolve_15032023_short': True,
'fflag_fix_back_LSDV_4748_annotate_task_number_14032023_short': True,
'fflag_feat_front_lsdv_4659_skipduplicates_060323_short': True,
'fflag_fix_back_LSDV_961_project_list_09022023_short': True,
'fflag_fix_font_lsdv_1148_hotkeys_namespaces_01022023_short': True,
'fflag_fix_back_lsdv_1044_check_annotations_24012023_short': False,
'fflag_feat_front_dev_4081_magic_wand_tool': True,
Expand All @@ -35,7 +34,6 @@
'fflag_feat_back_dev_3756_queue_enrollment_min_short': False,
'fflag_fix_front_dev_3666_max_usages_on_region_creation_171122_short': True,
'fflag_fix_front_dev_3617_taxonomy_memory_leaks_fix': True,
'ff_back_dev_2915_storage_nginx_proxy_26092022_short': True,
'fflag_fix_front_dev_3350_restrict_drawing_area_short': True,
'fflag_feat_front_dev_2984_dm_draggable_columns_short': True,
'fflag_feat_front_dev_2461_audio_paragraphs_seek_chunk_position_short': True,
Expand Down
11 changes: 11 additions & 0 deletions label_studio/core/feature_flags/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
def get_user_repr(user):
"""Turn user object into dict with required properties"""
if user.is_anonymous:
return {'key': str(user), 'custom': {'organization': None}}
user_data = {'email': user.email}
user_data['key'] = user_data['email']
if user.active_organization is not None:
user_data['custom'] = {'organization': user.active_organization.created_by.email}
else:
user_data['custom'] = {'organization': None}
return user_data
23 changes: 12 additions & 11 deletions label_studio/core/label_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,25 +261,26 @@ def generate_sample_task_without_check(label_config, mode='upload', secure_mode=
# make examples pretty
examples = data_examples(mode=mode)

# iterate over xml tree and find values with '$'
# iterate over xml tree and find elements with 'value' or 'valueList' attributes
task = {}
parent = xml.findall('.//*[@value]') # take all tags with value attribute
# Include both 'value' and 'valueList' attributes in the search
parent = xml.findall('.//*[@value]') + xml.findall('.//*[@valueList]')
for p in parent:

# Make sure it is a real object tag, extract data placeholder key
value = p.get('value')
# Extract data placeholder key
value = p.get('value') or p.get('valueList')
if not value or not value.startswith('$'):
continue
value = value[1:]
is_value_list = 'valueList' in p.attrib # Check if the attribute is 'valueList'

# detect secured mode - objects served as URLs
value_type = p.get('valueType') or p.get('valuetype')
only_urls = secure_mode or value_type == 'url'

example_from_field_name = examples.get('$' + value)
if example_from_field_name:
# try to get example by variable name
task[value] = example_from_field_name
# Get example by variable name
task[value] = [example_from_field_name] if is_value_list else example_from_field_name

elif value == 'video' and p.tag == 'HyperText':
task[value] = examples.get('$videoHack')
Expand All @@ -297,7 +298,6 @@ def generate_sample_task_without_check(label_config, mode='upload', secure_mode=
task[value] = []
for item in examples[p.tag]:
task[value].append({name_key: item['author'], text_key: item['text']})

elif p.tag == 'TimeSeries':
# TimeSeries special case - generate signals on-the-fly
time_column = p.get('timeColumn')
Expand Down Expand Up @@ -334,10 +334,11 @@ def generate_sample_task_without_check(label_config, mode='upload', secure_mode=
else:
task[value] = examples['Choices']
else:
# patch for valueType="url"
# Patch for valueType="url"
examples['Text'] = examples['TextUrl'] if only_urls else examples['TextRaw']
# not found by name, try get example by type
task[value] = examples.get(p.tag, 'Something')
# Not found by name, try to get example by type
example_value = examples.get(p.tag, 'Something')
task[value] = [example_value] if is_value_list else example_value

# support for Repeater tag
if '[' in value:
Expand Down
1 change: 1 addition & 0 deletions label_studio/core/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@
STORAGE_PERMISSION = 'io_storages.permissions.StoragePermission'
PROJECT_IMPORT_PERMISSION = 'projects.permissions.ProjectImportPermission'
DELETE_TASKS_ANNOTATIONS_POSTPROCESS = None
FEATURE_FLAGS_GET_USER_REPR = 'core.feature_flags.utils.get_user_repr'


def project_delete(project):
Expand Down
68 changes: 0 additions & 68 deletions label_studio/core/static/css/Toast.min.css

This file was deleted.

3 changes: 2 additions & 1 deletion label_studio/core/static/css/login.css
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ html, body {
font-size: .875rem;
}
.login_page_new_ui form input,
.login_page_new_ui form button {
.login_page_new_ui form button,
.login_page_new_ui form select {
width: 100%;
font-family: 'Hellix', sans-serif;
}
Expand Down
1 change: 0 additions & 1 deletion label_studio/core/static/css/uikit.css
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,3 @@ ul.toggle li.active {
box-shadow: none;
outline: none;
}

1 change: 0 additions & 1 deletion label_studio/core/static/js/Toast.min.js

This file was deleted.

Loading

0 comments on commit 014e4dd

Please sign in to comment.