Skip to content

Commit 4005b55

Browse files
author
Sunil Thaha
authored
Merge pull request #326 from sunya-ch/entrypoint-patch
make filter pod by benchmark optional
2 parents d55c2d3 + aad89b0 commit 4005b55

File tree

2 files changed

+33
-20
lines changed

2 files changed

+33
-20
lines changed

cmd/cmd_util.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ def get_validate_df(data_path, benchmark_filename, query_response):
103103
container_queries = [query for query in query_results.keys() if "container" in query]
104104
print("Container Queries: ", container_queries)
105105
status_data = load_json(data_path, benchmark_filename)
106-
if status_data is None or status_data.get("status", None) == None:
106+
filter_by_benchmark = False
107+
if status_data is None or "status" not in status_data:
107108
# select all with keyword
108109
for query in container_queries:
109110
df = query_results[query]
@@ -120,7 +121,11 @@ def get_validate_df(data_path, benchmark_filename, query_response):
120121
continue
121122
filtered_df = df.copy()
122123
if "pod_name" in df.columns:
123-
filtered_df = filtered_df[filtered_df["pod_name"].str.contains(benchmark_filename)]
124+
# check if we can use inputted benchmark to filtered stressing pods
125+
podname_filtered = filtered_df[filtered_df["pod_name"].str.contains(benchmark_filename)]
126+
if len(podname_filtered) > 0:
127+
filter_by_benchmark = True
128+
filtered_df = podname_filtered
124129
# set validate item
125130
item = dict()
126131
item["pod"] = benchmark_filename
@@ -131,6 +136,7 @@ def get_validate_df(data_path, benchmark_filename, query_response):
131136
item["total"] = filtered_df[query].max()
132137
items += [item]
133138
else:
139+
filtered_by_benchmark = True
134140
cpe_results = status_data["status"]["results"]
135141
for result in cpe_results:
136142
scenarioID = result["scenarioID"]
@@ -217,6 +223,11 @@ def get_validate_df(data_path, benchmark_filename, query_response):
217223
item["total"] = df[query].max()
218224
items += [item]
219225
validate_df = pd.DataFrame(items)
226+
227+
if filter_by_benchmark:
228+
print("===========================================\n Use benchmark name to filter pod results: \n\n", benchmark_filename)
229+
else:
230+
print("============================================\n Present results from all pods: \n\n")
220231
if not validate_df.empty:
221232
print(validate_df.groupby(["scenarioID", "query"]).sum()[["count", ">0"]])
222233
else:

model_training/cmd_instruction.md

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
# Manual Metric Collection and Training with Entrypoint
22

33
## 1. Collect metrics
4-
Without benchmark/pipeline automation, kepler metrics can be collected by `query` function by either one of the following options.
5-
### 1.1. by defining start time and end time
4+
Without benchmark/pipeline automation, kepler metrics can be collected by `query` function by setting `BENCHMARK`, `PROM_URL`, `COLLECT_ID` and either one of the following time options.
5+
6+
> It is recommend to set BENCHMARK name as a part of the pod name such as `stressng` to filter the validated results. BENCHMARK name will be also used by the TrainerIsolator to filter the target pods. If the BENCHMARK cannot be used to filter the target pods, the validated results will show result from all pods.
67
78
```bash
8-
# value setting
99
BENCHMARK= # name of the benchmark (will generate [BENCHMARK].json to save start and end time for reference)
1010
PROM_URL= # e.g., http://localhost:9090
11+
COLLECT_ID= # any unique id e.g., machine name
12+
```
13+
14+
### 1.1. by defining start time and end time
15+
16+
```bash
17+
# time value setting
1118
START_TIME= # format date +%Y-%m-%dT%H:%M:%SZ
1219
END_TIME= # format date +%Y-%m-%dT%H:%M:%SZ
13-
COLLECT_ID= # any unique id e.g., machine name
1420

1521
# query execution
1622
DATAPATH=/path/to/workspace python cmd/main.py query --benchmark $BENCHMARK --server $PROM_URL --output kepler_query --start-time $START_TIME --end-time $END_TIME --id $COLLECT_ID
@@ -19,11 +25,8 @@ DATAPATH=/path/to/workspace python cmd/main.py query --benchmark $BENCHMARK --se
1925
### 1.2. by defining last interval from the execution time
2026

2127
```bash
22-
# value setting
23-
BENCHMARK= # name of the benchmark (will generate [BENCHMARK].json to save start and end time for reference)
24-
PROM_URL= # e.g., http://localhost:9090
28+
# time value setting
2529
INTERVAL= # in second
26-
COLLECT_ID= # any unique id e.g., machine name
2730

2831
# query execution
2932
DATAPATH=/path/to/workspace python cmd/main.py query --benchmark $BENCHMARK --server $PROM_URL --output kepler_query --interval $INTERVAL --id $COLLECT_ID
@@ -47,31 +50,30 @@ DATAPATH=/path/to/workspace MODEL_PATH=/path/to/workspace python cmd/main.py tra
4750
```
4851

4952
## 3. Export models
50-
Export function is to archive the model that has an error less than threshold from the trained pipeline and make a report in the format that is ready to push to kepler-model-db.
51-
52-
### 3.1. exporting the trained pipeline with BENCHMARK
53-
54-
The benchmark file is created by CPE operator or by step 1.1. or 1.2..
53+
Export function is to archive the model that has an error less than threshold from the trained pipeline and make a report in the format that is ready to push to kepler-model-db. To use export function, need to set `EXPORTER_PATH` and `PUBLISHER`, and collect date option.
5554

5655
```bash
57-
# value setting
5856
EXPORT_PATH= # /path/to/kepler-model-db/models
5957
PUBLISHER= # github account of publisher
58+
```
6059

60+
### 3.1. extracting collect date from benchmark file
61+
62+
The benchmark file is created by CPE operator or by query function from step 1.
63+
64+
```bash
6165
# export execution
6266
# require BENCHMARK from collect step
6367
# require PIPELINE_NAME from train step
6468
DATAPATH=/path/to/workspace MODEL_PATH=/path/to/workspace python cmd/main.py export --benchmark $BENCHMARK --pipeline-name $PIPELINE_NAME -o $EXPORT_PATH --publisher $PUBLISHER --zip=true
6569
```
6670

67-
### 3.2. exporting the trained models without BENCHMARK
71+
### 3.2. manually set collect-date
6872

6973
If the data is collected by tekton, there is no benchmark file created. Need to manually set `--collect-date` instead of `--benchmark` parameter.
7074

7175
```bash
72-
# value setting
73-
EXPORT_PATH= # /path/to/kepler-model-db/models
74-
PUBLISHER= # github account of publisher
76+
# collect date value setting
7577
COLLECT_DATE= # collect date
7678

7779
# export execution

0 commit comments

Comments
 (0)