Skip to content

Commit

Permalink
Merge branch 'develop' into 'fb-ml-release-blocker'
Browse files Browse the repository at this point in the history
  • Loading branch information
hlomzik committed Apr 18, 2024
2 parents b3588dc + e9163ee commit ca5ca9f
Show file tree
Hide file tree
Showing 24 changed files with 304 additions and 440 deletions.
323 changes: 123 additions & 200 deletions .github/helpers/gh_changelog_generator/gh_changelog_generator.py

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions .github/workflows/cicd_pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,6 @@ jobs:
CURRENT_REF: "${{ github.event.after }}"
GH_REPO: "${{ github.repository }}"
GH_TOKEN: "${{ secrets.GIT_PAT }}"
AHA_SERVER: "https://labelstudio.aha.io"
AHA_TOKEN: "${{ secrets.AHA_TOKEN }}"
AHA_PRODUCT: "LSDV"
AHA_RN_FIELD: "release_notes"
AHA_FETCH_STRATEGY: "TAG"
AHA_TAG: "LS ${{ steps.create-draft-release.outputs.tag_name }}"
AHA_ADDITIONAL_RELEASES_TAG: "oss"
JIRA_SERVER: "${{ vars.JIRA_SERVER }}"
JIRA_USERNAME: "${{ secrets.JIRA_USERNAME }}"
JIRA_TOKEN: "${{ secrets.JIRA_TOKEN }}"
Expand Down
111 changes: 0 additions & 111 deletions .github/workflows/pr-labeler.yml

This file was deleted.

44 changes: 44 additions & 0 deletions .github/workflows/validator-pull-request-labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: "Check"

on:
pull_request_target:
types:
- opened
- edited
- reopened
- synchronize
- ready_for_review
branches:
- master
- develop
- 'release/**'
- 'lse-release/**'
- 'ls-release/**'

env:
ACTIONS_STEP_DEBUG: '${{ secrets.ACTIONS_STEP_DEBUG }}'

jobs:
autolabel:
name: "PR label validator"
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:

- uses: hmarr/debug-action@v3.0.0

- name: "Validate PR's title"
uses: thehanimo/pr-title-checker@v1.4.2
with:
GITHUB_TOKEN: ${{ github.token }}
pass_on_octokit_error: false
configuration_path: ".github/pr-title-checker-config.json"

