2020from .config_list_generic import ConfigListGeneric
2121from .config_list_string import ConfigListString
2222from .config_defaults import \
23- DEFAULT_CHECKPOINT_DIRECTORY , DEFAULT_EXPORT_PATH , DEFAULT_REPORT_FORMAT , DEFAULT_REPORT_PLOTS
23+ DEFAULT_CHECKPOINT_DIRECTORY , DEFAULT_EXPORT_PATH , \
24+ DEFAULT_OFFLINE_REPORT_PLOTS , DEFAULT_ONLINE_REPORT_PLOTS , DEFAULT_REPORT_FORMAT
2425from .config_field import ConfigField
2526from .config_primitive import ConfigPrimitive
2627from .config_command import ConfigCommand
@@ -36,7 +37,6 @@ class ConfigCommandReport(ConfigCommand):
3637 """
3738 Model Analyzer config object.
3839 """
39-
4040 def _fill_config (self ):
4141 """
4242 Builder function makes calls to add config to
@@ -59,21 +59,22 @@ def _fill_config(self):
5959 "Full path to directory to which to read and write checkpoints and profile data."
6060 ))
6161 self ._add_config (
62- ConfigField ('export_path' ,
63- flags = ['--export-path' , '-e' ],
64- default_value = DEFAULT_EXPORT_PATH ,
65- field_type = ConfigPrimitive (str ),
66- description =
67- "Full path to directory in which to store the results" ))
62+ ConfigField (
63+ 'export_path' ,
64+ flags = ['--export-path' , '-e' ],
65+ default_value = DEFAULT_EXPORT_PATH ,
66+ field_type = ConfigPrimitive (str ),
67+ description =
68+ "Full path to directory in which to store the results" ))
6869 plots_scheme = ConfigObject (schema = {
6970 '*' :
70- ConfigObject (
71- schema = {
72- 'title' : ConfigPrimitive (type_ = str ),
73- 'x_axis' : ConfigPrimitive (type_ = str ),
74- 'y_axis' : ConfigPrimitive (type_ = str ),
75- 'monotonic' : ConfigPrimitive (type_ = bool )
76- })
71+ ConfigObject (
72+ schema = {
73+ 'title' : ConfigPrimitive (type_ = str ),
74+ 'x_axis' : ConfigPrimitive (type_ = str ),
75+ 'y_axis' : ConfigPrimitive (type_ = str ),
76+ 'monotonic' : ConfigPrimitive (type_ = bool )
77+ })
7778 },
7879 output_mapper = ConfigPlot .from_object )
7980 self ._add_config (
@@ -84,7 +85,7 @@ def _fill_config(self):
8485 ConfigListGeneric (type_ = plots_scheme ,
8586 output_mapper = ConfigPlot .from_list )
8687 ]),
87- default_value = DEFAULT_REPORT_PLOTS ,
88+ default_value = DEFAULT_ONLINE_REPORT_PLOTS ,
8889 description =
8990 'Model analyzer uses the information in this section to construct plots of the results.'
9091 ))
@@ -131,6 +132,33 @@ def _fill_config(self):
131132 ]),
132133 description = 'Output file format for detailed report.' ))
133134
135+ def set_config_values (self , args ):
136+ """
137+ Set the config values. This function sets all the values for the
138+ config. CLI arguments have the highest priority, then YAML config
139+ values and then default values.
140+
141+ Parameters
142+ ----------
143+ args : argparse.Namespace
144+ Parsed arguments from the CLI
145+
146+ Raises
147+ ------
148+ TritonModelAnalyzerException
149+ If the required fields are not specified, it will raise
150+ this exception
151+ """
152+
153+ if args .mode == 'online' :
154+ self ._fields ['plots' ].set_default_value (
155+ DEFAULT_ONLINE_REPORT_PLOTS )
156+ elif args .mode == 'offline' :
157+ self ._fields ['plots' ].set_default_value (
158+ DEFAULT_OFFLINE_REPORT_PLOTS )
159+
160+ super ().set_config_values (args )
161+
134162 def _preprocess_and_verify_arguments (self ):
135163 """
136164 Enforces some rules on the config.
@@ -167,7 +195,8 @@ def _autofill_values(self):
167195 'x_axis' : plot .x_axis (),
168196 'y_axis' : plot .y_axis (),
169197 'monotonic' : plot .monotonic ()
170- } for plot in self .plots
198+ }
199+ for plot in self .plots
171200 }
172201 else :
173202 new_report_model_config ['plots' ] = {
@@ -176,10 +205,12 @@ def _autofill_values(self):
176205 'x_axis' : plot .x_axis (),
177206 'y_axis' : plot .y_axis (),
178207 'monotonic' : plot .monotonic ()
179- } for plot in model .plots ()
208+ }
209+ for plot in model .plots ()
180210 }
181211
182212 new_report_model_configs [
183213 model .model_config_name ()] = new_report_model_config
184214
185- self ._fields ['report_model_configs' ].set_value (new_report_model_configs )
215+ self ._fields ['report_model_configs' ].set_value (
216+ new_report_model_configs )
0 commit comments