8
8
import annofabapi .utils
9
9
from annofabapi import AnnofabApi
10
10
from annofabapi .exceptions import AnnofabApiException
11
+ from annofabapi .typing import (AnnotationSpecs , InputData , Inspection ,
12
+ OrganizationMember , Project , ProjectJob ,
13
+ ProjectMember , SupplementaryData , Task )
11
14
12
15
logger = logging .getLogger (__name__ )
13
16
@@ -138,7 +141,7 @@ def get_all_annotation_list(self,
138
141
# Public Method : AfAnnotationSpecsApi
139
142
#########################################
140
143
def copy_annotation_specs (self , src_project_id : str ,
141
- dest_project_id : str ) -> Dict [ str , Any ] :
144
+ dest_project_id : str ) -> AnnotationSpecs :
142
145
"""
143
146
アノテーション仕様を、別のプロジェクトにコピーする。
144
147
【注意】誤って実行しないようにすること
@@ -166,7 +169,7 @@ def copy_annotation_specs(self, src_project_id: str,
166
169
def get_all_input_data_list (self ,
167
170
project_id : str ,
168
171
query_params : Optional [Dict [str , Any ]] = None
169
- ) -> List [Dict [ str , Any ] ]:
172
+ ) -> List [InputData ]:
170
173
"""
171
174
すべての入力データを取得する。
172
175
Args:
@@ -227,7 +230,7 @@ def put_input_data_from_file(self,
227
230
file_path : str ,
228
231
request_body : Optional [Dict [str , Any ]] = None ,
229
232
content_type : Optional [str ] = None
230
- ) -> Dict [ str , Any ] :
233
+ ) -> InputData :
231
234
"""
232
235
ファイル(画像 or zip)を入力データとして登録する。
233
236
zipファイルを指定した場合は、登録が完了した後「ZIPアップロードジョブエラー削除」(delete_project_job)を実施する必要がある。
@@ -264,7 +267,7 @@ def put_supplementary_data_from_file(self,
264
267
file_path : str ,
265
268
request_body : Dict [str , Any ],
266
269
content_type : Optional [str ] = None
267
- ) -> Dict [ str , Any ] :
270
+ ) -> SupplementaryData :
268
271
"""
269
272
補助情報ファイルをアップロードする
270
273
Args:
@@ -313,14 +316,60 @@ def put_supplementary_data_from_file(self,
313
316
supplementary_data_id ,
314
317
request_body = copied_request_body )[0 ]
315
318
319
+ #########################################
320
+ # Public Method : AfInspection
321
+ #########################################
322
+ def update_status_of_inspections (
323
+ self , project_id : str , task_id : str , input_data_id : str ,
324
+ filter_inspection : Callable [[Inspection ], bool ],
325
+ inspection_status : str ) -> List [Inspection ]:
326
+ """
327
+ 検査コメント(返信コメント以外)のstatusを変更する。
328
+ Args:
329
+ project_id: プロジェクトID
330
+ task_id: タスクID
331
+ input_data_id: 入力データID
332
+ filter_inspection: 変更対象の検査コメントを絞り込む条件
333
+ inspection_status: 検査コメントのstatus
334
+
335
+ Returns:
336
+ 変更後の検査コメント一覧
337
+ """
338
+
339
+ def not_reply_comment (arg_inspection : Inspection ) -> bool :
340
+ """返信コメントでないならTrueをかえす"""
341
+ return arg_inspection ["parent_inspection_id" ] is None
342
+
343
+ inspections , _ = self .api .get_inspections (project_id , task_id ,
344
+ input_data_id )
345
+
346
+ target_inspections = [
347
+ e for e in inspections
348
+ if filter_inspection (e ) and not_reply_comment (e )
349
+ ]
350
+
351
+ for inspection in target_inspections :
352
+ inspection ["status" ] = inspection_status
353
+ if inspection ["updated_datetime" ] is None :
354
+ inspection ["updated_datetime" ] = inspection ["created_datetime" ]
355
+ else :
356
+ inspection ["updated_datetime" ] = annofabapi .utils .str_now ()
357
+
358
+ req_inspection = [{
359
+ "data" : e ,
360
+ "_type" : "Put"
361
+ } for e in target_inspections ]
362
+ return self .api .batch_update_inspections (project_id , task_id ,
363
+ input_data_id ,
364
+ req_inspection )[0 ]
365
+
316
366
#########################################
317
367
# Public Method : AfOrganizationApi
318
368
#########################################
319
369
def get_all_projects_of_organization (
320
370
self ,
321
371
organization_name : str ,
322
- query_params : Optional [Dict [str , Any ]] = None
323
- ) -> List [Dict [str , Any ]]:
372
+ query_params : Optional [Dict [str , Any ]] = None ) -> List [Project ]:
324
373
"""
325
374
組織配下のすべてのプロジェクト一覧を取得する
326
375
Args:
@@ -342,7 +391,7 @@ def get_all_organization_members(
342
391
self ,
343
392
organization_name : str ,
344
393
query_params : Optional [Dict [str , Any ]] = None
345
- ) -> List [Dict [ str , Any ] ]:
394
+ ) -> List [OrganizationMember ]:
346
395
"""
347
396
すべての組織メンバ一覧を取得する
348
397
Args:
@@ -423,7 +472,7 @@ def download_project_task_history_events_url(self, project_id: str,
423
472
def get_all_project_members (self ,
424
473
project_id : str ,
425
474
query_params : Optional [Dict [str , Any ]] = None
426
- ) -> List [Dict [ str , Any ] ]:
475
+ ) -> List [ProjectMember ]:
427
476
"""
428
477
すべてのプロジェクトメンバを取得する
429
478
Args:
@@ -440,7 +489,7 @@ def get_all_project_members(self,
440
489
441
490
def put_project_members (self , project_id ,
442
491
project_members : List [Dict [str , Any ]]
443
- ) -> List [Dict [ str , Any ] ]:
492
+ ) -> List [ProjectMember ]:
444
493
"""
445
494
複数のプロジェクトメンバを追加/更新/削除する.
446
495
【注意】誤って実行しないようにすること
@@ -484,7 +533,7 @@ def put_project_members(self, project_id,
484
533
def assign_role_to_project_members (self , project_id : str ,
485
534
user_id_list : List [str ],
486
535
member_role : str
487
- ) -> List [Dict [ str , Any ] ]:
536
+ ) -> List [ProjectMember ]:
488
537
"""
489
538
複数のプロジェクトメンバに1つのロールを割り当てる。
490
539
【注意】誤って実行しないようにすること
@@ -509,7 +558,7 @@ def assign_role_to_project_members(self, project_id: str,
509
558
return self .put_project_members (project_id , project_members )
510
559
511
560
def drop_role_to_project_members (self , project_id , user_id_list : List [str ]
512
- ) -> List [Dict [ str , Any ] ]:
561
+ ) -> List [ProjectMember ]:
513
562
"""
514
563
複数のプロジェクトメンバを、プロジェクトから脱退させる
515
564
【注意】誤って実行しないようにすること
@@ -534,8 +583,7 @@ def drop_role_to_project_members(self, project_id, user_id_list: List[str]
534
583
def copy_project_members (self ,
535
584
src_project_id : str ,
536
585
dest_project_id : str ,
537
- delete_dest : bool = False
538
- ) -> List [Dict [str , Any ]]:
586
+ delete_dest : bool = False ) -> List [ProjectMember ]:
539
587
"""
540
588
プロジェクトメンバを、別のプロジェクトにコピーする。
541
589
【注意】誤って実行しないようにすること
@@ -606,7 +654,7 @@ def initiate_tasks_generation_by_csv(self, project_id: str,
606
654
def get_all_tasks (self ,
607
655
project_id : str ,
608
656
query_params : Optional [Dict [str , Any ]] = None
609
- ) -> List [Dict [ str , Any ] ]:
657
+ ) -> List [Task ]:
610
658
"""
611
659
すべてのタスクを取得する。
612
660
Args:
@@ -688,7 +736,7 @@ def upload_instruction_image(self,
688
736
# Public Method : AfJobApi
689
737
#########################################
690
738
def delete_all_succeeded_job (self , project_id : str ,
691
- job_type : str ) -> List [Dict [ str , Any ] ]:
739
+ job_type : str ) -> List [ProjectJob ]:
692
740
"""
693
741
成功したジョブをすべて削除する
694
742
Args:
@@ -707,8 +755,8 @@ def delete_all_succeeded_job(self, project_id: str,
707
755
708
756
return deleted_jobs
709
757
710
- def get_all_project_job (self , project_id : str , query_params : Dict [ str , Any ]
711
- ) -> List [ Dict [str , Any ]]:
758
+ def get_all_project_job (self , project_id : str ,
759
+ query_params : Dict [str , Any ]) -> List [ ProjectJob ]:
712
760
"""
713
761
すべてのバックグランドジョブを取得する。
714
762
2019/01時点でAPIが未実装のため、このメソッドも未実装。
0 commit comments