ehovel2023 commited on
Commit
4d7de12
1 Parent(s): fb0d8d8
Files changed (2) hide show
  1. case.py +158 -0
  2. k.yaml +70 -0
case.py ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from uuid import uuid1
2
+
3
+ import pytest
4
+
5
+ from aidisdk import AIDIClient
6
+ from aidisdk.algo_house.algorithm_module import AlgoConfig, AlgoFieldEnum
7
+ from aidisdk.compute.job_abstract import (
8
+ JobType,
9
+ RunningResourceConfig,
10
+ StartUpConfig,
11
+ )
12
+ from aidisdk.compute.package_abstract import (
13
+ CodePackageConfig,
14
+ LocalPackageItem,
15
+ )
16
+ from aidisdk.model import ModelFramework
17
+
18
+
19
+ @pytest.mark.skip("unused")
20
+ def test_create_algo_for_eval_detection3d(unittest_client):
21
+ client: AIDIClient = unittest_client
22
+ # create a algorithm with a raw config file
23
+
24
+ algorithm = client.algo_house.create(
25
+ algo_name="eval_for_detection3d_" + str(uuid1()).replace("-", "_"),
26
+ field=AlgoFieldEnum.AUTO,
27
+ scene="高速",
28
+ module="感知",
29
+ task_types=["2D检测"],
30
+ framework=ModelFramework.pytorch,
31
+ startup="cd ${WORKING_PATH} && python3 local_example.py ", # noqa
32
+ code_package="test/test_data/eval_experiment",
33
+ docker_image="docker.hobot.cc/auto/eval-traincli:v1.0.36test",
34
+ desc="算法仓库发起评测使用,请勿删除.",
35
+ tags=["test", "unittest"],
36
+ config_files=[
37
+ AlgoConfig(
38
+ name="eval_setting",
39
+ local_path="test/test_data/"
40
+ + "eval_experiment/setting_example.yaml",
41
+ ),
42
+ ],
43
+ )
44
+ client.algo_house.__delete__(algorithm.algo_id)
45
+
46
+
47
+ @pytest.mark.skip("unused")
48
+ def test_update_algo(unittest_client):
49
+ client: AIDIClient = unittest_client
50
+ algo_name = "eval_for_Semantic_Segmentation"
51
+ algorithm = client.algo_house.update(
52
+ algo_name=algo_name,
53
+ field=AlgoFieldEnum.AUTO,
54
+ scene="高速",
55
+ module="感知",
56
+ task_types=["2D检测"],
57
+ framework=ModelFramework.pytorch,
58
+ startup="python3 local_example.py --task_type ${TASK_TYPE} "
59
+ + "--endpoint"
60
+ + " 'http://aidi-test.hobot.cc' "
61
+ + "--group_name ${GROUP_NAME} "
62
+ + "--experiment_name ${EXPERIMENT_NAME} --run_name '${RUN_NAME}' "
63
+ + "--gt_dataset_id "
64
+ + "'${GT_DATASET_ID}' "
65
+ + "--images_dataset_id " # detection 3d & 分割
66
+ + "'${IMAGES_DATASET_ID}' "
67
+ + "--prediction_name '${PREDICTION_NAME}' "
68
+ + "--predictions_dataset_id '${PREDICTIONS_DATASET_ID}' " # 分割
69
+ + "--labels_dataset_id '${LABELS_DATASET_ID}' " # 分割
70
+ + "--setting_file_name ${EVAL_SETTING}",
71
+
72
+
73
+ code_package="test/test_data/eval_experiment",
74
+ docker_image="docker.hobot.cc/auto/eval-traincli:v1.0.36test",
75
+ desc="算法仓库发起评测使用,请勿删除.",
76
+ tags=["test", "unittest"],
77
+ config_files=[
78
+ AlgoConfig(
79
+ name="eval_setting",
80
+ local_path="test/test_data/eval_experiment/wk_setting.yaml", # 分割
81
+ # local_path="test/test_data/eval_experiment/setting_example.yaml",
82
+ placeholder="${EVAL_SETTING}",
83
+ ),
84
+ ],
85
+ )
86
+ print(algorithm)
87
+
88
+
89
+ # @pytest.mark.skip("unused")
90
+ def test_create_eval_task_env_test(unittest_client):
91
+ client: AIDIClient = unittest_client
92
+ # algo_name = "eval_for_detection3d"
93
+ algo_name = "eval_for_Semantic_Segmentation"
94
+ algo = client.algo_house.get(
95
+ algo_name=algo_name, download_config=True, download_package=True
96
+ )
97
+ # experiment group name + experiment name + prediction in experiment
98
+ # 参数会替换cmd命令中的占位符,默认cmd_args_dict的key大写为占位符,如 task_type -> ${TASK_TYPE}
99
+ cmd_args_dict = {
100
+ "task_type": "Semantic_Segmentation",
101
+ "predictions_dataset_id": "dataset://25616",
102
+ "labels_dataset_id": "dataset://25615",
103
+
104
+ # "gt_dataset": "dataset://25575",
105
+ "gt_dataset": "",
106
+ "images_dataset_id": "dataset://25613",
107
+ "group_name": "train-withBN",
108
+ "experiment_name": "wjx_test_095",
109
+ "run_name": "test_run_name_wjx_003",
110
+ # "prediction_name": "wjx_test_023/prediction.json",
111
+ "prediction_name": "",
112
+ }
113
+
114
+ config_files = [
115
+ AlgoConfig(
116
+ name="eval_setting",
117
+ local_path="test/test_data/eval_experiment/wk_setting.yaml", # 分割
118
+ # local_path="test/test_data/eval_experiment/setting_example.yaml",
119
+ placeholder="${EVAL_SETTING}",
120
+ ),
121
+ ]
122
+
123
+ algo.update_config(config_files)
124
+ algo.update_cmd(cmd_args_dict)
125
+
126
+ # TODO gen job obj
127
+ # job = algo.gen_job()
128
+ cpu_count = 6
129
+ cpu_mem_ratio = 6
130
+ queue = "svc-aip-cpu"
131
+ project = "PD20210425"
132
+ job = client.single_job.create(
133
+ job_name="eval_from_algo_%s_%s"
134
+ % (algo.name, str(uuid1()).replace("-", "_")),
135
+ job_type=JobType.APP_EVAL,
136
+ ipd_number=project,
137
+ queue_name=queue,
138
+ running_resource=RunningResourceConfig(
139
+ docker_image=algo.docker_image,
140
+ instance=1,
141
+ cpu=cpu_count,
142
+ gpu=0,
143
+ cpu_mem_ratio=cpu_mem_ratio,
144
+ ),
145
+ mount=[],
146
+ startup=StartUpConfig(
147
+ command=algo.startup_command, # noqa
148
+ ),
149
+ code_package=CodePackageConfig(
150
+ raw_package=LocalPackageItem(
151
+ lpath=algo.package_path,
152
+ encrypt_passwd="12345",
153
+ follow_softlink=True,
154
+ ).set_as_startup_dir(),
155
+ ),
156
+ # subscribers=["dan.song", "shulan.shen"],
157
+ )
158
+ print(job)
k.yaml ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class:
2
+ - color: [128,64,128]
3
+ ignore: false
4
+ label: 0
5
+ name: road
6
+ - color: [70,70,70]
7
+ ignore: false
8
+ label: 1
9
+ name: background
10
+ - color: [153,153,190]
11
+ ignore: false
12
+ label: 2
13
+ name: fence
14
+ - color: [153,153,153]
15
+ ignore: false
16
+ label: 3
17
+ name: pole
18
+ - color: [30,170,250]
19
+ ignore: false
20
+ label: 4
21
+ name: traffic
22
+ - color: [60,20,220]
23
+ ignore: false
24
+ label: 5
25
+ name: person
26
+ - color: [142,0,0]
27
+ ignore: false
28
+ label: 6
29
+ name: vehicle
30
+ - color: [70,0,0]
31
+ ignore: false
32
+ label: 7
33
+ name: two-wheel
34
+ - color: [200,200,200]
35
+ ignore: false
36
+ label: 8
37
+ name: lane_marking
38
+ - color: [0,192,64]
39
+ ignore: false
40
+ label: 9
41
+ name: crosswalk
42
+ - color: [192,0,128]
43
+ ignore: false
44
+ label: 10
45
+ name: traffic_arrow
46
+ - color: [128,200,200]
47
+ ignore: false
48
+ label: 11
49
+ name: sign_line
50
+ - color: [192,192,0]
51
+ ignore: false
52
+ label: 12
53
+ name: guide_line
54
+ - color: [64,64,0]
55
+ ignore: false
56
+ label: 13
57
+ name: cone
58
+ - color: [0,0,255]
59
+ ignore: false
60
+ label: 14
61
+ name: stop_line
62
+ - color: [0,220,220]
63
+ ignore: false
64
+ label: 15
65
+ name: speed_bump
66
+
67
+ freespace:
68
+ - freespace_id: [0,8,9,10,11,12,14,15]
69
+ margin: [5,10]
70
+ thredshold: [0.5,0.7]