Skip to content

Commit

Permalink
statistics visualize : --custom_production_volumeに関する説明を追加 (#1295)
Browse files Browse the repository at this point in the history
* ドキュメントの生成

* `summarize_whole_performance_csv`の修正

* 生産量を追加

* format

* format

* format

* QualityIndicatorの修正

* format
  • Loading branch information
yuji38kwmt authored Nov 8, 2024
1 parent 4bcfc94 commit aa545e0
Show file tree
Hide file tree
Showing 9 changed files with 251 additions and 66 deletions.
6 changes: 5 additions & 1 deletion annofabcli/stat_visualization/mask_visualization_dir.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import argparse
import json
import logging
from dataclasses import dataclass
from pathlib import Path
Expand Down Expand Up @@ -266,11 +267,14 @@ def parse_args(parser: argparse.ArgumentParser) -> None:
action="store_true",
help="必要最小限のファイルを出力します。",
)
custom_production_volume_sample = {
"column_list": [{"value": "video_duration_minute", "name": "動画長さ"}],
}

parser.add_argument(
"--custom_production_volume",
type=str,
help=("プロジェクト独自の生産量の指標をJSON形式で指定します。"),
help=("プロジェクト独自の生産量をJSON形式で指定します。" f"(例) ``{json.dumps(custom_production_volume_sample, ensure_ascii=False)}`` \n"),
)

parser.add_argument("-o", "--output_dir", type=Path, required=True, help="出力先ディレクトリ。")
Expand Down
7 changes: 6 additions & 1 deletion annofabcli/stat_visualization/merge_visualization_dir.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import argparse
import json
import logging
import sys
from pathlib import Path
Expand Down Expand Up @@ -288,10 +289,14 @@ def parse_args(parser: argparse.ArgumentParser) -> None:
help="必要最小限のファイルを出力します。",
)

custom_production_volume_sample = {
"column_list": [{"value": "video_duration_minute", "name": "動画長さ"}],
}

parser.add_argument(
"--custom_production_volume",
type=str,
help=("プロジェクト独自の生産量の指標をJSON形式で指定します。"),
help=("プロジェクト独自の生産量をJSON形式で指定します。" f"(例) ``{json.dumps(custom_production_volume_sample, ensure_ascii=False)}`` \n"),
)

parser.set_defaults(subcommand_func=main)
Expand Down
36 changes: 35 additions & 1 deletion annofabcli/stat_visualization/summarize_whole_performance_csv.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,42 @@
from __future__ import annotations

import argparse
import json
import logging
from pathlib import Path
from typing import Optional

import annofabcli
from annofabcli.common.cli import (
get_json_from_args,
)
from annofabcli.statistics.visualization.dataframe.project_performance import ProjectPerformance
from annofabcli.statistics.visualization.model import ProductionVolumeColumn
from annofabcli.statistics.visualization.project_dir import ProjectDir

logger = logging.getLogger(__name__)


def create_custom_production_volume_list(cli_value: str) -> list[ProductionVolumeColumn]:
"""
コマンドラインから渡された文字列を元に、独自の生産量を表す列情報を生成します。
"""
dict_data = get_json_from_args(cli_value)

column_list = dict_data["column_list"]
custom_production_volume_list = [ProductionVolumeColumn(column["value"], column["name"]) for column in column_list]

return custom_production_volume_list


def main(args: argparse.Namespace) -> None:
root_dir: Path = args.dir
project_dir_list = [ProjectDir(elm) for elm in root_dir.iterdir() if elm.is_dir()]

project_performance = ProjectPerformance.from_project_dirs(project_dir_list)
custom_production_volume_list = (
create_custom_production_volume_list(args.custom_production_volume) if args.custom_production_volume is not None else None
)
project_performance = ProjectPerformance.from_project_dirs(project_dir_list, custom_production_volume_list=custom_production_volume_list)
project_performance.to_csv(args.output)


Expand All @@ -28,6 +50,18 @@ def parse_args(parser: argparse.ArgumentParser) -> None:

parser.add_argument("-o", "--output", type=Path, required=True, help="出力先のファイルパスを指定します。")

custom_production_volume_sample = {
"column_list": [{"value": "video_duration_minute", "name": "動画長さ"}],
}

parser.add_argument(
"--custom_production_volume",
type=str,
help=("プロジェクト独自の生産量をJSON形式で指定します。" f"(例) ``{json.dumps(custom_production_volume_sample, ensure_ascii=False)}`` \n"),
)

parser.set_defaults(subcommand_func=main)

parser.set_defaults(subcommand_func=main)


Expand Down
7 changes: 6 additions & 1 deletion annofabcli/stat_visualization/write_graph.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import argparse
import json
import logging
from pathlib import Path
from typing import List, Optional
Expand Down Expand Up @@ -163,10 +164,14 @@ def parse_args(parser: argparse.ArgumentParser) -> None:
help="必要最小限のファイルを出力します。",
)

custom_production_volume_sample = {
"column_list": [{"value": "video_duration_minute", "name": "動画長さ"}],
}

parser.add_argument(
"--custom_production_volume",
type=str,
help=("プロジェクト独自の生産量の指標をJSON形式で指定します。"),
help=("プロジェクト独自の生産量をJSON形式で指定します。" f"(例) ``{json.dumps(custom_production_volume_sample, ensure_ascii=False)}`` \n"),
)

parser.add_argument("-o", "--output_dir", type=Path, required=True, help="出力先ディレクトリ。配下にプロジェクトディレクトリが生成されます。")
Expand Down
Loading

0 comments on commit aa545e0

Please sign in to comment.