in scripts/metric_reporter/config.py [0:0]
def _parse_metric_reporter_config(self, config_parser: ConfigParser) -> MetricReporterConfig:
try:
return MetricReporterConfig(
gcp_project_id=config_parser.get("metric_reporter", "gcp_project_id"),
test_result_bucket=config_parser.get("metric_reporter", "test_result_bucket"),
junit_artifact_dir=config_parser.get("metric_reporter", "junit_artifact_dir"),
coverage_artifact_dir=config_parser.get(
"metric_reporter", "coverage_artifact_dir"
),
service_account_file=config_parser.get("metric_reporter", "service_account_file"),
bigquery_dataset_name=config_parser.get(
"metric_reporter", "bigquery_dataset_name"
),
update_bigquery=config_parser.getboolean(
"metric_reporter", "update_bigquery", fallback=False
),
)
except (NoSectionError, NoOptionError, ValidationError) as error:
error_mapping: dict[type, str] = {
NoSectionError: "The 'metric_reporter' section is missing",
NoOptionError: "Missing config option in 'metric_reporter' section",
ValidationError: "Unexpected value or schema in 'metric_reporter' section",
}
error_msg: str = next(m for t, m in error_mapping.items() if isinstance(error, t))
self.logger.error(error_msg, exc_info=error)
raise InvalidConfigError(error_msg) from error