18
18
from util .prom_types import metric_prefix as KEPLER_METRIC_PREFIX , prom_responses_to_results , TIMESTAMP_COL , feature_to_query , update_thirdparty_metrics , node_info_column
19
19
from util .extract_types import get_expected_power_columns
20
20
from util .train_types import ModelOutputType , FeatureGroups , is_single_source_feature_group , all_feature_groups , default_trainers
21
- from util .loader import load_json , DEFAULT_PIPELINE , load_pipeline_metadata , get_pipeline_path , get_model_group_path , list_pipelines , list_model_names , load_metadata , load_csv , get_preprocess_folder , get_general_filename , load_machine_spec
22
- from util .saver import save_json , save_csv , save_train_args , _pipeline_model_metadata_filename
21
+ from util .loader import default_train_output_pipeline , load_json , load_pipeline_metadata , get_pipeline_path , get_model_group_path , list_pipelines , list_model_names , load_metadata , load_csv , get_preprocess_folder , get_general_filename , load_machine_spec
22
+ from util .saver import save_json , save_csv , save_train_args , _pipeline_model_metadata_filename , _power_curve_filename
23
23
from util .config import ERROR_KEY , model_toppath
24
24
from util import get_valid_feature_group_from_queries , PowerSourceMap
25
25
from train .prom .prom_query import _range_queries
26
26
from train .exporter import exporter
27
27
from train import load_class
28
28
from train .profiler .node_type_index import NodeTypeIndexCollection , NodeTypeSpec , generate_spec
29
29
30
- from cmd_plot import ts_plot , feature_power_plot , summary_plot , metadata_plot
30
+ from cmd_plot import ts_plot , feature_power_plot , summary_plot , metadata_plot , power_curve_plot
31
31
from cmd_util import extract_time , save_query_results , get_validate_df , summary_validation , get_extractor , check_ot_fg , get_pipeline , assert_train , get_isolator , UTC_OFFSET_TIMEDELTA
32
32
33
33
import threading
@@ -215,7 +215,7 @@ def isolate(args):
215
215
extracted_data , power_labels = extract (args )
216
216
if extracted_data is None or power_labels is None :
217
217
return None
218
- pipeline_name = DEFAULT_PIPELINE if not args .pipeline_name else args .pipeline_name
218
+ pipeline_name = default_train_output_pipeline if not args .pipeline_name else args .pipeline_name
219
219
isolator = get_isolator (data_path , args .isolator , args .profile , pipeline_name , args .target_hints , args .bg_hints , args .abs_pipeline_name )
220
220
isolated_data = isolator .isolate (extracted_data , label_cols = power_labels , energy_source = args .energy_source )
221
221
if args .output :
@@ -247,7 +247,7 @@ def isolate_from_data(args):
247
247
energy_components = PowerSourceMap [args .energy_source ]
248
248
extracted_data = load_csv (data_path , "extracted_" + args .input )
249
249
power_columns = get_expected_power_columns (energy_components = energy_components )
250
- pipeline_name = DEFAULT_PIPELINE if not args .pipeline_name else args .pipeline_name
250
+ pipeline_name = default_train_output_pipeline if not args .pipeline_name else args .pipeline_name
251
251
isolator = get_isolator (data_path , args .isolator , args .profile , pipeline_name , args .target_hints , args .bg_hints , args .abs_pipeline_name )
252
252
isolated_data = isolator .isolate (extracted_data , label_cols = power_columns , energy_source = args .energy_source )
253
253
if args .output :
@@ -365,7 +365,7 @@ def train(args):
365
365
elif PROM_THIRDPARTY_METRICS != ["" ]:
366
366
update_thirdparty_metrics (PROM_THIRDPARTY_METRICS )
367
367
368
- pipeline_name = DEFAULT_PIPELINE
368
+ pipeline_name = default_train_output_pipeline
369
369
if args .pipeline_name :
370
370
pipeline_name = args .pipeline_name
371
371
@@ -599,14 +599,16 @@ def estimate(args):
599
599
- `estimate` passes all arguments to `estimate` function, and plots the predicted time series and correlation between usage and power metrics
600
600
- `error` passes all arguments to `estimate` function, and plots the summary of prediction error
601
601
- `metadata` plot pipeline metadata
602
+ - `curve_power` plot curve power
603
+ - --input : specify related path for pipeline metadata
602
604
- --energy-source : specify target energy sources (use comma(,) as delimiter)
603
605
- --extractor : specify extractor to get preprocessed data of AbsPower model linked to the input data
604
606
- --isolator : specify isolator to get preprocessed data of DynPower model linked to the input data
605
607
- --pipeline_name : specify pipeline name
606
608
"""
607
609
608
610
def plot (args ):
609
- pipeline_name = DEFAULT_PIPELINE if not args .pipeline_name else args .pipeline_name
611
+ pipeline_name = default_train_output_pipeline if not args .pipeline_name else args .pipeline_name
610
612
pipeline_path = get_pipeline_path (data_path , pipeline_name = pipeline_name )
611
613
if not args .target_data :
612
614
print ("must give target data via --target-data to plot." )
@@ -691,9 +693,13 @@ def plot(args):
691
693
elif args .target_data == "metadata" :
692
694
for energy_source in energy_sources :
693
695
data_filename = _pipeline_model_metadata_filename (energy_source , ot .name )
694
- pipeline_path = get_pipeline_path (data_path , pipeline_name = pipeline_name )
695
- model_metadata_df = load_pipeline_metadata (pipeline_path , energy_source , ot .name )
696
+ model_metadata_df = load_pipeline_metadata (args .input , energy_source , ot .name )
696
697
metadata_plot (args , energy_source , model_metadata_df , output_folder , data_filename )
698
+ elif args .target_data == "power_curve" :
699
+ for energy_source in energy_sources :
700
+ data_filename = _power_curve_filename (energy_source , ot .name )
701
+ model_metadata_df = load_pipeline_metadata (args .input , energy_source , ot .name )
702
+ power_curve_plot (args , data_path , energy_source , output_folder , data_filename )
697
703
698
704
"""
699
705
export
@@ -709,6 +715,7 @@ def plot(args):
709
715
- custom benchmark in json with `startTimeUTC` and `endTimeUTC` data
710
716
- --collect-date : specify collection time manually in UTC
711
717
- --input : specify kepler query response file (output of `query` function) - optional
718
+ - --zip : specify whether to zip pipeline
712
719
"""
713
720
714
721
def export (args ):
@@ -742,14 +749,18 @@ def export(args):
742
749
pipeline_path = get_pipeline_path (data_path , pipeline_name = pipeline_name )
743
750
744
751
local_export_path = exporter .export (data_path , pipeline_path , output_path , publisher = args .publisher , collect_date = collect_date , inputs = inputs )
745
- args .target_data = "metadata"
746
752
753
+ args .input = local_export_path
747
754
args .output = local_export_path
748
- args .output_type = "AbsPower"
749
755
args .energy_source = "," .join (PowerSourceMap .keys ())
750
- plot (args )
751
- args .output_type = "DynPower"
752
- plot (args )
756
+ for target_data in ["metadata" , "power_curve" ]:
757
+ for ot in ModelOutputType :
758
+ args .target_data = target_data
759
+ args .output_type = ot .name
760
+ plot (args )
761
+ if args .zip :
762
+ import shutil
763
+ shutil .make_archive (local_export_path , 'zip' , local_export_path )
753
764
754
765
"""
755
766
plot_scenario
@@ -886,6 +897,7 @@ def plot_scenario(args):
886
897
parser .add_argument ("--publisher" , type = str , help = "Specify github account of model publisher" )
887
898
parser .add_argument ("--include-raw" , type = bool , help = "Include raw query data" )
888
899
parser .add_argument ("--collect-date" , type = str , help = "Specify collect date directly" )
900
+ parser .add_argument ("--zip" , type = bool , help = "Specify whether to zip pipeline" , default = False )
889
901
890
902
parser .add_argument ("--id" , type = str , help = "specify machine id" )
891
903
0 commit comments