label-studio-sdk 0.0.19__tar.gz → 0.0.21__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. {label-studio-sdk-0.0.19/label_studio_sdk.egg-info → label-studio-sdk-0.0.21}/PKG-INFO +1 -1
  2. {label-studio-sdk-0.0.19 → label-studio-sdk-0.0.21}/label_studio_sdk/__init__.py +1 -1
  3. {label-studio-sdk-0.0.19 → label-studio-sdk-0.0.21}/label_studio_sdk/project.py +62 -5
  4. {label-studio-sdk-0.0.19 → label-studio-sdk-0.0.21/label_studio_sdk.egg-info}/PKG-INFO +1 -1
  5. {label-studio-sdk-0.0.19 → label-studio-sdk-0.0.21}/LICENSE +0 -0
  6. {label-studio-sdk-0.0.19 → label-studio-sdk-0.0.21}/MANIFEST.in +0 -0
  7. {label-studio-sdk-0.0.19 → label-studio-sdk-0.0.21}/README.md +0 -0
  8. {label-studio-sdk-0.0.19 → label-studio-sdk-0.0.21}/docs/__init__.py +0 -0
  9. {label-studio-sdk-0.0.19 → label-studio-sdk-0.0.21}/label_studio_sdk/client.py +0 -0
  10. {label-studio-sdk-0.0.19 → label-studio-sdk-0.0.21}/label_studio_sdk/data_manager.py +0 -0
  11. {label-studio-sdk-0.0.19 → label-studio-sdk-0.0.21}/label_studio_sdk/users.py +0 -0
  12. {label-studio-sdk-0.0.19 → label-studio-sdk-0.0.21}/label_studio_sdk/utils.py +0 -0
  13. {label-studio-sdk-0.0.19 → label-studio-sdk-0.0.21}/label_studio_sdk/workspaces.py +0 -0
  14. {label-studio-sdk-0.0.19 → label-studio-sdk-0.0.21}/label_studio_sdk.egg-info/SOURCES.txt +0 -0
  15. {label-studio-sdk-0.0.19 → label-studio-sdk-0.0.21}/label_studio_sdk.egg-info/dependency_links.txt +0 -0
  16. {label-studio-sdk-0.0.19 → label-studio-sdk-0.0.21}/label_studio_sdk.egg-info/requires.txt +0 -0
  17. {label-studio-sdk-0.0.19 → label-studio-sdk-0.0.21}/label_studio_sdk.egg-info/top_level.txt +0 -0
  18. {label-studio-sdk-0.0.19 → label-studio-sdk-0.0.21}/requirements.txt +0 -0
  19. {label-studio-sdk-0.0.19 → label-studio-sdk-0.0.21}/setup.cfg +0 -0
  20. {label-studio-sdk-0.0.19 → label-studio-sdk-0.0.21}/setup.py +0 -0
  21. {label-studio-sdk-0.0.19 → label-studio-sdk-0.0.21}/tests/__init__.py +0 -0
  22. {label-studio-sdk-0.0.19 → label-studio-sdk-0.0.21}/tests/test_client.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: label-studio-sdk
3
- Version: 0.0.19
3
+ Version: 0.0.21
4
4
  Summary: Label Studio annotation tool
5
5
  Home-page: https://github.com/heartexlabs/label-studio-sdk
6
6
  Author: Heartex
@@ -5,4 +5,4 @@ from .project import Project
5
5
  from .utils import parse_config
6
6
 
7
7
 
8
- __version__ = '0.0.19'
8
+ __version__ = '0.0.21'
@@ -7,6 +7,7 @@ import logging
7
7
  from enum import Enum, auto
8
8
  from random import sample, shuffle
9
9
  from requests.exceptions import HTTPError, InvalidSchema, MissingSchema
10
+ from requests import Response
10
11
  from pathlib import Path
11
12
  from typing import Optional, Union, List, Dict, Callable
12
13
  from .client import Client
@@ -1230,7 +1231,6 @@ class Project(Client):
1230
1231
  'presign_ttl': presign_ttl,
1231
1232
  'title': title,
1232
1233
  'description': description,
1233
- 'project': self.id,
1234
1234
  }
1235
1235
  response = self.make_request('POST', '/api/storages/gcs', json=payload)
1236
1236
  return response.json()
@@ -1801,7 +1801,7 @@ class Project(Client):
1801
1801
  overlap=overlap,
1802
1802
  )
1803
1803
 
