Skip to content

fix: LEAP-2058: delete unused upload-example endpoint #7440

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 2 commits into from
Apr 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions label_studio/core/all_urls.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,6 @@
"name": "projects:project-settings-anything",
"decorators": ""
},
{
"url": "/projects/upload-example/",
"module": "projects.views.upload_example_using_config",
"name": "projects:project-upload-example-using-config",
"decorators": ""
},
{
"url": "/api/projects/",
"module": "projects.api.ProjectListAPI",
Expand Down
1 change: 0 additions & 1 deletion label_studio/projects/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
path('', views.project_list, name='project-index'),
path('<int:pk>/settings/', views.project_settings, name='project-settings', kwargs={'sub_path': ''}),
path('<int:pk>/settings/<sub_path>', views.project_settings, name='project-settings-anything'),
path('upload-example/', views.upload_example_using_config, name='project-upload-example-using-config'),
]

# reverse for projects:api:name
Expand Down
40 changes: 0 additions & 40 deletions label_studio/projects/views.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
"""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.
"""
import json
import logging

import lxml.etree
from core.label_config import get_sample_task
from core.utils.common import get_organization_from_request
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse
from django.shortcuts import render
from django.views.decorators.http import require_http_methods
from organizations.models import Organization
from projects.models import Project
from rest_framework import generics, status
from rest_framework.exceptions import ValidationError

logger = logging.getLogger(__name__)

Expand All @@ -26,33 +16,3 @@ def project_list(request):
@login_required
def project_settings(request, pk, sub_path):
return render(request, 'projects/settings.html')


def playground_replacements(request, task_data):
if request.GET.get('playground', '0') == '1':
for key in task_data:
if '/samples/time-series.csv' in task_data[key]:
task_data[key] = 'https://app.heartex.ai' + task_data[key]
return task_data


@require_http_methods(['POST'])
def upload_example_using_config(request):
"""Generate upload data example by config only"""
config = request.POST.get('label_config', '')

org_pk = get_organization_from_request(request)
secure_mode = False
if org_pk is not None:
org = generics.get_object_or_404(Organization, pk=org_pk)
secure_mode = org.secure_mode

try:
Project.validate_label_config(config)
task_data, _, _ = get_sample_task(config, secure_mode)
task_data = playground_replacements(request, task_data)
except (ValueError, ValidationError, lxml.etree.Error):
response = HttpResponse('error while example generating', status=status.HTTP_400_BAD_REQUEST)
else:
response = HttpResponse(json.dumps(task_data))
return response
96 changes: 0 additions & 96 deletions label_studio/tests/sample_tasks.tavern.yml

This file was deleted.

Loading