7272from lib .infrastructure .validators import wrap_error
7373from lib .app .serializers import WMProjectSerializer
7474from lib .core .entities .work_managament import WMUserTypeEnum
75+ from lib .core .jsx_conditions import EmptyQuery
76+
7577
7678logger = logging .getLogger ("sa" )
7779
@@ -1354,7 +1356,7 @@ def get_project_metadata(
13541356 the key "settings"
13551357 :type include_settings: bool
13561358
1357- :param include_workflow: Deprecated
1359+ :param include_workflow: Returns workflow metadata
13581360 :type include_workflow: bool
13591361
13601362 :param include_contributors: enables project contributors output under
@@ -1377,6 +1379,7 @@ def get_project_metadata(
13771379
13781380 client.get_project_metadata(
13791381 project="Medical Annotations",
1382+ include_workflow=True,
13801383 include_custom_fields=True
13811384 )
13821385
@@ -1385,50 +1388,53 @@ def get_project_metadata(
13851388 ::
13861389
13871390 {
1388- "classes": [],
1389- "completed_items_count": None,
1390- "contributors": [],
13911391 "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,
13921399 "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,
13931422 "custom_fields": {
13941423 "Notes": "Something",
13951424 "Ann Quality threshold": 80,
13961425 "Tag": ["Tag1", "Tag2", "Tag3"],
13971426 "Due date": 1738281600.0,
13981427 "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+ }
14171429 }
14181430 """
14191431 project_name , _ = extract_project_folder (project )
14201432 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- )
14281433 response = self .controller .projects .get_metadata (
14291434 project ,
14301435 include_annotation_classes ,
14311436 include_settings ,
1437+ include_workflow ,
14321438 include_contributors ,
14331439 include_complete_item_count ,
14341440 include_custom_fields ,
@@ -1464,18 +1470,6 @@ def get_project_settings(self, project: Union[NotEmptyStr, dict]):
14641470 ]
14651471 return settings
14661472
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-
14791473 def get_project_steps (self , project : Union [str , dict ]):
14801474 """Gets project's steps.
14811475
@@ -1509,10 +1503,10 @@ def get_project_steps(self, project: Union[str, dict]):
15091503 """
15101504 project_name , _ = extract_project_folder (project )
15111505 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
15161510
15171511 def search_annotation_classes (
15181512 self , project : Union [NotEmptyStr , dict ], name_contains : Optional [str ] = None
@@ -2502,19 +2496,6 @@ def download_export(
25022496 if response .errors :
25032497 raise AppException (response .errors )
25042498
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-
25182499 def set_project_steps (self , project : Union [NotEmptyStr , dict ], steps : List [dict ]):
25192500 """Sets project's steps.
25202501
@@ -2548,7 +2529,7 @@ def set_project_steps(self, project: Union[NotEmptyStr, dict], steps: List[dict]
25482529 """
25492530 project_name , _ = extract_project_folder (project )
25502531 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 )
25522533 if response .errors :
25532534 raise AppException (response .errors )
25542535
@@ -4781,3 +4762,46 @@ def item_context(
47814762 item = _item ,
47824763 overwrite = overwrite ,
47834764 )
4765+
4766+ def list_workflows (self ):
4767+ """
4768+ Lists team’s all workflows and their metadata
4769+
4770+ :return: metadata of workflows
4771+ :rtype: list of dicts
4772+
4773+
4774+ Request Example:
4775+ ::
4776+
4777+ client.list_workflows()
4778+
4779+
4780+ Response Example:
4781+ ::
4782+
4783+ [
4784+ {
4785+ "createdAt": "2024-09-03T12:48:09+00:00",
4786+ "updatedAt": "2024-09-04T12:48:09+00:00",
4787+ "id": 1,
4788+ "name": "System workflow",
4789+ "type": "system",
4790+ "description": "This workflow is generated by the system, and prevents annotators from completing items.",
4791+ "raw_config": {"roles": ["Annotator", "QA"], ...}
4792+ },
4793+ {
4794+ "createdAt": "2025-01-03T12:48:09+00:00",
4795+ "updatedAt": "2025-01-05T12:48:09+00:00",
4796+ "id": 58758,
4797+ "name": "Custom workflow",
4798+ "type": "user",
4799+ "description": "This workflow custom build.",
4800+ "raw_config": {"roles": ["Custom Annotator", "Custom QA"], ...}
4801+ }
4802+ ]
4803+ """
4804+ workflows = self .controller .service_provider .work_management .list_workflows (
4805+ EmptyQuery ()
4806+ )
4807+ return BaseSerializer .serialize_iterable (workflows .data )
0 commit comments