annofabcli 1.114.3__py3-none-any.whl → 1.114.4__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/list_annotation.py +4 -4
- annofabcli/annotation/list_annotation_count.py +4 -4
- annofabcli/annotation_specs/export_annotation_specs.py +4 -4
- annofabcli/annotation_specs/get_annotation_specs_with_attribute_id_replaced.py +4 -4
- annofabcli/annotation_specs/get_annotation_specs_with_choice_id_replaced.py +4 -4
- annofabcli/annotation_specs/get_annotation_specs_with_label_id_replaced.py +4 -4
- annofabcli/annotation_specs/list_annotation_specs_attribute.py +7 -7
- annofabcli/annotation_specs/list_annotation_specs_choice.py +9 -9
- annofabcli/annotation_specs/list_annotation_specs_history.py +2 -2
- annofabcli/annotation_specs/list_annotation_specs_label.py +8 -8
- annofabcli/annotation_specs/list_annotation_specs_label_attribute.py +7 -7
- annofabcli/annotation_specs/list_label_color.py +2 -2
- annofabcli/annotation_zip/list_annotation_3d_bounding_box.py +8 -8
- annofabcli/annotation_zip/list_annotation_bounding_box_2d.py +8 -8
- annofabcli/annotation_zip/list_polygon_annotation.py +8 -8
- annofabcli/annotation_zip/list_polyline_annotation.py +8 -8
- annofabcli/annotation_zip/list_range_annotation.py +8 -8
- annofabcli/annotation_zip/list_single_point_annotation.py +8 -8
- annofabcli/annotation_zip/validate_annotation.py +2 -2
- annofabcli/comment/list_all_comment.py +8 -8
- annofabcli/comment/list_comment.py +8 -8
- annofabcli/common/cli.py +3 -3
- annofabcli/common/enums.py +1 -1
- annofabcli/common/pandas.py +4 -3
- annofabcli/common/utils.py +10 -10
- annofabcli/common/visualize.py +3 -3
- annofabcli/filesystem/mask_user_info.py +3 -2
- annofabcli/input_data/list_all_input_data.py +11 -22
- annofabcli/input_data/list_all_input_data_merged_task.py +7 -7
- annofabcli/input_data/list_input_data.py +67 -18
- annofabcli/instruction/list_instruction_history.py +2 -2
- annofabcli/job/list_job.py +2 -2
- annofabcli/job/list_last_job.py +2 -2
- annofabcli/my_account/get_my_account.py +4 -4
- annofabcli/organization/list_organization.py +5 -5
- annofabcli/organization_member/list_organization_member.py +4 -4
- annofabcli/project/list_project.py +9 -9
- annofabcli/project_member/list_users.py +4 -4
- annofabcli/statistics/list_annotation_area.py +8 -8
- annofabcli/statistics/list_annotation_attribute.py +8 -8
- annofabcli/statistics/list_annotation_attribute_filled_count.py +11 -11
- annofabcli/statistics/list_annotation_count.py +8 -8
- annofabcli/statistics/list_annotation_duration.py +8 -8
- annofabcli/statistics/list_video_duration.py +6 -6
- annofabcli/statistics/summarize_task_count_by_task_id_group.py +2 -2
- annofabcli/statistics/summarize_task_count_by_user.py +2 -2
- annofabcli/statistics/visualization/dataframe/project_performance.py +2 -1
- annofabcli/statistics/visualization/dataframe/task.py +25 -6
- annofabcli/supplementary/list_supplementary_data.py +2 -2
- annofabcli/task/list_all_tasks.py +8 -18
- annofabcli/task/list_all_tasks_added_task_history.py +6 -6
- annofabcli/task/list_tasks.py +73 -37
- annofabcli/task/list_tasks_added_task_history.py +25 -16
- annofabcli/task_history/list_all_task_history.py +6 -6
- annofabcli/task_history/list_task_history.py +6 -6
- annofabcli/task_history_event/list_all_task_history_event.py +6 -6
- annofabcli/task_history_event/list_worktime.py +6 -6
- {annofabcli-1.114.3.dist-info → annofabcli-1.114.4.dist-info}/METADATA +2 -2
- {annofabcli-1.114.3.dist-info → annofabcli-1.114.4.dist-info}/RECORD +62 -62
- {annofabcli-1.114.3.dist-info → annofabcli-1.114.4.dist-info}/WHEEL +0 -0
- {annofabcli-1.114.3.dist-info → annofabcli-1.114.4.dist-info}/entry_points.txt +0 -0
- {annofabcli-1.114.3.dist-info → annofabcli-1.114.4.dist-info}/licenses/LICENSE +0 -0
|
@@ -3,7 +3,7 @@ import logging
|
|
|
3
3
|
|
|
4
4
|
import annofabcli.common.cli
|
|
5
5
|
from annofabcli.common.cli import ArgumentParser, CommandLine, build_annofabapi_resource_and_login
|
|
6
|
-
from annofabcli.common.enums import
|
|
6
|
+
from annofabcli.common.enums import OutputFormat
|
|
7
7
|
from annofabcli.common.facade import AnnofabApiFacade
|
|
8
8
|
|
|
9
9
|
logger = logging.getLogger(__name__)
|
|
@@ -27,11 +27,11 @@ def parse_args(parser: argparse.ArgumentParser) -> None:
|
|
|
27
27
|
|
|
28
28
|
argument_parser.add_format(
|
|
29
29
|
choices=[
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
OutputFormat.CSV,
|
|
31
|
+
OutputFormat.JSON,
|
|
32
|
+
OutputFormat.PRETTY_JSON,
|
|
33
33
|
],
|
|
34
|
-
default=
|
|
34
|
+
default=OutputFormat.CSV,
|
|
35
35
|
)
|
|
36
36
|
argument_parser.add_output()
|
|
37
37
|
|
|
@@ -7,7 +7,7 @@ import requests
|
|
|
7
7
|
|
|
8
8
|
import annofabcli.common.cli
|
|
9
9
|
from annofabcli.common.cli import ArgumentParser, CommandLine, build_annofabapi_resource_and_login
|
|
10
|
-
from annofabcli.common.enums import
|
|
10
|
+
from annofabcli.common.enums import OutputFormat
|
|
11
11
|
from annofabcli.common.facade import AnnofabApiFacade
|
|
12
12
|
from annofabcli.common.utils import get_columns_with_priority
|
|
13
13
|
|
|
@@ -52,7 +52,7 @@ class ListOrganizationMember(CommandLine):
|
|
|
52
52
|
logger.warning(f"組織'{organization_name}'のメンバー一覧を取得できませんでした。", exc_info=True)
|
|
53
53
|
continue
|
|
54
54
|
|
|
55
|
-
if args.format ==
|
|
55
|
+
if args.format == OutputFormat.CSV.value:
|
|
56
56
|
df = pandas.DataFrame(organization_member_list)
|
|
57
57
|
columns = get_columns_with_priority(df, prior_columns=self.PRIOR_COLUMNS)
|
|
58
58
|
self.print_csv(df[columns])
|
|
@@ -79,8 +79,8 @@ def parse_args(parser: argparse.ArgumentParser) -> None:
|
|
|
79
79
|
)
|
|
80
80
|
|
|
81
81
|
argument_parser.add_format(
|
|
82
|
-
choices=[
|
|
83
|
-
default=
|
|
82
|
+
choices=[OutputFormat.CSV, OutputFormat.JSON, OutputFormat.PRETTY_JSON, OutputFormat.USER_ID_LIST],
|
|
83
|
+
default=OutputFormat.CSV,
|
|
84
84
|
)
|
|
85
85
|
argument_parser.add_output()
|
|
86
86
|
|
|
@@ -15,7 +15,7 @@ from annofabcli.common.cli import (
|
|
|
15
15
|
CommandLine,
|
|
16
16
|
build_annofabapi_resource_and_login,
|
|
17
17
|
)
|
|
18
|
-
from annofabcli.common.enums import
|
|
18
|
+
from annofabcli.common.enums import OutputFormat
|
|
19
19
|
from annofabcli.common.facade import AnnofabApiFacade
|
|
20
20
|
from annofabcli.common.utils import get_columns_with_priority
|
|
21
21
|
|
|
@@ -186,10 +186,10 @@ class ListProject(CommandLine):
|
|
|
186
186
|
|
|
187
187
|
logger.info(f"プロジェクト一覧の件数: {len(project_list)}")
|
|
188
188
|
|
|
189
|
-
if args.format ==
|
|
189
|
+
if args.format == OutputFormat.MINIMAL_CSV.value:
|
|
190
190
|
df = create_minimal_dataframe(project_list)
|
|
191
191
|
self.print_csv(df)
|
|
192
|
-
elif args.format ==
|
|
192
|
+
elif args.format == OutputFormat.CSV.value:
|
|
193
193
|
df = pandas.DataFrame(project_list)
|
|
194
194
|
columns = get_columns_with_priority(df, prior_columns=self.PRIOR_COLUMNS)
|
|
195
195
|
self.print_csv(df[columns])
|
|
@@ -241,13 +241,13 @@ def parse_args(parser: argparse.ArgumentParser) -> None:
|
|
|
241
241
|
|
|
242
242
|
argument_parser.add_format(
|
|
243
243
|
choices=[
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
244
|
+
OutputFormat.CSV,
|
|
245
|
+
OutputFormat.MINIMAL_CSV,
|
|
246
|
+
OutputFormat.JSON,
|
|
247
|
+
OutputFormat.PRETTY_JSON,
|
|
248
|
+
OutputFormat.PROJECT_ID_LIST,
|
|
249
249
|
],
|
|
250
|
-
default=
|
|
250
|
+
default=OutputFormat.CSV,
|
|
251
251
|
)
|
|
252
252
|
argument_parser.add_output()
|
|
253
253
|
|
|
@@ -7,7 +7,7 @@ from annofabapi.models import ProjectMember
|
|
|
7
7
|
|
|
8
8
|
import annofabcli.common.cli
|
|
9
9
|
from annofabcli.common.cli import ArgumentParser, CommandLine, build_annofabapi_resource_and_login
|
|
10
|
-
from annofabcli.common.enums import
|
|
10
|
+
from annofabcli.common.enums import OutputFormat
|
|
11
11
|
from annofabcli.common.facade import AnnofabApiFacade
|
|
12
12
|
from annofabcli.common.utils import get_columns_with_priority
|
|
13
13
|
from annofabcli.common.visualize import AddProps
|
|
@@ -75,7 +75,7 @@ class ListUser(CommandLine):
|
|
|
75
75
|
)
|
|
76
76
|
|
|
77
77
|
logger.info(f"プロジェクトメンバ一覧の件数: {len(project_members)}")
|
|
78
|
-
if args.format ==
|
|
78
|
+
if args.format == OutputFormat.CSV.value:
|
|
79
79
|
df = pandas.DataFrame(project_members)
|
|
80
80
|
columns = get_columns_with_priority(df, prior_columns=self.PRIOR_COLUMNS)
|
|
81
81
|
self.print_csv(df[columns])
|
|
@@ -104,8 +104,8 @@ def parse_args(parser: argparse.ArgumentParser) -> None:
|
|
|
104
104
|
parser.add_argument("--include_inactive", action="store_true", help="脱退しているメンバも出力します。")
|
|
105
105
|
|
|
106
106
|
argument_parser.add_format(
|
|
107
|
-
choices=[
|
|
108
|
-
default=
|
|
107
|
+
choices=[OutputFormat.CSV, OutputFormat.JSON, OutputFormat.PRETTY_JSON, OutputFormat.USER_ID_LIST],
|
|
108
|
+
default=OutputFormat.CSV,
|
|
109
109
|
)
|
|
110
110
|
argument_parser.add_output()
|
|
111
111
|
|
|
@@ -30,7 +30,7 @@ from annofabcli.common.cli import (
|
|
|
30
30
|
build_annofabapi_resource_and_login,
|
|
31
31
|
)
|
|
32
32
|
from annofabcli.common.download import DownloadingFile
|
|
33
|
-
from annofabcli.common.enums import
|
|
33
|
+
from annofabcli.common.enums import OutputFormat
|
|
34
34
|
from annofabcli.common.facade import (
|
|
35
35
|
AnnofabApiFacade,
|
|
36
36
|
TaskQuery,
|
|
@@ -189,7 +189,7 @@ def create_df(
|
|
|
189
189
|
def print_annotation_area(
|
|
190
190
|
annotation_path: Path,
|
|
191
191
|
output_file: Path,
|
|
192
|
-
output_format:
|
|
192
|
+
output_format: OutputFormat,
|
|
193
193
|
*,
|
|
194
194
|
target_task_ids: Collection[str] | None = None,
|
|
195
195
|
task_query: TaskQuery | None = None,
|
|
@@ -202,12 +202,12 @@ def print_annotation_area(
|
|
|
202
202
|
|
|
203
203
|
logger.info(f"{len(annotation_area_list)} 件のタスクに含まれる塗りつぶし、矩形、ポリゴンアノテーションの面積情報を出力します。")
|
|
204
204
|
|
|
205
|
-
if output_format ==
|
|
205
|
+
if output_format == OutputFormat.CSV:
|
|
206
206
|
df = create_df(annotation_area_list)
|
|
207
207
|
print_csv(df, output_file)
|
|
208
208
|
|
|
209
|
-
elif output_format in [
|
|
210
|
-
json_is_pretty = output_format ==
|
|
209
|
+
elif output_format in [OutputFormat.PRETTY_JSON, OutputFormat.JSON]:
|
|
210
|
+
json_is_pretty = output_format == OutputFormat.PRETTY_JSON
|
|
211
211
|
print_json(
|
|
212
212
|
[e.to_dict(encode_json=True) for e in annotation_area_list],
|
|
213
213
|
is_pretty=json_is_pretty,
|
|
@@ -249,7 +249,7 @@ class ListAnnotationArea(CommandLine):
|
|
|
249
249
|
task_query = TaskQuery.from_dict(annofabcli.common.cli.get_json_from_args(args.task_query)) if args.task_query is not None else None
|
|
250
250
|
|
|
251
251
|
output_file: Path = args.output
|
|
252
|
-
output_format =
|
|
252
|
+
output_format = OutputFormat(args.format)
|
|
253
253
|
|
|
254
254
|
downloading_obj = DownloadingFile(self.service)
|
|
255
255
|
|
|
@@ -298,8 +298,8 @@ def parse_args(parser: argparse.ArgumentParser) -> None:
|
|
|
298
298
|
group.add_argument("-p", "--project_id", type=str, help="project_id。``--annotation`` が未指定のときは必須です。\n")
|
|
299
299
|
|
|
300
300
|
argument_parser.add_format(
|
|
301
|
-
choices=[
|
|
302
|
-
default=
|
|
301
|
+
choices=[OutputFormat.CSV, OutputFormat.JSON, OutputFormat.PRETTY_JSON],
|
|
302
|
+
default=OutputFormat.CSV,
|
|
303
303
|
)
|
|
304
304
|
|
|
305
305
|
argument_parser.add_output()
|
|
@@ -27,7 +27,7 @@ from annofabcli.common.cli import (
|
|
|
27
27
|
build_annofabapi_resource_and_login,
|
|
28
28
|
)
|
|
29
29
|
from annofabcli.common.download import DownloadingFile
|
|
30
|
-
from annofabcli.common.enums import
|
|
30
|
+
from annofabcli.common.enums import OutputFormat
|
|
31
31
|
from annofabcli.common.facade import (
|
|
32
32
|
AnnofabApiFacade,
|
|
33
33
|
TaskQuery,
|
|
@@ -164,14 +164,14 @@ def print_annotation_attribute_list_as_csv(annotation_attribute_list: list, outp
|
|
|
164
164
|
def print_annotation_attribute_list(
|
|
165
165
|
annotation_attribute_list: list[AnnotationAttribute],
|
|
166
166
|
output_file: Path,
|
|
167
|
-
output_format: Literal[
|
|
167
|
+
output_format: Literal[OutputFormat.CSV, OutputFormat.JSON, OutputFormat.PRETTY_JSON],
|
|
168
168
|
) -> None:
|
|
169
169
|
tmp_annotation_attribute_list = [e.model_dump() for e in annotation_attribute_list]
|
|
170
|
-
if output_format ==
|
|
170
|
+
if output_format == OutputFormat.CSV:
|
|
171
171
|
print_annotation_attribute_list_as_csv(tmp_annotation_attribute_list, output_file)
|
|
172
|
-
elif output_format ==
|
|
172
|
+
elif output_format == OutputFormat.JSON:
|
|
173
173
|
print_json(tmp_annotation_attribute_list, output=output_file, is_pretty=False)
|
|
174
|
-
elif output_format ==
|
|
174
|
+
elif output_format == OutputFormat.PRETTY_JSON:
|
|
175
175
|
print_json(tmp_annotation_attribute_list, output=output_file, is_pretty=True)
|
|
176
176
|
else:
|
|
177
177
|
raise assert_noreturn(output_format)
|
|
@@ -207,7 +207,7 @@ class ListAnnotationAttribute(CommandLine):
|
|
|
207
207
|
task_query = TaskQuery.from_dict(annofabcli.common.cli.get_json_from_args(args.task_query)) if args.task_query is not None else None
|
|
208
208
|
|
|
209
209
|
output_file: Path = args.output
|
|
210
|
-
output_format =
|
|
210
|
+
output_format = OutputFormat(args.format)
|
|
211
211
|
|
|
212
212
|
downloading_obj = DownloadingFile(self.service)
|
|
213
213
|
|
|
@@ -254,8 +254,8 @@ def parse_args(parser: argparse.ArgumentParser) -> None:
|
|
|
254
254
|
annotation_group.add_argument("-p", "--project_id", type=str, help="対象プロジェクトの project_id")
|
|
255
255
|
|
|
256
256
|
argument_parser.add_format(
|
|
257
|
-
choices=[
|
|
258
|
-
default=
|
|
257
|
+
choices=[OutputFormat.CSV, OutputFormat.JSON, OutputFormat.PRETTY_JSON],
|
|
258
|
+
default=OutputFormat.CSV,
|
|
259
259
|
)
|
|
260
260
|
|
|
261
261
|
argument_parser.add_output()
|
|
@@ -36,7 +36,7 @@ from annofabcli.common.cli import (
|
|
|
36
36
|
build_annofabapi_resource_and_login,
|
|
37
37
|
)
|
|
38
38
|
from annofabcli.common.download import DownloadingFile
|
|
39
|
-
from annofabcli.common.enums import
|
|
39
|
+
from annofabcli.common.enums import OutputFormat
|
|
40
40
|
from annofabcli.common.facade import (
|
|
41
41
|
AnnofabApiFacade,
|
|
42
42
|
TaskQuery,
|
|
@@ -480,7 +480,7 @@ class ListAnnotationAttributeFilledCountMain:
|
|
|
480
480
|
annotation_path: Path,
|
|
481
481
|
output_file: Path,
|
|
482
482
|
group_by: GroupBy,
|
|
483
|
-
output_format:
|
|
483
|
+
output_format: OutputFormat,
|
|
484
484
|
*,
|
|
485
485
|
project_id: str | None = None,
|
|
486
486
|
include_flag_attribute: bool = False,
|
|
@@ -505,11 +505,11 @@ class ListAnnotationAttributeFilledCountMain:
|
|
|
505
505
|
|
|
506
506
|
if group_by == GroupBy.INPUT_DATA_ID:
|
|
507
507
|
logger.info(f"{len(annotation_count_list_by_input_data)} 件の入力データに含まれるアノテーション数の情報を出力します。")
|
|
508
|
-
if output_format ==
|
|
508
|
+
if output_format == OutputFormat.CSV:
|
|
509
509
|
self.print_annotation_count_csv_by_input_data(annotation_count_list_by_input_data, output_file=output_file, attribute_names=target_attribute_names)
|
|
510
510
|
|
|
511
|
-
elif output_format in [
|
|
512
|
-
json_is_pretty = output_format ==
|
|
511
|
+
elif output_format in [OutputFormat.PRETTY_JSON, OutputFormat.JSON]:
|
|
512
|
+
json_is_pretty = output_format == OutputFormat.PRETTY_JSON
|
|
513
513
|
|
|
514
514
|
print_json(
|
|
515
515
|
[e.to_dict(encode_json=True) for e in annotation_count_list_by_input_data],
|
|
@@ -519,11 +519,11 @@ class ListAnnotationAttributeFilledCountMain:
|
|
|
519
519
|
elif group_by == GroupBy.TASK_ID:
|
|
520
520
|
annotation_count_list_by_task = convert_annotation_count_list_by_input_data_to_by_task(annotation_count_list_by_input_data)
|
|
521
521
|
logger.info(f"{len(annotation_count_list_by_task)} 件のタスクに含まれるアノテーション数の情報を出力します。")
|
|
522
|
-
if output_format ==
|
|
522
|
+
if output_format == OutputFormat.CSV:
|
|
523
523
|
self.print_annotation_count_csv_by_task(annotation_count_list_by_task, output_file=output_file, attribute_names=target_attribute_names)
|
|
524
524
|
|
|
525
|
-
elif output_format in [
|
|
526
|
-
json_is_pretty = output_format ==
|
|
525
|
+
elif output_format in [OutputFormat.PRETTY_JSON, OutputFormat.JSON]:
|
|
526
|
+
json_is_pretty = output_format == OutputFormat.PRETTY_JSON
|
|
527
527
|
|
|
528
528
|
print_json(
|
|
529
529
|
[e.to_dict(encode_json=True) for e in annotation_count_list_by_task],
|
|
@@ -565,7 +565,7 @@ class ListAnnotationAttributeFilledCount(CommandLine):
|
|
|
565
565
|
|
|
566
566
|
group_by = GroupBy(args.group_by)
|
|
567
567
|
output_file: Path = args.output
|
|
568
|
-
output_format =
|
|
568
|
+
output_format = OutputFormat(args.format)
|
|
569
569
|
main_obj = ListAnnotationAttributeFilledCountMain(self.service)
|
|
570
570
|
|
|
571
571
|
downloading_obj = DownloadingFile(self.service)
|
|
@@ -668,8 +668,8 @@ def parse_args(parser: argparse.ArgumentParser) -> None:
|
|
|
668
668
|
)
|
|
669
669
|
|
|
670
670
|
argument_parser.add_format(
|
|
671
|
-
choices=[
|
|
672
|
-
default=
|
|
671
|
+
choices=[OutputFormat.CSV, OutputFormat.JSON, OutputFormat.PRETTY_JSON],
|
|
672
|
+
default=OutputFormat.CSV,
|
|
673
673
|
)
|
|
674
674
|
|
|
675
675
|
argument_parser.add_output()
|
|
@@ -40,7 +40,7 @@ from annofabcli.common.cli import (
|
|
|
40
40
|
build_annofabapi_resource_and_login,
|
|
41
41
|
)
|
|
42
42
|
from annofabcli.common.download import DownloadingFile
|
|
43
|
-
from annofabcli.common.enums import
|
|
43
|
+
from annofabcli.common.enums import OutputFormat
|
|
44
44
|
from annofabcli.common.facade import (
|
|
45
45
|
AnnofabApiFacade,
|
|
46
46
|
TaskQuery,
|
|
@@ -1001,7 +1001,7 @@ class ListAnnotationCountMain:
|
|
|
1001
1001
|
annotation_path: Path,
|
|
1002
1002
|
group_by: GroupBy,
|
|
1003
1003
|
output_file: Path,
|
|
1004
|
-
arg_format:
|
|
1004
|
+
arg_format: OutputFormat,
|
|
1005
1005
|
*,
|
|
1006
1006
|
project_id: str | None = None,
|
|
1007
1007
|
task_json_path: Path | None = None,
|
|
@@ -1010,7 +1010,7 @@ class ListAnnotationCountMain:
|
|
|
1010
1010
|
csv_type: CsvType | None = None,
|
|
1011
1011
|
) -> None:
|
|
1012
1012
|
"""ラベルごと/属性ごとのアノテーション数を出力します。"""
|
|
1013
|
-
if arg_format ==
|
|
1013
|
+
if arg_format == OutputFormat.CSV:
|
|
1014
1014
|
assert csv_type is not None
|
|
1015
1015
|
if group_by == GroupBy.INPUT_DATA_ID:
|
|
1016
1016
|
self.print_annotation_counter_csv_by_input_data(
|
|
@@ -1033,8 +1033,8 @@ class ListAnnotationCountMain:
|
|
|
1033
1033
|
csv_type=csv_type,
|
|
1034
1034
|
)
|
|
1035
1035
|
|
|
1036
|
-
elif arg_format in [
|
|
1037
|
-
json_is_pretty = arg_format ==
|
|
1036
|
+
elif arg_format in [OutputFormat.PRETTY_JSON, OutputFormat.JSON]:
|
|
1037
|
+
json_is_pretty = arg_format == OutputFormat.PRETTY_JSON
|
|
1038
1038
|
|
|
1039
1039
|
if group_by == GroupBy.INPUT_DATA_ID:
|
|
1040
1040
|
self.print_annotation_counter_json_by_input_data(
|
|
@@ -1093,7 +1093,7 @@ class ListAnnotationCount(CommandLine):
|
|
|
1093
1093
|
group_by = GroupBy(args.group_by)
|
|
1094
1094
|
csv_type = CsvType(args.type)
|
|
1095
1095
|
output_file: Path = args.output
|
|
1096
|
-
arg_format =
|
|
1096
|
+
arg_format = OutputFormat(args.format)
|
|
1097
1097
|
main_obj = ListAnnotationCountMain(self.service)
|
|
1098
1098
|
|
|
1099
1099
|
downloading_obj = DownloadingFile(self.service)
|
|
@@ -1191,8 +1191,8 @@ def parse_args(parser: argparse.ArgumentParser) -> None:
|
|
|
1191
1191
|
)
|
|
1192
1192
|
|
|
1193
1193
|
argument_parser.add_format(
|
|
1194
|
-
choices=[
|
|
1195
|
-
default=
|
|
1194
|
+
choices=[OutputFormat.CSV, OutputFormat.JSON, OutputFormat.PRETTY_JSON],
|
|
1195
|
+
default=OutputFormat.CSV,
|
|
1196
1196
|
)
|
|
1197
1197
|
|
|
1198
1198
|
argument_parser.add_output()
|
|
@@ -34,7 +34,7 @@ from annofabcli.common.cli import (
|
|
|
34
34
|
build_annofabapi_resource_and_login,
|
|
35
35
|
)
|
|
36
36
|
from annofabcli.common.download import DownloadingFile
|
|
37
|
-
from annofabcli.common.enums import
|
|
37
|
+
from annofabcli.common.enums import OutputFormat
|
|
38
38
|
from annofabcli.common.facade import (
|
|
39
39
|
AnnofabApiFacade,
|
|
40
40
|
TaskQuery,
|
|
@@ -504,7 +504,7 @@ class ListAnnotationDurationMain:
|
|
|
504
504
|
self,
|
|
505
505
|
annotation_path: Path,
|
|
506
506
|
output_file: Path,
|
|
507
|
-
arg_format:
|
|
507
|
+
arg_format: OutputFormat,
|
|
508
508
|
*,
|
|
509
509
|
project_id: str | None = None,
|
|
510
510
|
input_data_json_path: Path | None = None,
|
|
@@ -527,12 +527,12 @@ class ListAnnotationDurationMain:
|
|
|
527
527
|
|
|
528
528
|
logger.info(f"{len(annotation_duration_list)} 件のタスクに含まれる区間アノテーションの長さ情報を出力します。")
|
|
529
529
|
|
|
530
|
-
if arg_format ==
|
|
530
|
+
if arg_format == OutputFormat.CSV:
|
|
531
531
|
assert csv_type is not None
|
|
532
532
|
self.print_annotation_duration_csv(annotation_duration_list, output_file=output_file, csv_type=csv_type, annotation_specs=annotation_specs)
|
|
533
533
|
|
|
534
|
-
elif arg_format in [
|
|
535
|
-
json_is_pretty = arg_format ==
|
|
534
|
+
elif arg_format in [OutputFormat.PRETTY_JSON, OutputFormat.JSON]:
|
|
535
|
+
json_is_pretty = arg_format == OutputFormat.PRETTY_JSON
|
|
536
536
|
|
|
537
537
|
print_json(
|
|
538
538
|
[e.to_dict(encode_json=True) for e in annotation_duration_list],
|
|
@@ -578,7 +578,7 @@ class ListAnnotationDuration(CommandLine):
|
|
|
578
578
|
|
|
579
579
|
csv_type = CsvType(args.type)
|
|
580
580
|
output_file: Path = args.output
|
|
581
|
-
arg_format =
|
|
581
|
+
arg_format = OutputFormat(args.format)
|
|
582
582
|
main_obj = ListAnnotationDurationMain(self.service)
|
|
583
583
|
|
|
584
584
|
downloading_obj = DownloadingFile(self.service)
|
|
@@ -660,8 +660,8 @@ def parse_args(parser: argparse.ArgumentParser) -> None:
|
|
|
660
660
|
)
|
|
661
661
|
|
|
662
662
|
argument_parser.add_format(
|
|
663
|
-
choices=[
|
|
664
|
-
default=
|
|
663
|
+
choices=[OutputFormat.CSV, OutputFormat.JSON, OutputFormat.PRETTY_JSON],
|
|
664
|
+
default=OutputFormat.CSV,
|
|
665
665
|
)
|
|
666
666
|
|
|
667
667
|
argument_parser.add_output()
|
|
@@ -20,7 +20,7 @@ from annofabcli.common.cli import (
|
|
|
20
20
|
build_annofabapi_resource_and_login,
|
|
21
21
|
)
|
|
22
22
|
from annofabcli.common.download import DownloadingFile
|
|
23
|
-
from annofabcli.common.enums import
|
|
23
|
+
from annofabcli.common.enums import OutputFormat
|
|
24
24
|
from annofabcli.common.facade import AnnofabApiFacade
|
|
25
25
|
from annofabcli.common.utils import print_according_to_format, print_csv
|
|
26
26
|
|
|
@@ -81,7 +81,7 @@ class ListVideoDuration(CommandLine):
|
|
|
81
81
|
self,
|
|
82
82
|
task_json: Path,
|
|
83
83
|
input_data_json: Path,
|
|
84
|
-
output_format:
|
|
84
|
+
output_format: OutputFormat,
|
|
85
85
|
output_file: Path | None,
|
|
86
86
|
) -> None:
|
|
87
87
|
with task_json.open(encoding="utf-8") as f:
|
|
@@ -91,7 +91,7 @@ class ListVideoDuration(CommandLine):
|
|
|
91
91
|
|
|
92
92
|
video_duration_list = get_video_duration_list(task_list=task_list, input_data_list=input_data_list)
|
|
93
93
|
logger.info(f"{len(video_duration_list)} 件のタスクの動画長さを出力します。")
|
|
94
|
-
if output_format ==
|
|
94
|
+
if output_format == OutputFormat.CSV:
|
|
95
95
|
columns = [
|
|
96
96
|
"project_id",
|
|
97
97
|
"task_id",
|
|
@@ -125,7 +125,7 @@ class ListVideoDuration(CommandLine):
|
|
|
125
125
|
)
|
|
126
126
|
sys.exit(COMMAND_LINE_ERROR_STATUS_CODE)
|
|
127
127
|
|
|
128
|
-
func = partial(self.list_video_duration, output_file=args.output, output_format=
|
|
128
|
+
func = partial(self.list_video_duration, output_file=args.output, output_format=OutputFormat(args.format))
|
|
129
129
|
|
|
130
130
|
def wrapper_func(temp_dir: Path) -> None:
|
|
131
131
|
downloading_obj = DownloadingFile(self.service)
|
|
@@ -190,8 +190,8 @@ def parse_args(parser: argparse.ArgumentParser) -> None:
|
|
|
190
190
|
)
|
|
191
191
|
|
|
192
192
|
argument_parser.add_format(
|
|
193
|
-
choices=[
|
|
194
|
-
default=
|
|
193
|
+
choices=[OutputFormat.CSV, OutputFormat.JSON, OutputFormat.PRETTY_JSON],
|
|
194
|
+
default=OutputFormat.CSV,
|
|
195
195
|
)
|
|
196
196
|
|
|
197
197
|
argument_parser.add_output()
|
|
@@ -19,7 +19,7 @@ from annofabcli.common.cli import (
|
|
|
19
19
|
)
|
|
20
20
|
from annofabcli.common.dataclasses import WaitOptions
|
|
21
21
|
from annofabcli.common.download import DownloadingFile
|
|
22
|
-
from annofabcli.common.enums import
|
|
22
|
+
from annofabcli.common.enums import OutputFormat
|
|
23
23
|
from annofabcli.common.facade import AnnofabApiFacade
|
|
24
24
|
from annofabcli.statistics.summarize_task_count import get_step_for_current_phase
|
|
25
25
|
|
|
@@ -144,7 +144,7 @@ class SummarizeTaskCountByTaskId(CommandLine):
|
|
|
144
144
|
columns = ["task_id_group"] + [status.value for status in TaskStatusForSummary] + ["sum"]
|
|
145
145
|
annofabcli.common.utils.print_according_to_format(
|
|
146
146
|
df[columns],
|
|
147
|
-
format=
|
|
147
|
+
format=OutputFormat.CSV,
|
|
148
148
|
output=self.output,
|
|
149
149
|
)
|
|
150
150
|
|
|
@@ -16,7 +16,7 @@ from annofabcli.common.cli import (
|
|
|
16
16
|
)
|
|
17
17
|
from annofabcli.common.dataclasses import WaitOptions
|
|
18
18
|
from annofabcli.common.download import DownloadingFile
|
|
19
|
-
from annofabcli.common.enums import
|
|
19
|
+
from annofabcli.common.enums import OutputFormat
|
|
20
20
|
from annofabcli.common.facade import AnnofabApiFacade
|
|
21
21
|
|
|
22
22
|
logger = logging.getLogger(__name__)
|
|
@@ -112,7 +112,7 @@ class SummarizeTaskCountByUser(CommandLine):
|
|
|
112
112
|
target_df = df[columns].sort_values("user_id")
|
|
113
113
|
annofabcli.common.utils.print_according_to_format(
|
|
114
114
|
target_df,
|
|
115
|
-
format=
|
|
115
|
+
format=OutputFormat.CSV,
|
|
116
116
|
output=self.output,
|
|
117
117
|
)
|
|
118
118
|
|
|
@@ -136,7 +136,8 @@ class ProjectWorktimePerMonth:
|
|
|
136
136
|
series = df.groupby(pandas.Grouper(key="dt_date", freq=get_frequency_of_monthend())).sum(numeric_only=True)[worktime_column.value]
|
|
137
137
|
# indexを"2022-04"という形式にする
|
|
138
138
|
new_index = [str(dt)[0:7] for dt in series.index]
|
|
139
|
-
|
|
139
|
+
# pandas 3.0対応: .valuesではなく.to_numpy()を使用
|
|
140
|
+
result = pandas.Series(series.to_numpy(), index=new_index)
|
|
140
141
|
result["dirname"] = project_dir.project_dir.name
|
|
141
142
|
result["project_title"] = project_dir.get_project_title()
|
|
142
143
|
return result
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
import datetime
|
|
3
4
|
import logging
|
|
4
5
|
from pathlib import Path
|
|
5
6
|
from typing import Any
|
|
@@ -9,7 +10,6 @@ import bokeh
|
|
|
9
10
|
import bokeh.layouts
|
|
10
11
|
import numpy
|
|
11
12
|
import pandas
|
|
12
|
-
import pytz
|
|
13
13
|
from bokeh.plotting import figure
|
|
14
14
|
|
|
15
15
|
from annofabcli.common.bokeh import convert_1d_figure_list_to_2d, create_pretext_from_metadata
|
|
@@ -426,10 +426,11 @@ class Task:
|
|
|
426
426
|
# タイムゾーンを指定している理由::
|
|
427
427
|
# すべてがNaNのseriesをdatetimeに変換すると、型にタイムゾーンが指定されない。
|
|
428
428
|
# その状態で加算すると、`TypeError: DatetimeArray subtraction must have the same timezones or no timezones`というエラーが発生するため
|
|
429
|
+
# pandas 3.0対応: pytz.FixedOffsetの代わりにdatetime.timezoneを使用
|
|
429
430
|
if not isinstance(dt1.dtype, pandas.DatetimeTZDtype):
|
|
430
|
-
dt1 = dt1.dt.tz_localize(
|
|
431
|
+
dt1 = dt1.dt.tz_localize(datetime.timezone(datetime.timedelta(hours=9)))
|
|
431
432
|
if not isinstance(dt2.dtype, pandas.DatetimeTZDtype):
|
|
432
|
-
dt2 = dt2.dt.tz_localize(
|
|
433
|
+
dt2 = dt2.dt.tz_localize(datetime.timezone(datetime.timedelta(hours=9)))
|
|
433
434
|
|
|
434
435
|
return (dt1 - dt2).dt.total_seconds() / 3600 / 24
|
|
435
436
|
|
|
@@ -532,9 +533,27 @@ class Task:
|
|
|
532
533
|
if not self._validate_df_for_output(output_file):
|
|
533
534
|
return
|
|
534
535
|
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
536
|
+
# metadata列が存在する場合は展開する
|
|
537
|
+
if "metadata" in self.df.columns:
|
|
538
|
+
# metadata列のみをjson_normalizeで展開
|
|
539
|
+
df_metadata = pandas.json_normalize(self.df["metadata"].tolist())
|
|
540
|
+
# 列名にmetadata.プレフィックスを追加
|
|
541
|
+
df_metadata.columns = [f"metadata.{col}" for col in df_metadata.columns]
|
|
542
|
+
# 元のDataFrameからmetadata列を削除
|
|
543
|
+
df_without_metadata = self.df.drop(columns=["metadata"])
|
|
544
|
+
# 展開したmetadata列を結合
|
|
545
|
+
df_normalized = pandas.concat([df_without_metadata.reset_index(drop=True), df_metadata.reset_index(drop=True)], axis=1)
|
|
546
|
+
else:
|
|
547
|
+
df_normalized = self.df
|
|
548
|
+
|
|
549
|
+
# metadata.*列を検出
|
|
550
|
+
metadata_columns = sorted([col for col in df_normalized.columns if col.startswith("metadata.")])
|
|
551
|
+
|
|
552
|
+
# 出力対象の列を定義
|
|
553
|
+
existing_optional_columns = [col for col in self.optional_columns if col in set(df_normalized.columns)]
|
|
554
|
+
columns = self.required_columns + existing_optional_columns + metadata_columns
|
|
555
|
+
|
|
556
|
+
print_csv(df_normalized[columns], str(output_file))
|
|
538
557
|
|
|
539
558
|
def mask_user_info(
|
|
540
559
|
self,
|
|
@@ -15,7 +15,7 @@ from annofabapi.models import SupplementaryData
|
|
|
15
15
|
import annofabcli.common.cli
|
|
16
16
|
from annofabcli.common.cli import PARALLELISM_CHOICES, ArgumentParser, CommandLine, build_annofabapi_resource_and_login
|
|
17
17
|
from annofabcli.common.download import DownloadingFile
|
|
18
|
-
from annofabcli.common.enums import
|
|
18
|
+
from annofabcli.common.enums import OutputFormat
|
|
19
19
|
from annofabcli.common.facade import AnnofabApiFacade
|
|
20
20
|
|
|
21
21
|
logger = logging.getLogger(__name__)
|
|
@@ -155,7 +155,7 @@ def parse_args(parser: argparse.ArgumentParser) -> None:
|
|
|
155
155
|
),
|
|
156
156
|
)
|
|
157
157
|
|
|
158
|
-
argument_parser.add_format(choices=[
|
|
158
|
+
argument_parser.add_format(choices=[OutputFormat.CSV, OutputFormat.JSON, OutputFormat.PRETTY_JSON], default=OutputFormat.CSV)
|
|
159
159
|
argument_parser.add_output()
|
|
160
160
|
|
|
161
161
|
parser.add_argument(
|
|
@@ -6,17 +6,15 @@ from pathlib import Path
|
|
|
6
6
|
from typing import Any
|
|
7
7
|
|
|
8
8
|
import annofabapi
|
|
9
|
-
import pandas
|
|
10
9
|
from annofabapi.dataclass.task import Task
|
|
11
10
|
|
|
12
11
|
import annofabcli.common.cli
|
|
13
12
|
from annofabcli.common.cli import ArgumentParser, CommandLine, build_annofabapi_resource_and_login
|
|
14
13
|
from annofabcli.common.download import DownloadingFile
|
|
15
|
-
from annofabcli.common.enums import
|
|
14
|
+
from annofabcli.common.enums import OutputFormat
|
|
16
15
|
from annofabcli.common.facade import AnnofabApiFacade, TaskQuery, match_task_with_query
|
|
17
|
-
from annofabcli.common.utils import get_columns_with_priority
|
|
18
16
|
from annofabcli.common.visualize import AddProps
|
|
19
|
-
from annofabcli.task.list_tasks import
|
|
17
|
+
from annofabcli.task.list_tasks import print_task_list
|
|
20
18
|
|
|
21
19
|
logger = logging.getLogger(__name__)
|
|
22
20
|
|
|
@@ -44,9 +42,10 @@ class ListTasksWithJsonMain:
|
|
|
44
42
|
self,
|
|
45
43
|
project_id: str,
|
|
46
44
|
task_json: Path | None,
|
|
45
|
+
*,
|
|
47
46
|
task_id_list: list[str] | None = None,
|
|
48
47
|
task_query: TaskQuery | None = None,
|
|
49
|
-
is_latest: bool = False,
|
|
48
|
+
is_latest: bool = False,
|
|
50
49
|
temp_dir: Path | None = None,
|
|
51
50
|
) -> list[dict[str, Any]]:
|
|
52
51
|
if task_json is None:
|
|
@@ -108,17 +107,8 @@ class ListTasksWithJson(CommandLine):
|
|
|
108
107
|
temp_dir=temp_dir,
|
|
109
108
|
)
|
|
110
109
|
|
|
111
|
-
logger.
|
|
112
|
-
|
|
113
|
-
if len(task_list) > 0:
|
|
114
|
-
if self.str_format == FormatArgument.CSV.value:
|
|
115
|
-
df = pandas.DataFrame(task_list)
|
|
116
|
-
columns = get_columns_with_priority(df, prior_columns=ListTasks.PRIOR_COLUMNS)
|
|
117
|
-
self.print_csv(df[columns])
|
|
118
|
-
else:
|
|
119
|
-
self.print_according_to_format(task_list)
|
|
120
|
-
else:
|
|
121
|
-
logger.info("タスク一覧の件数が0件のため、出力しません。")
|
|
110
|
+
logger.info(f"{len(task_list)}件のタスク情報を出力します。")
|
|
111
|
+
print_task_list(task_list, OutputFormat(args.format), args.output)
|
|
122
112
|
|
|
123
113
|
|
|
124
114
|
def main(args: argparse.Namespace) -> None:
|
|
@@ -155,8 +145,8 @@ def parse_args(parser: argparse.ArgumentParser) -> None:
|
|
|
155
145
|
)
|
|
156
146
|
|
|
157
147
|
argument_parser.add_format(
|
|
158
|
-
choices=[
|
|
159
|
-
default=
|
|
148
|
+
choices=[OutputFormat.CSV, OutputFormat.JSON, OutputFormat.PRETTY_JSON, OutputFormat.TASK_ID_LIST],
|
|
149
|
+
default=OutputFormat.CSV,
|
|
160
150
|
)
|
|
161
151
|
argument_parser.add_output()
|
|
162
152
|
|