1804
- def export_snapshot_list(self):
1804
+ def export_snapshot_list(self) -> list:
1805
1805
  """
1806
1806
  Get list of export snapshots for the current project
1807
1807
  -------
@@ -1835,7 +1835,7 @@ class Project(Client):
1835
1835
  annotation_filter_options_ground_truth: bool = True,
1836
1836
  annotation_filter_options_skipped: bool = True,
1837
1837
  interpolate_key_frames: bool = False,
1838
- ):
1838
+ ) -> dict:
1839
1839
  """
1840
1840
  Create new export snapshot
1841
1841
  ----------
@@ -1904,7 +1904,7 @@ class Project(Client):
1904
1904
  )
1905
1905
  return response.json()
1906
1906
 
1907
- def export_snapshot_status(self, export_id: int):
1907
+ def export_snapshot_status(self, export_id: int) -> ExportSnapshotStatus:
1908
1908
  """
1909
1909
  Get export snapshot status by Export ID
1910
1910
  ----------
@@ -1936,7 +1936,7 @@ class Project(Client):
1936
1936
 
1937
1937
  def export_snapshot_download(
1938
1938
  self, export_id: int, export_type: str = 'JSON', path: str = "."
1939
- ):
1939
+ ) -> (int, str):
1940
1940
  """
1941
1941
  Download file with export snapshot in provided format
1942
1942
  ----------
@@ -1966,6 +1966,24 @@ class Project(Client):
1966
1966
  f.write(chunk)
1967
1967
  return response.status_code, filename
1968
1968
 
1969
+ def export_snapshot_delete(self, export_id: int) -> int:
1970
+ """Delete an export file by specified export ID
1971
+
1972
+ Parameters
1973
+ ----------
1974
+ export_id: int
1975
+ Existing Export ID from current project
1976
+
1977
+ Returns
1978
+ ----------
1979
+ Status code for operation
1980
+ """
1981
+ response = self.make_request(
1982
+ 'DELETE',
1983
+ f'/api/projects/{self.id}/exports/{export_id}',
1984
+ )
1985
+ return response.status_code
1986
+
1969
1987
  def get_files_from_tasks(self, tasks: Dict, get_tasks: bool = False):
1970
1988
  """Copy files from tasks to cache folder
1971
1989
 
@@ -1997,3 +2015,42 @@ class Project(Client):
1997
2015
  except (FileNotFoundError, InvalidSchema, MissingSchema, IOError):
1998
2016
  logger.debug(f"Couldn't copy file {task['data'][key]}.")
1999
2017
  return filenames
2018
+
2019
+ def delete_task(self, task_id: int) -> Response:
2020
+ """Delete a task. To remove multiple tasks `use delete_tasks()`.
2021
+
2022
+ Parameters
2023
+ ----------
2024
+ task_id: int
2025
+ Task id.
2026
+ """
2027
+ assert isinstance(task_id, int), 'task_id should be int'
2028
+ return self.make_request("DELETE", f"/api/tasks/{task_id}")
2029
+
2030
+ def delete_tasks(self, task_ids: list) -> Response:
2031
+ """Delete multiple tasks by IDs.
2032
+
2033
+ Parameters
2034
+ ----------
2035
+ task_ids: list of int
2036
+ Task ids.
2037
+ """
2038
+ assert isinstance(task_ids, list), 'task_ids should be list of int'
2039
+ if not task_ids: # avoid deletion of all tasks when task_ids = []
2040
+ return Response()
2041
+ payload = {"selectedItems": {"all": False, "included": task_ids}, "project": self.id}
2042
+ return self.make_request("POST", f"/api/dm/actions?project={self.id}&id=delete_tasks", json=payload)
2043
+
2044
+ def delete_all_tasks(self, excluded_ids: list = None) -> Response:
2045
+ """Delete all tasks from the project.
2046
+
2047
+ Parameters
2048
+ ----------
2049
+ excluded_ids: list of int
2050
+ Task ids that should be excluded from the deletion.
2051
+ """
2052
+ assert isinstance(excluded_ids, list) or excluded_ids is None, 'excluded_ids should be list of int or None'
2053
+ if excluded_ids is None:
2054
+ excluded_ids = []
2055
+ payload = {"selectedItems": {"all": True, "excluded": excluded_ids}, "project": self.id}
2056
+ return self.make_request("POST", f"/api/dm/actions?project={self.id}&id=delete_tasks", json=payload)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: label-studio-sdk
3
- Version: 0.0.19
3
+ Version: 0.0.21
4
4
  Summary: Label Studio annotation tool
5
5
  Home-page: https://github.com/heartexlabs/label-studio-sdk
6
6
  Author: Heartex