72
72
from lib .infrastructure .validators import wrap_error
73
73
from lib .app .serializers import WMProjectSerializer
74
74
from lib .core .entities .work_managament import WMUserTypeEnum
75
+ from lib .core .jsx_conditions import EmptyQuery
76
+
75
77
76
78
logger = logging .getLogger ("sa" )
77
79
@@ -211,7 +213,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
211
213
return True
212
214
213
215
def save (self ):
214
- if len (json .dumps (self .annotation ).encode ("utf-8" )) > 16 * 1024 * 1024 :
216
+ if len (json .dumps (self .annotation ).encode ("utf-8" )) > 15 * 1024 * 1024 :
215
217
self ._set_large_annotation_adapter (self .annotation )
216
218
else :
217
219
self ._set_small_annotation_adapter (self .annotation )
@@ -1354,7 +1356,7 @@ def get_project_metadata(
1354
1356
the key "settings"
1355
1357
:type include_settings: bool
1356
1358
1357
- :param include_workflow: Deprecated
1359
+ :param include_workflow: Returns workflow metadata
1358
1360
:type include_workflow: bool
1359
1361
1360
1362
:param include_contributors: enables project contributors output under
@@ -1377,6 +1379,7 @@ def get_project_metadata(
1377
1379
1378
1380
client.get_project_metadata(
1379
1381
project="Medical Annotations",
1382
+ include_workflow=True,
1380
1383
include_custom_fields=True
1381
1384
)
1382
1385
@@ -1385,50 +1388,53 @@ def get_project_metadata(
1385
1388
::
1386
1389
1387
1390
{
1388
- "classes": [],
1389
- "completed_items_count": None,
1390
- "contributors": [],
1391
1391
"createdAt": "2025-02-04T12:04:01+00:00",
1392
+ "updatedAt": "2024-02-04T12:04:01+00:00",
1393
+ "id": 902174,
1394
+ "team_id": 233435,
1395
+ "name": "Medical Annotations",
1396
+ "type": "Vector",
1397
+ "description": "DESCRIPTION",
1398
+ "instructions_link": None,
1392
1399
"creator_id": "ecample@email.com",
1400
+ "entropy_status": 1,
1401
+ "sharing_status": None,
1402
+ "status": "NotStarted",
1403
+ "folder_id": 1191383,
1404
+ "workflow_id": 1,
1405
+ "workflow": {
1406
+ "createdAt": "2024-09-03T12:48:09+00:00",
1407
+ "updatedAt": "2024-09-03T12:48:09+00:00",
1408
+ "id": 1,
1409
+ "name": "System workflow",
1410
+ "type": "system",
1411
+ "description": "This workflow is generated by the system, and prevents annotators from completing items.",
1412
+ "raw_config": {"roles": ["Annotator", "QA"], ...}
1413
+ },
1414
+ "upload_state": "INITIAL",
1415
+ "users": [],
1416
+ "contributors": [],
1417
+ "settings": [],
1418
+ "classes": [],
1419
+ "item_count": None,
1420
+ "completed_items_count": None,
1421
+ "root_folder_completed_items_count": None,
1393
1422
"custom_fields": {
1394
1423
"Notes": "Something",
1395
1424
"Ann Quality threshold": 80,
1396
1425
"Tag": ["Tag1", "Tag2", "Tag3"],
1397
1426
"Due date": 1738281600.0,
1398
1427
"Other_Custom_Field": None,
1399
- },
1400
- "description": "DESCRIPTION",
1401
- "entropy_status": 1,
1402
- "folder_id": 1191383,
1403
- "id": 902174,
1404
- "instructions_link": None,
1405
- "item_count": None,
1406
- "name": "Medical Annotations",
1407
- "root_folder_completed_items_count": None,
1408
- "settings": [],
1409
- "sharing_status": None,
1410
- "status": "NotStarted",
1411
- "team_id": 233435,
1412
- "type": "Vector",
1413
- "updatedAt": "2024-02-04T12:04:01+00:00",
1414
- "upload_state": "INITIAL",
1415
- "users": [],
1416
- "workflow_id": 1,
1428
+ }
1417
1429
}
1418
1430
"""
1419
1431
project_name , _ = extract_project_folder (project )
1420
1432
project = self .controller .get_project (project_name )
1421
- if include_workflow :
1422
- warnings .warn (
1423
- DeprecationWarning (
1424
- "The “include_workflow” parameter is deprecated."
1425
- " Please use the “get_project_steps” function instead."
1426
- )
1427
- )
1428
1433
response = self .controller .projects .get_metadata (
1429
1434
project ,
1430
1435
include_annotation_classes ,
1431
1436
include_settings ,
1437
+ include_workflow ,
1432
1438
include_contributors ,
1433
1439
include_complete_item_count ,
1434
1440
include_custom_fields ,
@@ -1464,18 +1470,6 @@ def get_project_settings(self, project: Union[NotEmptyStr, dict]):
1464
1470
]
1465
1471
return settings
1466
1472
1467
- def get_project_workflow (self , project : Union [str , dict ]):
1468
- """
1469
- Deprecated
1470
- """
1471
- warnings .warn (
1472
- DeprecationWarning (
1473
- "The “get_project_workflow” function is deprecated."
1474
- " Please use the “get_project_steps” function instead."
1475
- )
1476
- )
1477
- return self .get_project_steps (project )
1478
-
1479
1473
def get_project_steps (self , project : Union [str , dict ]):
1480
1474
"""Gets project's steps.
1481
1475
@@ -1509,10 +1503,10 @@ def get_project_steps(self, project: Union[str, dict]):
1509
1503
"""
1510
1504
project_name , _ = extract_project_folder (project )
1511
1505
project = self .controller .get_project (project_name )
1512
- workflow = self .controller .projects .list_workflow (project )
1513
- if workflow .errors :
1514
- raise AppException (workflow .errors )
1515
- return workflow .data
1506
+ steps = self .controller .projects .list_steps (project )
1507
+ if steps .errors :
1508
+ raise AppException (steps .errors )
1509
+ return steps .data
1516
1510
1517
1511
def search_annotation_classes (
1518
1512
self , project : Union [NotEmptyStr , dict ], name_contains : Optional [str ] = None
@@ -2502,19 +2496,6 @@ def download_export(
2502
2496
if response .errors :
2503
2497
raise AppException (response .errors )
2504
2498
2505
- def set_project_workflow (
2506
- self , project : Union [NotEmptyStr , dict ], new_workflow : List [dict ]
2507
- ):
2508
- """
2509
- Deprecated
2510
- """
2511
- warnings .warn (
2512
- DeprecationWarning (
2513
- "The “set_project_workflow” function is deprecated. Please use the “set_project_steps” function instead."
2514
- )
2515
- )
2516
- return self .set_project_steps (project , new_workflow )
2517
-
2518
2499
def set_project_steps (self , project : Union [NotEmptyStr , dict ], steps : List [dict ]):
2519
2500
"""Sets project's steps.
2520
2501
@@ -2548,7 +2529,7 @@ def set_project_steps(self, project: Union[NotEmptyStr, dict], steps: List[dict]
2548
2529
"""
2549
2530
project_name , _ = extract_project_folder (project )
2550
2531
project = self .controller .get_project (project_name )
2551
- response = self .controller .projects .set_workflows (project , steps = steps )
2532
+ response = self .controller .projects .set_steps (project , steps = steps )
2552
2533
if response .errors :
2553
2534
raise AppException (response .errors )
2554
2535
@@ -3273,14 +3254,33 @@ def get_integrations(self):
3273
3254
3274
3255
:return: metadata objects of all integrations of the team.
3275
3256
:rtype: list of dicts
3257
+
3258
+ Request Example:
3259
+ ::
3260
+
3261
+ client.get_integrations()
3262
+
3263
+
3264
+ Response Example:
3265
+ ::
3266
+
3267
+ [
3268
+ {
3269
+ "createdAt": "2023-11-27T11:16:02.000Z",
3270
+ "id": 5072,
3271
+ "name": "My S3 Bucket",
3272
+ "root": "test-openseadragon-1212",
3273
+ "type": "aws",
3274
+ "updatedAt": "2023-12-27T11:16:02.000Z",
3275
+ "creator_id": "example@superannotate.com"
3276
+ }
3277
+ ]
3276
3278
"""
3277
3279
response = self .controller .integrations .list ()
3278
3280
if response .errors :
3279
3281
raise AppException (response .errors )
3280
3282
integrations = response .data
3281
- return BaseSerializer .serialize_iterable (
3282
- integrations , ("name" , "type" , "root" ) # noqa
3283
- )
3283
+ return BaseSerializer .serialize_iterable (integrations )
3284
3284
3285
3285
def attach_items_from_integrated_storage (
3286
3286
self ,
@@ -4783,3 +4783,46 @@ def item_context(
4783
4783
item = _item ,
4784
4784
overwrite = overwrite ,
4785
4785
)
4786
+
4787
+ def list_workflows (self ):
4788
+ """
4789
+ Lists team’s all workflows and their metadata
4790
+
4791
+ :return: metadata of workflows
4792
+ :rtype: list of dicts
4793
+
4794
+
4795
+ Request Example:
4796
+ ::
4797
+
4798
+ client.list_workflows()
4799
+
4800
+
4801
+ Response Example:
4802
+ ::
4803
+
4804
+ [
4805
+ {
4806
+ "createdAt": "2024-09-03T12:48:09+00:00",
4807
+ "updatedAt": "2024-09-04T12:48:09+00:00",
4808
+ "id": 1,
4809
+ "name": "System workflow",
4810
+ "type": "system",
4811
+ "description": "This workflow is generated by the system, and prevents annotators from completing items.",
4812
+ "raw_config": {"roles": ["Annotator", "QA"], ...}
4813
+ },
4814
+ {
4815
+ "createdAt": "2025-01-03T12:48:09+00:00",
4816
+ "updatedAt": "2025-01-05T12:48:09+00:00",
4817
+ "id": 58758,
4818
+ "name": "Custom workflow",
4819
+ "type": "user",
4820
+ "description": "This workflow custom build.",
4821
+ "raw_config": {"roles": ["Custom Annotator", "Custom QA"], ...}
4822
+ }
4823
+ ]
4824
+ """
4825
+ workflows = self .controller .service_provider .work_management .list_workflows (
4826
+ EmptyQuery ()
4827
+ )
4828
+ return BaseSerializer .serialize_iterable (workflows .data )
0 commit comments