Skip to content

Commit ee6166b

Browse files
chore: FIT-1124: sync SDK (#702)
Co-authored-by: fern-api[bot] <115122769+fern-api[bot]@users.noreply.github.com> Co-authored-by: robot-ci-heartex <robot-ci-heartex@users.noreply.github.com>
1 parent 20b0935 commit ee6166b

4 files changed

Lines changed: 95 additions & 14 deletions

File tree

reference.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10147,6 +10147,20 @@ Data that you want to duplicate: settings only, with tasks, with annotations
1014710147
must include a "text" field.
1014810148
<br>
1014910149

10150+
## Async Import Behavior
10151+
<hr style="opacity:0.3">
10152+
10153+
**For non-Community editions, this endpoint processes imports asynchronously.**
10154+
10155+
- The POST request **can fail** for invalid parameters, malformed request body, or other request-level validation errors.
10156+
- However, **data validation errors** that occur during import processing are handled asynchronously and will not cause the POST request to fail.
10157+
- Upon successful request validation, a response is returned: `{"import": <import_id>}`
10158+
- Use the returned `import_id` to poll the GET `/api/projects/{project_id}/imports/{import_id}` endpoint to check the import status and see any data validation errors.
10159+
- Data-level errors and import failures will only be visible in the GET request response.
10160+
10161+
For Community edition, imports are processed synchronously and return task counts immediately.
10162+
<br>
10163+
1015010164
## POST requests
1015110165
<hr style="opacity:0.3">
1015210166

@@ -10455,7 +10469,17 @@ client.projects.validate_label_config(
1045510469
<dl>
1045610470
<dd>
1045710471

10458-
Return data related to async project import operation
10472+
10473+
Poll the status of an asynchronous project import operation.
10474+
10475+
**Usage:**
10476+
1. When you POST to `/api/projects/{project_id}/import`, you'll receive a response like `{"import": <import_id>}`
10477+
2. Use that `import_id` with this GET endpoint to check the import status
10478+
3. Poll this endpoint to see if the import has completed, is still processing, or has failed
10479+
4. **Import errors and failures will only be visible in this GET response**, not in the original POST request
10480+
10481+
This endpoint returns detailed information about the import including task counts, status, and any error messages.
10482+
1045910483
</dd>
1046010484
</dl>
1046110485
</dd>

src/label_studio_sdk/projects/client.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,20 @@ def import_tasks(
10141014
must include a "text" field.
10151015
<br>
10161016
1017+
## Async Import Behavior
1018+
<hr style="opacity:0.3">
1019+
1020+
**For non-Community editions, this endpoint processes imports asynchronously.**
1021+
1022+
- The POST request **can fail** for invalid parameters, malformed request body, or other request-level validation errors.
1023+
- However, **data validation errors** that occur during import processing are handled asynchronously and will not cause the POST request to fail.
1024+
- Upon successful request validation, a response is returned: `{"import": <import_id>}`
1025+
- Use the returned `import_id` to poll the GET `/api/projects/{project_id}/imports/{import_id}` endpoint to check the import status and see any data validation errors.
1026+
- Data-level errors and import failures will only be visible in the GET request response.
1027+
1028+
For Community edition, imports are processed synchronously and return task counts immediately.
1029+
<br>
1030+
10171031
## POST requests
10181032
<hr style="opacity:0.3">
10191033
@@ -1079,7 +1093,7 @@ def import_tasks(
10791093
Returns
10801094
-------
10811095
ImportTasksProjectsResponse
1082-
Tasks successfully imported
1096+
Tasks successfully imported or import queued. **For non-Community editions**, the response will be `{"import": <import_id>}` which you can use to poll the import status. **For Community edition**, the response contains task counts and is processed synchronously.
10831097
10841098
Examples
10851099
--------
@@ -2291,6 +2305,20 @@ async def import_tasks(
22912305
must include a "text" field.
22922306
<br>
22932307
2308+
## Async Import Behavior
2309+
<hr style="opacity:0.3">
2310+
2311+
**For non-Community editions, this endpoint processes imports asynchronously.**
2312+
2313+
- The POST request **can fail** for invalid parameters, malformed request body, or other request-level validation errors.
2314+
- However, **data validation errors** that occur during import processing are handled asynchronously and will not cause the POST request to fail.
2315+
- Upon successful request validation, a response is returned: `{"import": <import_id>}`
2316+
- Use the returned `import_id` to poll the GET `/api/projects/{project_id}/imports/{import_id}` endpoint to check the import status and see any data validation errors.
2317+
- Data-level errors and import failures will only be visible in the GET request response.
2318+
2319+
For Community edition, imports are processed synchronously and return task counts immediately.
2320+
<br>
2321+
22942322
## POST requests
22952323
<hr style="opacity:0.3">
22962324
@@ -2356,7 +2384,7 @@ async def import_tasks(
23562384
Returns
23572385
-------
23582386
ImportTasksProjectsResponse
2359-
Tasks successfully imported
2387+
Tasks successfully imported or import queued. **For non-Community editions**, the response will be `{"import": <import_id>}` which you can use to poll the import status. **For Community edition**, the response contains task counts and is processed synchronously.
23602388
23612389
Examples
23622390
--------

src/label_studio_sdk/projects/types/import_tasks_projects_response.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,61 @@
33
from ...core.unchecked_base_model import UncheckedBaseModel
44
import typing
55
import pydantic
6+
import typing_extensions
7+
from ...core.serialization import FieldMetadata
68
from ...core.pydantic_utilities import IS_PYDANTIC_V2
79

810

911
class ImportTasksProjectsResponse(UncheckedBaseModel):
1012
"""
11-
Task creation response
13+
Response format varies by edition. Non-Community editions return `{"import": <import_id>}` for async processing. Community edition returns the detailed response below with task counts.
1214
"""
1315

1416
annotation_count: typing.Optional[int] = pydantic.Field(default=None)
1517
"""
16-
Number of annotations added
18+
Number of annotations added (Community edition sync import only)
1719
"""
1820

1921
could_be_tasks_list: typing.Optional[bool] = pydantic.Field(default=None)
2022
"""
21-
Whether uploaded files can contain lists of tasks, like CSV/TSV files
23+
Whether uploaded files can contain lists of tasks, like CSV/TSV files (Community edition sync import only)
2224
"""
2325

2426
data_columns: typing.Optional[typing.List[str]] = pydantic.Field(default=None)
2527
"""
26-
The list of found data columns
28+
The list of found data columns (Community edition sync import only)
2729
"""
2830

2931
duration: typing.Optional[float] = pydantic.Field(default=None)
3032
"""
31-
Time in seconds to create
33+
Time in seconds to create (Community edition sync import only)
3234
"""
3335

3436
file_upload_ids: typing.Optional[typing.List[int]] = pydantic.Field(default=None)
3537
"""
36-
Database IDs of uploaded files
38+
Database IDs of uploaded files (Community edition sync import only)
3739
"""
3840

3941
found_formats: typing.Optional[typing.List[str]] = pydantic.Field(default=None)
4042
"""
41-
The list of found file formats
43+
The list of found file formats (Community edition sync import only)
44+
"""
45+
46+
import_: typing_extensions.Annotated[typing.Optional[int], FieldMetadata(alias="import")] = pydantic.Field(
47+
default=None
48+
)
49+
"""
50+
Import ID for async operations (non-Community editions only). Use this ID to poll `/api/projects/{project_id}/imports/{import_id}` for status.
4251
"""
4352

4453
predictions_count: typing.Optional[int] = pydantic.Field(default=None)
4554
"""
46-
Number of predictions added
55+
Number of predictions added (Community edition sync import only)
4756
"""
4857

4958
task_count: typing.Optional[int] = pydantic.Field(default=None)
5059
"""
51-
Number of tasks added
60+
Number of tasks added (Community edition sync import only)
5261
"""
5362

5463
if IS_PYDANTIC_V2:

src/label_studio_sdk/tasks/client.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,17 @@ def create_many_status(
3434
self, id: int, import_pk: int, *, request_options: typing.Optional[RequestOptions] = None
3535
) -> ProjectImport:
3636
"""
37-
Return data related to async project import operation
37+
38+
Poll the status of an asynchronous project import operation.
39+
40+
**Usage:**
41+
1. When you POST to `/api/projects/{project_id}/import`, you'll receive a response like `{"import": <import_id>}`
42+
2. Use that `import_id` with this GET endpoint to check the import status
43+
3. Poll this endpoint to see if the import has completed, is still processing, or has failed
44+
4. **Import errors and failures will only be visible in this GET response**, not in the original POST request
45+
46+
This endpoint returns detailed information about the import including task counts, status, and any error messages.
47+
3848
3949
Parameters
4050
----------
@@ -856,7 +866,17 @@ async def create_many_status(
856866
self, id: int, import_pk: int, *, request_options: typing.Optional[RequestOptions] = None
857867
) -> ProjectImport:
858868
"""
859-
Return data related to async project import operation
869+
870+
Poll the status of an asynchronous project import operation.
871+
872+
**Usage:**
873+
1. When you POST to `/api/projects/{project_id}/import`, you'll receive a response like `{"import": <import_id>}`
874+
2. Use that `import_id` with this GET endpoint to check the import status
875+
3. Poll this endpoint to see if the import has completed, is still processing, or has failed
876+
4. **Import errors and failures will only be visible in this GET response**, not in the original POST request
877+
878+
This endpoint returns detailed information about the import including task counts, status, and any error messages.
879+
860880
861881
Parameters
862882
----------

0 commit comments

Comments
 (0)