CLI#
See this for command-line interface overview.
Exceptions reporter#
- class gordo.cli.exceptions_reporter.ExceptionsReporter(exceptions: Iterable[Tuple[Type[Exception], int]], default_exit_code: int = 1, traceback_limit: int | None = None)[source]#
Bases:
objectHelper which can save the exception information in JSON format into the file. This class might be used for storing exception information after termination of the Kubernetes pod. Information
- Parameters:
exceptions – Exceptions list with preferred exit codes for each of them
default_exit_code – Default exit code. It might be used as
sys.exit()codetraceback_limit – Limit for
traceback.format_exception()
- exception_exit_code(exc_type: Type[BaseException] | None) int[source]#
Possible
sys.exit()code for given exception type- Parameters:
exc_type – The exception type
- found_exception_item(exc_type: Type[BaseException])[source]#
- report(level: ReportLevel, exc_type: Type[BaseException] | None, exc_value: BaseException | None, exc_traceback: TracebackType | None, report_file: IO[str], max_message_len: int | None = None)[source]#
Report exception to the file.
exc_type,exc_value,exc_tracebackmight be values returned bysys.exc_info()- Parameters:
level – Level of the report verbosity
exc_type – The exception type
exc_value – The exception
exc_traceback – The exception traceback
report_file – File like object for reporting
max_message_len – The maximum length of message or traceback. Actual for the environments with limitation of storage capacity. For example, 2024 bytes is the maximum size of the k8s pod termination message content
- safe_report(level: ReportLevel, exc_type: Type[BaseException] | None, exc_value: BaseException | None, exc_traceback: TracebackType | None, report_file_path: str, max_message_len: int | None = None)[source]#
Basically this is a wrapper for
report()function with additional internal exceptions handling- Parameters:
level –
exc_type –
exc_value –
exc_traceback –
report_file_path –
max_message_len –
Click types#
- class gordo.cli.custom_types.HostIP[source]#
Bases:
ParamTypeValidate input is a valid IP address
- convert(value: Any, param: Parameter | None, ctx: Context | None)[source]#
Convert the value to the correct type. This is not called if the value is
None(the missing value).This must accept string values from the command line, as well as values that are already the correct type. It may also convert other compatible types.
The
paramandctxarguments may beNonein certain situations, such as when converting prompt input.If the value cannot be converted, call
fail()with a descriptive message.- Parameters:
value – The value to convert.
param – The parameter that is using this type to convert its value. May be
None.ctx – The current context that arrived at this value. May be
None.
- class gordo.cli.custom_types.JSONParam(schema: Type[T])[source]#
Bases:
ParamType,Generic[T]Loads JSON and validates value against pydantic schema
- convert(value: Any, param: Parameter | None, ctx: Context | None) T | None[source]#
Convert the value to the correct type. This is not called if the value is
None(the missing value).This must accept string values from the command line, as well as values that are already the correct type. It may also convert other compatible types.
The
paramandctxarguments may beNonein certain situations, such as when converting prompt input.If the value cannot be converted, call
fail()with a descriptive message.- Parameters:
value – The value to convert.
param – The parameter that is using this type to convert its value. May be
None.ctx – The current context that arrived at this value. May be
None.
- class gordo.cli.custom_types.REParam(pattern: str)[source]#
Bases:
ParamTypeValidates argument over a regular expression
- convert(value: Any, param: Parameter | None, ctx: Context | None)[source]#
Convert the value to the correct type. This is not called if the value is
None(the missing value).This must accept string values from the command line, as well as values that are already the correct type. It may also convert other compatible types.
The
paramandctxarguments may beNonein certain situations, such as when converting prompt input.If the value cannot be converted, call
fail()with a descriptive message.- Parameters:
value – The value to convert.
param – The parameter that is using this type to convert its value. May be
None.ctx – The current context that arrived at this value. May be
None.
Utils#
- gordo.cli.cli.expand_model(model_config: str, model_parameters: dict)[source]#
Expands the jinja template which is the model using the variables in model_parameters
- Parameters:
model_config – Jinja template which when expanded becomes a valid model config json.
config. (model_parameters Parameters for the model) –
- Raises:
ValueError – If an undefined variable is used in the model_config.
- Return type:
The model config with variables expanded
- gordo.cli.cli.get_all_score_strings(machine)[source]#
Given metadata from the model builder this function returns a list of strings of the following format:
{metric_name}-{tag_name}_{fold-fold-number} = {score_val}. This computes the score for the given tag and cross validation split.{metric_name}-{tag_name}_{fold-aggregation} = {score_val}. This computes the score for the given tag and aggregates the score over all cross validation splits (aggregations currently used are mean, std, min and max){metric_name}_{fold-fold-number} = {score_val}. This computes the score aggregate across all tags (uses sklearn’s default aggregation method) for a given cross validation split.{metric_name}_{fold-aggregation} = {score_val}. This computes the score aggregate across all tags (uses sklearn’s default aggregation method) and cross validation splits (aggregations currently used are mean, std, min and max).for katib to pick up.
Current metric names supported are sklearn score functions: ‘r2_score’, ‘explained_variance_score’, ‘mean_squared_error’ and ‘mean_absolute_error’. The underscores in such score names are replaced by ‘-‘.
All spaces in the tag name are also replaced by ‘-‘.
- Parameters:
machine – Machine to score
- gordo.cli.workflow_generator.get_builder_exceptions_report_level(config: NormalizedConfig) ReportLevel[source]#