Skip to content

Commit 505bf93

Browse files
feat: UTC-288: Add bulk import predictions api to sdk (#595)
Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com>
1 parent 90f4274 commit 505bf93

10 files changed

Lines changed: 383 additions & 1 deletion

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ dist/
33
__pycache__/
44
poetry.toml
55
.ruff_cache/
6-
CLAUDE.local.md

.mock/definition/projects.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ types:
7474
docs: Number of tasks added
7575
source:
7676
openapi: openapi/openapi.yaml
77+
ProjectsImportPredictionsResponse:
78+
docs: Import result
79+
properties:
80+
created:
81+
type: optional<integer>
82+
docs: Number of predictions created
83+
source:
84+
openapi: openapi/openapi.yaml
7785
ApiProjectsProjectExtraParamsRetrieveResponse:
7886
docs: Create or change annotator weights for statistics
7987
properties:
@@ -995,6 +1003,38 @@ service:
9951003
task_count: 1
9961004
audiences:
9971005
- public
1006+
import_predictions:
1007+
path: /api/projects/{id}/import/predictions
1008+
method: POST
1009+
auth: true
1010+
docs: Import model predictions for tasks in the specified project.
1011+
source:
1012+
openapi: openapi/openapi.yaml
1013+
path-parameters:
1014+
id:
1015+
type: integer
1016+
docs: A unique integer value identifying this project.
1017+
display-name: Import predictions
1018+
request:
1019+
body: list<root.PredictionRequest>
1020+
content-type: application/json
1021+
response:
1022+
docs: Predictions successfully imported
1023+
type: ProjectsImportPredictionsResponse
1024+
errors:
1025+
- root.BadRequestError
1026+
examples:
1027+
- path-parameters:
1028+
id: 1
1029+
request:
1030+
- result:
1031+
- key: value
1032+
task: 1
1033+
response:
1034+
body:
1035+
created: 1
1036+
audiences:
1037+
- public
9981038
api_projects_members_create:
9991039
path: /api/projects/{id}/members/
10001040
method: POST

.mock/openapi/openapi.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7486,6 +7486,60 @@ paths:
74867486
- public
74877487
x-fern-sdk-group-name: projects
74887488
x-fern-sdk-method-name: import_tasks
7489+
/api/projects/{id}/import/predictions:
7490+
post:
7491+
description: Import model predictions for tasks in the specified project.
7492+
operationId: api_projects_import_predictions_create
7493+
parameters:
7494+
- description: A unique integer value identifying this project.
7495+
in: path
7496+
name: id
7497+
required: true
7498+
schema:
7499+
type: integer
7500+
requestBody:
7501+
content:
7502+
application/json:
7503+
schema:
7504+
items:
7505+
$ref: '#/components/schemas/PredictionRequest'
7506+
type: array
7507+
application/x-www-form-urlencoded:
7508+
schema:
7509+
items:
7510+
$ref: '#/components/schemas/PredictionRequest'
7511+
type: array
7512+
multipart/form-data:
7513+
schema:
7514+
items:
7515+
$ref: '#/components/schemas/PredictionRequest'
7516+
type: array
7517+
required: true
7518+
responses:
7519+
'201':
7520+
content:
7521+
application/json:
7522+
schema:
7523+
description: Import result
7524+
properties:
7525+
created:
7526+
description: Number of predictions created
7527+
title: created
7528+
type: integer
7529+
title: Predictions import response
7530+
type: object
7531+
description: Predictions successfully imported
7532+
'400':
7533+
description: Bad Request
7534+
security:
7535+
- Token: []
7536+
summary: Import predictions
7537+
tags:
7538+
- Import
7539+
x-fern-audiences:
7540+
- public
7541+
x-fern-sdk-group-name: projects
7542+
x-fern-sdk-method-name: import_predictions
74897543
/api/projects/{id}/imports/{import_pk}/:
74907544
get:
74917545
description: Return data related to async project import operation

reference.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9865,6 +9865,90 @@ client.projects.import_tasks(
98659865
</dl>
98669866

98679867

9868+
</dd>
9869+
</dl>
9870+
</details>
9871+
9872+
<details><summary><code>client.projects.<a href="src/label_studio_sdk/projects/client.py">import_predictions</a>(...)</code></summary>
9873+
<dl>
9874+
<dd>
9875+
9876+
#### 📝 Description
9877+
9878+
<dl>
9879+
<dd>
9880+
9881+
<dl>
9882+
<dd>
9883+
9884+
Import model predictions for tasks in the specified project.
9885+
</dd>
9886+
</dl>
9887+
</dd>
9888+
</dl>
9889+
9890+
#### 🔌 Usage
9891+
9892+
<dl>
9893+
<dd>
9894+
9895+
<dl>
9896+
<dd>
9897+
9898+
```python
9899+
from label_studio_sdk import LabelStudio, PredictionRequest
9900+
9901+
client = LabelStudio(
9902+
api_key="YOUR_API_KEY",
9903+
)
9904+
client.projects.import_predictions(
9905+
id=1,
9906+
request=[
9907+
PredictionRequest(
9908+
result=[{"key": "value"}],
9909+
task=1,
9910+
)
9911+
],
9912+
)
9913+
9914+
```
9915+
</dd>
9916+
</dl>
9917+
</dd>
9918+
</dl>
9919+
9920+
#### ⚙️ Parameters
9921+
9922+
<dl>
9923+
<dd>
9924+
9925+
<dl>
9926+
<dd>
9927+
9928+
**id:** `int` — A unique integer value identifying this project.
9929+
9930+
</dd>
9931+
</dl>
9932+
9933+
<dl>
9934+
<dd>
9935+
9936+
**request:** `typing.Sequence[PredictionRequest]`
9937+
9938+
</dd>
9939+
</dl>
9940+
9941+
<dl>
9942+
<dd>
9943+
9944+
**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
9945+
9946+
</dd>
9947+
</dl>
9948+
</dd>
9949+
</dl>
9950+
9951+
98689952
</dd>
98699953
</dl>
98709954
</details>

src/label_studio_sdk/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@
292292
PatchedLseProjectUpdateRequestSampling,
293293
PatchedLseProjectUpdateRequestSkipQueue,
294294
ProjectsDuplicateResponse,
295+
ProjectsImportPredictionsResponse,
295296
ProjectsImportTasksResponse,
296297
ProjectsListRequestFilter,
297298
)
@@ -537,6 +538,7 @@
537538
"ProjectTemplate",
538539
"ProjectTemplateRequest",
539540
"ProjectsDuplicateResponse",
541+
"ProjectsImportPredictionsResponse",
540542
"ProjectsImportTasksResponse",
541543
"ProjectsListRequestFilter",
542544
"PromptsCompatibleProjectsRequestProjectType",

src/label_studio_sdk/projects/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
PatchedLseProjectUpdateRequestSampling,
77
PatchedLseProjectUpdateRequestSkipQueue,
88
ProjectsDuplicateResponse,
9+
ProjectsImportPredictionsResponse,
910
ProjectsImportTasksResponse,
1011
ProjectsListRequestFilter,
1112
)
@@ -58,6 +59,7 @@
5859
"PatchedLseProjectUpdateRequestSampling",
5960
"PatchedLseProjectUpdateRequestSkipQueue",
6061
"ProjectsDuplicateResponse",
62+
"ProjectsImportPredictionsResponse",
6163
"ProjectsImportTasksResponse",
6264
"ProjectsListRequestFilter",
6365
"StatsIaaResponse",

0 commit comments

Comments
 (0)