label-studio-sdk 0.0.18__tar.gz → 0.0.20__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.
Potentially problematic release.
This version of label-studio-sdk might be problematic. Click here for more details.
- {label-studio-sdk-0.0.18/label_studio_sdk.egg-info → label-studio-sdk-0.0.20}/PKG-INFO +1 -1
- {label-studio-sdk-0.0.18 → label-studio-sdk-0.0.20}/label_studio_sdk/__init__.py +1 -1
- {label-studio-sdk-0.0.18 → label-studio-sdk-0.0.20}/label_studio_sdk/project.py +97 -6
- {label-studio-sdk-0.0.18 → label-studio-sdk-0.0.20/label_studio_sdk.egg-info}/PKG-INFO +1 -1
- label-studio-sdk-0.0.20/label_studio_sdk.egg-info/requires.txt +4 -0
- label-studio-sdk-0.0.20/requirements.txt +4 -0
- label-studio-sdk-0.0.18/label_studio_sdk.egg-info/requires.txt +0 -3
- label-studio-sdk-0.0.18/requirements.txt +0 -3
- {label-studio-sdk-0.0.18 → label-studio-sdk-0.0.20}/LICENSE +0 -0
- {label-studio-sdk-0.0.18 → label-studio-sdk-0.0.20}/MANIFEST.in +0 -0
- {label-studio-sdk-0.0.18 → label-studio-sdk-0.0.20}/README.md +0 -0
- {label-studio-sdk-0.0.18 → label-studio-sdk-0.0.20}/docs/__init__.py +0 -0
- {label-studio-sdk-0.0.18 → label-studio-sdk-0.0.20}/label_studio_sdk/client.py +0 -0
- {label-studio-sdk-0.0.18 → label-studio-sdk-0.0.20}/label_studio_sdk/data_manager.py +0 -0
- {label-studio-sdk-0.0.18 → label-studio-sdk-0.0.20}/label_studio_sdk/users.py +0 -0
- {label-studio-sdk-0.0.18 → label-studio-sdk-0.0.20}/label_studio_sdk/utils.py +0 -0
- {label-studio-sdk-0.0.18 → label-studio-sdk-0.0.20}/label_studio_sdk/workspaces.py +0 -0
- {label-studio-sdk-0.0.18 → label-studio-sdk-0.0.20}/label_studio_sdk.egg-info/SOURCES.txt +0 -0
- {label-studio-sdk-0.0.18 → label-studio-sdk-0.0.20}/label_studio_sdk.egg-info/dependency_links.txt +0 -0
- {label-studio-sdk-0.0.18 → label-studio-sdk-0.0.20}/label_studio_sdk.egg-info/top_level.txt +0 -0
- {label-studio-sdk-0.0.18 → label-studio-sdk-0.0.20}/setup.cfg +0 -0
- {label-studio-sdk-0.0.18 → label-studio-sdk-0.0.20}/setup.py +0 -0
- {label-studio-sdk-0.0.18 → label-studio-sdk-0.0.20}/tests/__init__.py +0 -0
- {label-studio-sdk-0.0.18 → label-studio-sdk-0.0.20}/tests/test_client.py +0 -0
|
@@ -6,12 +6,17 @@ import logging
|
|
|
6
6
|
|
|
7
7
|
from enum import Enum, auto
|
|
8
8
|
from random import sample, shuffle
|
|
9
|
-
from requests.exceptions import HTTPError
|
|
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
|
|
13
14
|
from .utils import parse_config, chunk
|
|
14
15
|
|
|
16
|
+
from label_studio_tools.core.utils.io import get_local_path
|
|
17
|
+
from label_studio_tools.core.label_config import parse_config
|
|
18
|
+
|
|
19
|
+
|
|
15
20
|
logger = logging.getLogger(__name__)
|
|
16
21
|
|
|
17
22
|
|
|
@@ -1226,7 +1231,6 @@ class Project(Client):
|
|
|
1226
1231
|
'presign_ttl': presign_ttl,
|
|
1227
1232
|
'title': title,
|
|
1228
1233
|
'description': description,
|
|
1229
|
-
'project': self.id,
|
|
1230
1234
|
}
|
|
1231
1235
|
response = self.make_request('POST', '/api/storages/gcs', json=payload)
|
|
1232
1236
|
return response.json()
|
|
@@ -1797,7 +1801,7 @@ class Project(Client):
|
|
|
1797
1801
|
overlap=overlap,
|
|
1798
1802
|
)
|
|
1799
1803
|
|
|
1800
|
-
def export_snapshot_list(self):
|
|
1804
|
+
def export_snapshot_list(self) -> list:
|
|
1801
1805
|
"""
|
|
1802
1806
|
Get list of export snapshots for the current project
|
|
1803
1807
|
-------
|
|
@@ -1831,7 +1835,7 @@ class Project(Client):
|
|
|
1831
1835
|
annotation_filter_options_ground_truth: bool = True,
|
|
1832
1836
|
annotation_filter_options_skipped: bool = True,
|
|
1833
1837
|
interpolate_key_frames: bool = False,
|
|
1834
|
-
):
|
|
1838
|
+
) -> dict:
|
|
1835
1839
|
"""
|
|
1836
1840
|
Create new export snapshot
|
|
1837
1841
|
----------
|
|
@@ -1900,7 +1904,7 @@ class Project(Client):
|
|
|
1900
1904
|
)
|
|
1901
1905
|
return response.json()
|
|
1902
1906
|
|
|
1903
|
-
def export_snapshot_status(self, export_id: int):
|
|
1907
|
+
def export_snapshot_status(self, export_id: int) -> ExportSnapshotStatus:
|
|
1904
1908
|
"""
|
|
1905
1909
|
Get export snapshot status by Export ID
|
|
1906
1910
|
----------
|
|
@@ -1932,7 +1936,7 @@ class Project(Client):
|
|
|
1932
1936
|
|
|
1933
1937
|
def export_snapshot_download(
|
|
1934
1938
|
self, export_id: int, export_type: str = 'JSON', path: str = "."
|
|
1935
|
-
):
|
|
1939
|
+
) -> (int, str):
|
|
1936
1940
|
"""
|
|
1937
1941
|
Download file with export snapshot in provided format
|
|
1938
1942
|
----------
|
|
@@ -1961,3 +1965,90 @@ class Project(Client):
|
|
|
1961
1965
|
for chunk in response:
|
|
1962
1966
|
f.write(chunk)
|
|
1963
1967
|
return response.status_code, filename
|
|
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
|
+
|
|
1987
|
+
def get_files_from_tasks(self, tasks: Dict, get_tasks: bool = False):
|
|
1988
|
+
"""Copy files from tasks to cache folder
|
|
1989
|
+
|
|
1990
|
+
Parameters
|
|
1991
|
+
----------
|
|
1992
|
+
tasks: Dict
|
|
1993
|
+
Tasks to download to local storage
|
|
1994
|
+
get_tasks: bool
|
|
1995
|
+
Get all tasks from current project
|
|
1996
|
+
|
|
1997
|
+
Returns
|
|
1998
|
+
-------
|
|
1999
|
+
list
|
|
2000
|
+
List of filenames
|
|
2001
|
+
"""
|
|
2002
|
+
if get_tasks:
|
|
2003
|
+
tasks = self.get_tasks()
|
|
2004
|
+
filenames = []
|
|
2005
|
+
if tasks:
|
|
2006
|
+
for task in tasks:
|
|
2007
|
+
for key in task['data']:
|
|
2008
|
+
try:
|
|
2009
|
+
filename = get_local_path(
|
|
2010
|
+
task['data'][key],
|
|
2011
|
+
access_token=self.api_key,
|
|
2012
|
+
hostname=self.url,
|
|
2013
|
+
)
|
|
2014
|
+
filenames.append(filename)
|
|
2015
|
+
except (FileNotFoundError, InvalidSchema, MissingSchema, IOError):
|
|
2016
|
+
logger.debug(f"Couldn't copy file {task['data'][key]}.")
|
|
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
|
+
payload = {"selectedItems": {"all": False, "included": task_ids}, "project": self.id}
|
|
2040
|
+
return self.make_request("POST", f"/api/dm/actions?project={self.id}&id=delete_tasks", json=payload)
|
|
2041
|
+
|
|
2042
|
+
def delete_all_tasks(self, excluded_ids: list = None) -> Response:
|
|
2043
|
+
"""Delete all tasks from the project.
|
|
2044
|
+
|
|
2045
|
+
Parameters
|
|
2046
|
+
----------
|
|
2047
|
+
excluded_ids: list of int
|
|
2048
|
+
Task ids that should be excluded from the deletion.
|
|
2049
|
+
"""
|
|
2050
|
+
assert isinstance(excluded_ids, list) or excluded_ids is None, 'excluded_ids should be list of int or None'
|
|
2051
|
+
if excluded_ids is None:
|
|
2052
|
+
excluded_ids = []
|
|
2053
|
+
payload = {"selectedItems": {"all": True, "excluded": excluded_ids}, "project": self.id}
|
|
2054
|
+
return self.make_request("POST", f"/api/dm/actions?project={self.id}&id=delete_tasks", json=payload)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{label-studio-sdk-0.0.18 → label-studio-sdk-0.0.20}/label_studio_sdk.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|