annofabcli 1.106.5__py3-none-any.whl → 1.106.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- annofabcli/annotation/import_annotation.py +25 -16
- annofabcli/stat_visualization/write_performance_rating_csv.py +1 -1
- {annofabcli-1.106.5.dist-info → annofabcli-1.106.6.dist-info}/METADATA +1 -1
- {annofabcli-1.106.5.dist-info → annofabcli-1.106.6.dist-info}/RECORD +7 -7
- {annofabcli-1.106.5.dist-info → annofabcli-1.106.6.dist-info}/WHEEL +0 -0
- {annofabcli-1.106.5.dist-info → annofabcli-1.106.6.dist-info}/entry_points.txt +0 -0
- {annofabcli-1.106.5.dist-info → annofabcli-1.106.6.dist-info}/licenses/LICENSE +0 -0
|
@@ -9,6 +9,7 @@ import uuid
|
|
|
9
9
|
import zipfile
|
|
10
10
|
from collections.abc import Iterator
|
|
11
11
|
from dataclasses import dataclass
|
|
12
|
+
from functools import partial
|
|
12
13
|
from pathlib import Path
|
|
13
14
|
from typing import Any, Optional, Union
|
|
14
15
|
|
|
@@ -407,7 +408,6 @@ class ImportAnnotationMain(CommandLineWithConfirm):
|
|
|
407
408
|
is_force: bool,
|
|
408
409
|
is_merge: bool,
|
|
409
410
|
is_overwrite: bool,
|
|
410
|
-
converter: AnnotationConverter,
|
|
411
411
|
) -> None:
|
|
412
412
|
self.service = service
|
|
413
413
|
self.facade = AnnofabApiFacade(service)
|
|
@@ -417,9 +417,8 @@ class ImportAnnotationMain(CommandLineWithConfirm):
|
|
|
417
417
|
self.is_force = is_force
|
|
418
418
|
self.is_merge = is_merge
|
|
419
419
|
self.is_overwrite = is_overwrite
|
|
420
|
-
self.converter = converter
|
|
421
420
|
|
|
422
|
-
def put_annotation_for_input_data(self, parser: SimpleAnnotationParser) -> bool:
|
|
421
|
+
def put_annotation_for_input_data(self, parser: SimpleAnnotationParser, converter: AnnotationConverter) -> bool:
|
|
423
422
|
task_id = parser.task_id
|
|
424
423
|
input_data_id = parser.input_data_id
|
|
425
424
|
|
|
@@ -445,18 +444,18 @@ class ImportAnnotationMain(CommandLineWithConfirm):
|
|
|
445
444
|
|
|
446
445
|
logger.info(f"task_id='{task_id}', input_data_id='{input_data_id}' :: {len(simple_annotation.details)} 件のアノテーションを登録します。")
|
|
447
446
|
if self.is_merge:
|
|
448
|
-
request_body =
|
|
447
|
+
request_body = converter.convert_annotation_details(parser, simple_annotation.details, old_details=old_annotation["details"], updated_datetime=old_annotation["updated_datetime"])
|
|
449
448
|
else:
|
|
450
|
-
request_body =
|
|
449
|
+
request_body = converter.convert_annotation_details(parser, simple_annotation.details, old_details=[], updated_datetime=old_annotation["updated_datetime"])
|
|
451
450
|
|
|
452
451
|
self.service.api.put_annotation(self.project_id, task_id, input_data_id, request_body=request_body, query_params={"v": "2"})
|
|
453
452
|
return True
|
|
454
453
|
|
|
455
|
-
def put_annotation_for_task(self, task_parser: SimpleAnnotationParserByTask) -> int:
|
|
454
|
+
def put_annotation_for_task(self, task_parser: SimpleAnnotationParserByTask, converter: AnnotationConverter) -> int:
|
|
456
455
|
success_count = 0
|
|
457
456
|
for parser in task_parser.lazy_parse():
|
|
458
457
|
try:
|
|
459
|
-
if self.put_annotation_for_input_data(parser):
|
|
458
|
+
if self.put_annotation_for_input_data(parser, converter):
|
|
460
459
|
success_count += 1
|
|
461
460
|
except Exception: # pylint: disable=broad-except
|
|
462
461
|
logger.warning(
|
|
@@ -466,7 +465,7 @@ class ImportAnnotationMain(CommandLineWithConfirm):
|
|
|
466
465
|
|
|
467
466
|
return success_count
|
|
468
467
|
|
|
469
|
-
def execute_task(self, task_parser: SimpleAnnotationParserByTask, task_index: Optional[int] = None) -> bool:
|
|
468
|
+
def execute_task(self, task_parser: SimpleAnnotationParserByTask, converter: AnnotationConverter, task_index: Optional[int] = None) -> bool:
|
|
470
469
|
"""
|
|
471
470
|
1個のタスクに対してアノテーションを登録する。
|
|
472
471
|
|
|
@@ -515,7 +514,7 @@ class ImportAnnotationMain(CommandLineWithConfirm):
|
|
|
515
514
|
)
|
|
516
515
|
return False
|
|
517
516
|
|
|
518
|
-
result_count = self.put_annotation_for_task(task_parser)
|
|
517
|
+
result_count = self.put_annotation_for_task(task_parser, converter)
|
|
519
518
|
logger.info(f"{logger_prefix}タスク'{task_parser.task_id}'の入力データ {result_count} 個に対してアノテーションをインポートしました。")
|
|
520
519
|
|
|
521
520
|
if changed_operator:
|
|
@@ -532,20 +531,30 @@ class ImportAnnotationMain(CommandLineWithConfirm):
|
|
|
532
531
|
def execute_task_wrapper(
|
|
533
532
|
self,
|
|
534
533
|
tpl: tuple[int, SimpleAnnotationParserByTask],
|
|
534
|
+
converter: AnnotationConverter,
|
|
535
535
|
) -> bool:
|
|
536
536
|
task_index, task_parser = tpl
|
|
537
537
|
try:
|
|
538
|
-
return self.execute_task(task_parser, task_index=task_index)
|
|
538
|
+
return self.execute_task(task_parser, converter=converter, task_index=task_index)
|
|
539
539
|
except Exception: # pylint: disable=broad-except
|
|
540
540
|
logger.warning(f"task_id='{task_parser.task_id}' のアノテーションのインポートに失敗しました。", exc_info=True)
|
|
541
541
|
return False
|
|
542
542
|
|
|
543
|
-
def main(
|
|
543
|
+
def main(
|
|
544
544
|
self,
|
|
545
545
|
iter_task_parser: Iterator[SimpleAnnotationParserByTask],
|
|
546
|
+
converter: AnnotationConverter,
|
|
546
547
|
target_task_ids: Optional[set[str]] = None,
|
|
547
548
|
parallelism: Optional[int] = None,
|
|
548
|
-
):
|
|
549
|
+
) -> None:
|
|
550
|
+
"""
|
|
551
|
+
アノテーションのインポート処理を実行するメイン関数です。
|
|
552
|
+
|
|
553
|
+
Notes:
|
|
554
|
+
`converter`をインスタンス変数でなく引数として渡している理由:
|
|
555
|
+
`multiprocessing.Pool`でシリアライズ化する際、"TypeError: cannot pickle '_thread.RLock' object"というエラーが発生するため
|
|
556
|
+
"""
|
|
557
|
+
|
|
549
558
|
def get_iter_task_parser_from_task_ids(_iter_task_parser: Iterator[SimpleAnnotationParserByTask], _target_task_ids: set[str]) -> Iterator[SimpleAnnotationParserByTask]:
|
|
550
559
|
for task_parser in _iter_task_parser:
|
|
551
560
|
if task_parser.task_id in _target_task_ids:
|
|
@@ -562,14 +571,15 @@ class ImportAnnotationMain(CommandLineWithConfirm):
|
|
|
562
571
|
task_count = 0
|
|
563
572
|
if parallelism is not None:
|
|
564
573
|
with multiprocessing.Pool(parallelism) as pool:
|
|
565
|
-
|
|
574
|
+
func = partial(self.execute_task_wrapper, converter=converter)
|
|
575
|
+
result_bool_list = pool.map(func, enumerate(iter_task_parser))
|
|
566
576
|
success_count = len([e for e in result_bool_list if e])
|
|
567
577
|
task_count = len(result_bool_list)
|
|
568
578
|
|
|
569
579
|
else:
|
|
570
580
|
for task_index, task_parser in enumerate(iter_task_parser):
|
|
571
581
|
try:
|
|
572
|
-
result = self.execute_task(task_parser, task_index=task_index)
|
|
582
|
+
result = self.execute_task(task_parser, converter=converter, task_index=task_index)
|
|
573
583
|
if result:
|
|
574
584
|
success_count += 1
|
|
575
585
|
except Exception:
|
|
@@ -649,10 +659,9 @@ class ImportAnnotation(CommandLine):
|
|
|
649
659
|
is_merge=args.merge,
|
|
650
660
|
is_overwrite=args.overwrite,
|
|
651
661
|
is_force=args.force,
|
|
652
|
-
converter=converter,
|
|
653
662
|
)
|
|
654
663
|
|
|
655
|
-
main_obj.main(iter_task_parser, target_task_ids=target_task_ids, parallelism=args.parallelism)
|
|
664
|
+
main_obj.main(iter_task_parser, target_task_ids=target_task_ids, converter=converter, parallelism=args.parallelism)
|
|
656
665
|
|
|
657
666
|
|
|
658
667
|
def main(args: argparse.Namespace) -> None:
|
|
@@ -413,7 +413,7 @@ def create_rank_df(df: pandas.DataFrame, *, user_ids: Optional[Collection[str]]
|
|
|
413
413
|
df_rank[col] = to_rank(df[col])
|
|
414
414
|
|
|
415
415
|
if user_ids is not None:
|
|
416
|
-
return df_rank[df_rank[("user_id", "")].isin(user_ids)]
|
|
416
|
+
return df_rank[df_rank[("user_id", "", "")].isin(user_ids)]
|
|
417
417
|
else:
|
|
418
418
|
return df_rank
|
|
419
419
|
|
|
@@ -10,7 +10,7 @@ annofabcli/annotation/copy_annotation.py,sha256=Pih2k3vvpgfT3Ovb3gZw2L_8fK_ws_wK
|
|
|
10
10
|
annofabcli/annotation/delete_annotation.py,sha256=hQApNrx2Ci1bBWk0dRGA0oJkIgDHwl6Jy0-33gYF6jo,22989
|
|
11
11
|
annofabcli/annotation/download_annotation_zip.py,sha256=P_ZpdqIaSFEmB8jjpdykcRhh2tVlHxSlXFrYreJjShE,3282
|
|
12
12
|
annofabcli/annotation/dump_annotation.py,sha256=Q-p6f5XBs7khDgrfY5Q3CGLBMKEerJWO_CQ8_73UXVM,9972
|
|
13
|
-
annofabcli/annotation/import_annotation.py,sha256=
|
|
13
|
+
annofabcli/annotation/import_annotation.py,sha256=hVX2T7gN3pad2KI7TzB2_fnga7fnfRVTMGUa611m3xE,34612
|
|
14
14
|
annofabcli/annotation/list_annotation.py,sha256=uKcOuGC7lzd6vVbzizkiZtYdXJ7EzY0iifuiqKl2wQM,10707
|
|
15
15
|
annofabcli/annotation/list_annotation_count.py,sha256=T9fbaoxWeDJIVgW_YgHRldbwrVZWiE-57lfJrDQrj80,6474
|
|
16
16
|
annofabcli/annotation/merge_segmentation.py,sha256=kIsCeXtJxzd6nobQPpi0fscaRDlTx3tg1qpy5PDfSJI,18107
|
|
@@ -133,7 +133,7 @@ annofabcli/stat_visualization/merge_visualization_dir.py,sha256=7rOluAY7X5rcukWs
|
|
|
133
133
|
annofabcli/stat_visualization/subcommand_stat_visualization.py,sha256=vk-LPAjhfkTaGHC-pDLhwLCc0opF3hMz-0af3yichuA,1484
|
|
134
134
|
annofabcli/stat_visualization/summarize_whole_performance_csv.py,sha256=gPldqPECBqC61IdTw7JPAscUVRz76YluDiF3QOVnSEk,3099
|
|
135
135
|
annofabcli/stat_visualization/write_graph.py,sha256=gRO0LcZ6x7Jgln9ALUUM3BHTMaAt1H15PB4_0bRo8TI,9101
|
|
136
|
-
annofabcli/stat_visualization/write_performance_rating_csv.py,sha256
|
|
136
|
+
annofabcli/stat_visualization/write_performance_rating_csv.py,sha256=-eC_Nv9ohrLe3J4wvVHxvE8HJ35u1UMJP_fJCJHSKoU,31269
|
|
137
137
|
annofabcli/statistics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
138
138
|
annofabcli/statistics/histogram.py,sha256=CvzDxT2cKLSnBGSqkZE6p92PayGxYYja1YyB24M4ALU,3245
|
|
139
139
|
annofabcli/statistics/linegraph.py,sha256=0kr7jVBNMiM2ECYhv3Ry5RitElKerSl9ZKxbKzfiplI,12494
|
|
@@ -209,8 +209,8 @@ annofabcli/task_history_event/download_task_history_event_json.py,sha256=hQLVbQ0
|
|
|
209
209
|
annofabcli/task_history_event/list_all_task_history_event.py,sha256=EeKMyPUxGwYCFtWQHHW954ZserGm8lUqrwNnV1iX9X4,6830
|
|
210
210
|
annofabcli/task_history_event/list_worktime.py,sha256=Y7Pu5DP7scPf7HPt6CTiTvB1_5_Nfi1bStUIaCpkhII,15507
|
|
211
211
|
annofabcli/task_history_event/subcommand_task_history_event.py,sha256=mJVJoT4RXk4HWnY7-Nrsl4If-gtaIIEXd2z7eFZwM2I,1260
|
|
212
|
-
annofabcli-1.106.
|
|
213
|
-
annofabcli-1.106.
|
|
214
|
-
annofabcli-1.106.
|
|
215
|
-
annofabcli-1.106.
|
|
216
|
-
annofabcli-1.106.
|
|
212
|
+
annofabcli-1.106.6.dist-info/METADATA,sha256=6fqjbrE7DWDbXzS3Zo4GPm_oHeqhkdfjqqdUlySo8Rw,5286
|
|
213
|
+
annofabcli-1.106.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
214
|
+
annofabcli-1.106.6.dist-info/entry_points.txt,sha256=C2uSUc-kkLJpoK_mDL5FEMAdorLEMPfwSf8VBMYnIFM,56
|
|
215
|
+
annofabcli-1.106.6.dist-info/licenses/LICENSE,sha256=pcqWYfxFtxBzhvKp3x9MXNM4xciGb2eFewaRhXUNHlo,1081
|
|
216
|
+
annofabcli-1.106.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|