Skip to content
This repository was archived by the owner on Oct 20, 2025. It is now read-only.

Commit e01015f

Browse files
authored
Merge pull request #80 from zqzten/algo
Algo: Make tsf model train script more general
2 parents 10f40f6 + ee1954c commit e01015f

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

  • algorithm/kapacity/timeseries/forecasting

algorithm/kapacity/timeseries/forecasting/train.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,22 +85,22 @@ def fetch_train_data(args, config):
8585

8686

8787
def fetch_history_metrics(args, target):
88-
df = pd.DataFrame(columns=['timestamp', 'value', 'workload', 'metric'])
88+
workload_namespace = target['workloadNamespace']
89+
workload_name = target['workloadRef']['name']
90+
workload_identifier = '%s/%s' % (workload_namespace, workload_name)
8991
start, end = query.compute_history_range(target['historyLength'])
9092

93+
df = pd.DataFrame(columns=['timestamp', 'value', 'workload', 'metric'])
9194
for i in range(len(target['metrics'])):
9295
metric = target['metrics'][i]
93-
if metric['type'] != 'Object' and metric['type'] != 'External':
94-
raise RuntimeError('UnsupportedMetricType')
95-
workload_namespace = target['workloadNamespace']
96-
workload_name = target['workloadName']
97-
df_metric = query.fetch_metrics(addr=args.metrics_server_addr,
98-
namespace=workload_namespace,
99-
metric=metric,
100-
start=start,
101-
end=end)
96+
df_metric = query.fetch_metrics(args.metrics_server_addr,
97+
workload_namespace,
98+
metric,
99+
target['workloadRef'],
100+
start,
101+
end)
102102
df_metric['metric'] = metric['name']
103-
df_metric['workload'] = '%s/%s' % (workload_namespace, workload_name)
103+
df_metric['workload'] = workload_identifier
104104
df = pd.concat([df, df_metric])
105105
return df
106106

0 commit comments

Comments
 (0)