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

label-studio "internal server error" when filtering image classification dataset #5340

Closed
pdlje82 opened this issue Jan 23, 2024 · 2 comments
Labels
community:duplicate Community reported issue that has been previously reported community:reviewed Issue has been reviewed by the Label Studio Community Team.

Comments

@pdlje82
Copy link

pdlje82 commented Jan 23, 2024

Describe the bug
When in a labeling project, trying to filter by "Annotation result" crashes label-studio. It seems that this happens if the filter is working on a big number of results, i.e. reducing results from 5000 to 60.
Annotations where imported previously via json import, using the format in the screenshot.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'filters' -> "Annotation result" -> contains
  2. enter search string, i.e. "mi" for "missing"
  3. See error (screenshots)

Expected behavior
label-studio should show only images containing the search string in their annotations

Screenshots
image
image
image

Environment (please complete the following information):

  • OS: Win10
  • Label Studio Version 1.10.1dev

Additional context
Images imported from S3

@pdlje82 pdlje82 changed the title label-studio "broken pipe" crash when filtering image classification dataset label-studio "internal server error" when filtering image classification dataset Jan 23, 2024
@jombooth
Copy link
Contributor

Hi @pdlje82 , thanks for your report! Closing as this is actually a duplicate of issue #5321 - in that ticket, there's a suggested workaround of using regex-based filtering instead of "contains", which I think should cover your usecase for now. We'll work on this when we can, and of course would welcome a PR :)

@jombooth jombooth closed this as not planned Won't fix, can't repro, duplicate, stale Jan 23, 2024
@jombooth jombooth added community:reviewed Issue has been reviewed by the Label Studio Community Team. community:duplicate Community reported issue that has been previously reported labels Jan 23, 2024
@JiashuaiXu
Copy link

Let me tell you my solution, none of the above methods solved my problem. I was unable to access my project directory after using filter and it showed that the database was locked.

     ^^^^^^^^^^^^^^^^^^^^^^^^
django.db.utils.OperationalError: database is locked
[2024-08-01 05:41:15,031] [core.utils.common::custom_exception_handler::91] [ERROR] cb6e4b22-32e5-4acf-a28f-b293626e8460 database is locked
Traceback (most recent call last):
  File "/home/jesse/miniconda3/envs/label_1_13/lib/python3.12/site-packages/django/db/backends/base/base.py", line 242, in _commit
    return self.connection.commit()
           ^^^^^^^^^^^^^^^^^^^^^^^^
sqlite3.OperationalError: database is locked

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/jesse/miniconda3/envs/label_1_13/lib/python3.12/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jesse/miniconda3/envs/label_1_13/lib/python3.12/site-packages/label_studio/projects/api.py", line 482, in get
    history = get_label_stream_history(request.user, project)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jesse/miniconda3/envs/label_1_13/lib/python3.12/site-packages/label_studio/projects/functions/stream_history.py", line 38, in get_label_stream_history
    with transaction.atomic():
  File "/home/jesse/miniconda3/envs/label_1_13/lib/python3.12/site-packages/django/db/transaction.py", line 246, in __exit__
    connection.commit()
  File "/home/jesse/miniconda3/envs/label_1_13/lib/python3.12/site-packages/django/utils/asyncio.py", line 33, in inner
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/jesse/miniconda3/envs/label_1_13/lib/python3.12/site-packages/django/db/backends/base/base.py", line 266, in commit
    self._commit()
  File "/home/jesse/miniconda3/envs/label_1_13/lib/python3.12/site-packages/django/db/backends/base/base.py", line 241, in _commit
    with self.wrap_database_errors:
  File "/home/jesse/miniconda3/envs/label_1_13/lib/python3.12/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/home/jesse/miniconda3/envs/label_1_13/lib/python3.12/site-packages/django/db/backends/base/base.py", line 242, in _commit
    return self.connection.commit()
           ^^^^^^^^^^^^^^^^^^^^^^^^
django.db.utils.OperationalError: database is locked

image

I tried all the delete views in the project failed, and the default view can't be deleted.

image

I know it's an error in the filter on my page.
image

So I updated the filter via the official API provided and it worked!
image

You need to go to the corresponding web

api address.

Anyway, I updated the contents of the filter through the interface provided by the web, api. Then solved the problem of view 98 being inaccessible and the database lockup he was causing.


import requests

# 配置API URL和请求头
api_url = "http://your-label-project:8080/api/dm/views/98/"
headers = {
    "Authorization": "Token d5c13639bc280904ceccc317a2xxxxxxxxxxxxxxxxx",  # 确保这里的格式为 'Token <your_token>'
    "Content-Type": "application/json"
}
data = {
    "project": 9,  # 替换为您的项目ID
    "data": {
        "title": "Default",
        "type": "list",
        "target": "tasks",
        "hiddenColumns": {
            "explore": [
                "tasks:annotations_ids",
                "tasks:predictions_score",
                "tasks:predictions_model_versions",
                "tasks:predictions_results",
                "tasks:file_upload",
                "tasks:storage_filename",
                "tasks:created_at",
                "tasks:updated_at",
                "tasks:updated_by",
                "tasks:avg_lead_time",
                "tasks:draft_exists"
            ],
            "labeling": [
                "tasks:cancelled_annotations",
                "tasks:total_predictions",
                "tasks:annotations_ids",
                "tasks:predictions_score",
                "tasks:predictions_model_versions",
                "tasks:predictions_results",
                "tasks:file_upload",
                "tasks:storage_filename",
                "tasks:created_at",
                "tasks:updated_at",
                "tasks:updated_by",
                "tasks:avg_lead_time",
                "tasks:completed_at",
                "tasks:annotators",
                "tasks:annotations_results",
                "tasks:draft_exists",
                "tasks:total_annotations"
            ]
        },
        "columnsWidth": {},
        "columnsDisplayType": {},
        "gridWidth": 4,
        "semantic_search": [],
        "filters": {
            "conjunction": "and",
            "items": [
                {
                    "filter": "filter:tasks:inner_id",
                    "operator": "less_or_equal",
                    "type": "Number",
                    "value": 3500
                }
            ]
        },
        "ordering": [
            "tasks:total_annotations"
        ]
    },
    "user": 1,  # 替换为用户ID
    "project": 9  # 替换为项目ID
}

# 执行API请求
response = requests.put(api_url, headers=headers, json=data)

# 输出响应结果
if response.status_code == 200:
    print("视图更新成功")
    print(response.json())  # 打印更新后的视图数据
else:
    print(f"视图更新失败: {response.status_code} - {response.text}")
 

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community:duplicate Community reported issue that has been previously reported community:reviewed Issue has been reviewed by the Label Studio Community Team.
Projects
None yet
Development

No branches or pull requests

3 participants