- name: "Set PR's label based on title"
uses: release-drafter/release-drafter@v6.0.0
with:
disable-releaser: true
config-name: autolabeler.yml
env:
GITHUB_TOKEN: ${{ github.token }}
36 changes: 4 additions & 32 deletions label_studio/feature_flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
},
"feat_front_dev_4008_quick_task_open_short": {
"key": "feat_front_dev_4008_quick_task_open_short",
"on": false,
"on": true,
"prerequisites": [],
"targets": [],
"contextTargets": [],
Expand All @@ -160,7 +160,7 @@
"trackEvents": false,
"trackEventsFallthrough": false,
"debugEventsUntilDate": null,
"version": 2,
"version": 3,
"deleted": false
},
"feat_front_lsdv_4583_multi_image_segmentation_short": {
Expand Down Expand Up @@ -595,34 +595,6 @@
"version": 2,
"deleted": false
},
"ff_click_new_project_action_short": {
"key": "ff_click_new_project_action_short",
"on": true,
"prerequisites": [],
"targets": [],
"contextTargets": [],
"rules": [],
"fallthrough": {
"variation": 0
},
"offVariation": 0,
"variations": [
"Control",
"Treatment 1",
"Treatment 2"
],
"clientSideAvailability": {
"usingMobileKey": false,
"usingEnvironmentId": false
},
"clientSide": false,
"salt": "32c224eac7a14fe5a8ee046dd0a00619",
"trackEvents": false,
"trackEventsFallthrough": false,
"debugEventsUntilDate": null,
"version": 3,
"deleted": false
},
"ff_dev_2007_dev_2008_dynamic_tag_children_250322_short": {
"key": "ff_dev_2007_dev_2008_dynamic_tag_children_250322_short",
"on": true,
Expand Down Expand Up @@ -1752,7 +1724,7 @@
"contextTargets": [],
"rules": [],
"fallthrough": {
"variation": 1
"variation": 0
},
"offVariation": 1,
"variations": [
Expand All @@ -1768,7 +1740,7 @@
"trackEvents": false,
"trackEventsFallthrough": false,
"debugEventsUntilDate": null,
"version": 7,
"version": 8,
"deleted": false
},
"fflag_feat_all_lsdv_e_295_project_level_roles_via_saml_scim_ldap_short": {
Expand Down
9 changes: 9 additions & 0 deletions label_studio/ml/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ def perform_create(self, serializer):
ml_backend = serializer.save()
ml_backend.update_state()

project = ml_backend.project

# In case we are adding the model, let's set it as the default
# to obtain predictions. This approach is consistent with uploading
# offline predictions, which would be set automatically.
if project.show_collab_predictions and not project.model_version:
project.model_version = ml_backend.title
project.save(update_fields=['model_version'])


@method_decorator(
name='patch',
Expand Down
3 changes: 2 additions & 1 deletion label_studio/projects/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def to_internal_value(self, data):
# FIXME: remake this logic with start_training_on_annotation_update
initial_data = data
data = super().to_internal_value(data)

if 'start_training_on_annotation_update' in initial_data:
data['min_annotations_to_start_training'] = int(initial_data['start_training_on_annotation_update'])

Expand Down Expand Up @@ -186,7 +187,7 @@ def validate_model_version(self, value):
return value

def update(self, instance, validated_data):
if not validated_data.get('show_collab_predictions'):
if validated_data.get('show_collab_predictions') is False:
instance.model_version = ''

return super().update(instance, validated_data)
Expand Down
76 changes: 68 additions & 8 deletions label_studio/tests/ml/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

from label_studio.tests.utils import make_project, register_ml_backend_mock

ORIG_MODEL_NAME = 'basic_ml_backend'
PROJECT_CONFIG = """<View><Image name="image" value="$image_url"/><Choices name="label"
toName="image"><Choice value="pos"/><Choice value="neg"/></Choices></View>"""


@pytest.fixture
def ml_backend_for_test_api(ml_backend):
Expand All @@ -22,13 +26,72 @@ def mock_gethostbyname(mocker):
mocker.patch('socket.gethostbyname', return_value='321.21.21.21')


@pytest.mark.django_db
def test_ml_backend_set_for_prelabeling(business_client, ml_backend_for_test_api, mock_gethostbyname):
project = make_project(
config=dict(
is_published=True,
label_config=PROJECT_CONFIG,
title='test_ml_backend_creation',
),
user=business_client.user,
)

assert project.model_version == ''

# create ML backend
response = business_client.post(
'/api/ml/',
data={
'project': project.id,
'title': 'ml_backend_title',
'url': 'https://ml_backend_for_test_api',
},
)
assert response.status_code == 201

project.refresh_from_db()
assert project.model_version == 'ml_backend_title'


@pytest.mark.django_db
def test_ml_backend_not_set_for_prelabeling(business_client, ml_backend_for_test_api, mock_gethostbyname):
"""We are not setting it when its already set for another name,
for example when predictions were uploaded before"""

project = make_project(
config=dict(
is_published=True,
label_config=PROJECT_CONFIG,
title='test_ml_backend_creation',
),
user=business_client.user,
)

project.model_version = ORIG_MODEL_NAME
project.save()

# create ML backend
response = business_client.post(
'/api/ml/',
data={
'project': project.id,
'title': 'ml_backend_title',
'url': 'https://ml_backend_for_test_api',
},
)
assert response.status_code == 201

project.refresh_from_db()
assert project.model_version == ORIG_MODEL_NAME


@pytest.mark.django_db
def test_model_version_on_save(business_client, ml_backend_for_test_api, mock_gethostbyname):
project = make_project(
config=dict(
is_published=True,
label_config="""<View><Image name="image" value="$image_url"/><Choices name="label"
toName="image"><Choice value="pos"/><Choice value="neg"/></Choices></View>""",
label_config=PROJECT_CONFIG,
title='test_ml_backend_creation',
),
user=business_client.user,
Expand Down Expand Up @@ -86,8 +149,7 @@ def test_model_version_on_delete(business_client, ml_backend_for_test_api, mock_
project = make_project(
config=dict(
is_published=True,
label_config="""<View><Image name="image" value="$image_url"/><Choices name="label"
toName="image"><Choice value="pos"/><Choice value="neg"/></Choices></View>""",
label_config=PROJECT_CONFIG,
title='test_ml_backend_creation',
),
user=business_client.user,
Expand Down Expand Up @@ -135,8 +197,7 @@ def test_security_write_only_payload(business_client, ml_backend_for_test_api, m
project = make_project(
config=dict(
is_published=True,
label_config="""<View><Image name="image" value="$image_url"/><Choices name="label"
toName="image"><Choice value="pos"/><Choice value="neg"/></Choices></View>""",
label_config=PROJECT_CONFIG,
title='test_ml_backend_creation',
),
user=business_client.user,
Expand Down Expand Up @@ -226,8 +287,7 @@ def test_ml_backend_predict_test_api_post_random_true(business_client):
project = make_project(
config=dict(
is_published=True,
label_config="""<View><Image name="image" value="$image_url"/><Choices name="label"
toName="image"><Choice value="pos"/><Choice value="neg"/></Choices></View>""",
label_config=PROJECT_CONFIG,
title='test_ml_backend_creation',
),
user=business_client.user,
Expand Down
Loading

0 comments on commit ca5ca9f

Please sign in to comment.