Skip to content

Commit

Permalink
Merge pull request #80 from zqzten/algo
Browse files Browse the repository at this point in the history
Algo: Make tsf model train script more general
  • Loading branch information
dayko2019 committed Oct 30, 2023
2 parents 10f40f6 + ee1954c commit e01015f
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions algorithm/kapacity/timeseries/forecasting/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,22 @@ def fetch_train_data(args, config):


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

df = pd.DataFrame(columns=['timestamp', 'value', 'workload', 'metric'])
for i in range(len(target['metrics'])):
metric = target['metrics'][i]
if metric['type'] != 'Object' and metric['type'] != 'External':
raise RuntimeError('UnsupportedMetricType')
workload_namespace = target['workloadNamespace']
workload_name = target['workloadName']
df_metric = query.fetch_metrics(addr=args.metrics_server_addr,
namespace=workload_namespace,
metric=metric,
start=start,
end=end)
df_metric = query.fetch_metrics(args.metrics_server_addr,
workload_namespace,
metric,
target['workloadRef'],
start,
end)
df_metric['metric'] = metric['name']
df_metric['workload'] = '%s/%s' % (workload_namespace, workload_name)
df_metric['workload'] = workload_identifier
df = pd.concat([df, df_metric])
return df

Expand Down

0 comments on commit e01015f

Please sign in to comment.