1818from 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
1919from util .extract_types import get_expected_power_columns
2020from 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
2323from util .config import ERROR_KEY , model_toppath
2424from util import get_valid_feature_group_from_queries , PowerSourceMap
2525from train .prom .prom_query import _range_queries
2626from train .exporter import exporter
2727from train import load_class
2828from train .profiler .node_type_index import NodeTypeIndexCollection , NodeTypeSpec , generate_spec
2929
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
3131from 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
3232
3333import threading
@@ -215,7 +215,7 @@ def isolate(args):
215215 extracted_data , power_labels = extract (args )
216216 if extracted_data is None or power_labels is None :
217217 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
219219 isolator = get_isolator (data_path , args .isolator , args .profile , pipeline_name , args .target_hints , args .bg_hints , args .abs_pipeline_name )
220220 isolated_data = isolator .isolate (extracted_data , label_cols = power_labels , energy_source = args .energy_source )
221221 if args .output :
@@ -247,7 +247,7 @@ def isolate_from_data(args):
247247 energy_components = PowerSourceMap [args .energy_source ]
248248 extracted_data = load_csv (data_path , "extracted_" + args .input )
249249 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
251251 isolator = get_isolator (data_path , args .isolator , args .profile , pipeline_name , args .target_hints , args .bg_hints , args .abs_pipeline_name )
252252 isolated_data = isolator .isolate (extracted_data , label_cols = power_columns , energy_source = args .energy_source )
253253 if args .output :
@@ -365,7 +365,7 @@ def train(args):
365365 elif PROM_THIRDPARTY_METRICS != ["" ]:
366366 update_thirdparty_metrics (PROM_THIRDPARTY_METRICS )
367367
368- pipeline_name = DEFAULT_PIPELINE
368+ pipeline_name = default_train_output_pipeline
369369 if args .pipeline_name :
370370 pipeline_name = args .pipeline_name
371371
@@ -599,14 +599,16 @@ def estimate(args):
599599 - `estimate` passes all arguments to `estimate` function, and plots the predicted time series and correlation between usage and power metrics
600600 - `error` passes all arguments to `estimate` function, and plots the summary of prediction error
601601 - `metadata` plot pipeline metadata
602+ - `curve_power` plot curve power
603+ - --input : specify related path for pipeline metadata
602604- --energy-source : specify target energy sources (use comma(,) as delimiter)
603605- --extractor : specify extractor to get preprocessed data of AbsPower model linked to the input data
604606- --isolator : specify isolator to get preprocessed data of DynPower model linked to the input data
605607- --pipeline_name : specify pipeline name
606608"""
607609
608610def 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
610612 pipeline_path = get_pipeline_path (data_path , pipeline_name = pipeline_name )
611613 if not args .target_data :
612614 print ("must give target data via --target-data to plot." )
@@ -691,9 +693,13 @@ def plot(args):
691693 elif args .target_data == "metadata" :
692694 for energy_source in energy_sources :
693695 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 )
696697 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 )
697703
698704"""
699705export
@@ -709,6 +715,7 @@ def plot(args):
709715 - custom benchmark in json with `startTimeUTC` and `endTimeUTC` data
710716- --collect-date : specify collection time manually in UTC
711717- --input : specify kepler query response file (output of `query` function) - optional
718+ - --zip : specify whether to zip pipeline
712719"""
713720
714721def export (args ):
@@ -742,14 +749,18 @@ def export(args):
742749 pipeline_path = get_pipeline_path (data_path , pipeline_name = pipeline_name )
743750
744751 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"
746752
753+ args .input = local_export_path
747754 args .output = local_export_path
748- args .output_type = "AbsPower"
749755 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 )
753764
754765"""
755766plot_scenario
@@ -886,6 +897,7 @@ def plot_scenario(args):
886897 parser .add_argument ("--publisher" , type = str , help = "Specify github account of model publisher" )
887898 parser .add_argument ("--include-raw" , type = bool , help = "Include raw query data" )
888899 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 )
889901
890902 parser .add_argument ("--id" , type = str , help = "specify machine id" )
891903
0 commit comments