Skip to content

Commit

Permalink
Fix automated monitoring, prevent duplicate queries
Browse files Browse the repository at this point in the history
  • Loading branch information
m1n0 committed May 3, 2024
1 parent 5e51e69 commit 0903719
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
5 changes: 0 additions & 5 deletions soda/core/soda/execution/check/automated_monitoring_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ def create_anomaly_detection_checks(self) -> List[AnomalyMetricCheck]:
)
anomaly_metric_check.archetype = "volumeConsistency"

# Execute query to change the value of metric class to get the historical results
self.data_source_scan.execute_queries()

annomaly_detection_checks.append(anomaly_metric_check)

return annomaly_detection_checks
Expand Down Expand Up @@ -110,8 +107,6 @@ def create_schema_checks(self) -> List[SchemaCheck]:
schema_check = SchemaCheck(schema_check_cfg, self.data_source_scan, partition=partition)
schema_check.archetype = "schemaConsistency"

# Execute query to change the value of metric class to get the historical results
self.data_source_scan.execute_queries()
schema_checks.append(schema_check)
return schema_checks

Expand Down
12 changes: 6 additions & 6 deletions soda/core/soda/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,12 @@ def execute(self) -> int:
self._logs.info(f"Refer to list of valid attributes and values at {attributes_page_url}.")

if not invalid_checks:
# Run profiling, data samples, automated monitoring, sample tables
try:
self.run_data_source_scan()
except Exception as e:
self._logs.error("""An error occurred while executing data source scan""", exception=e)

# Each data_source is asked to create metric values that are returned as a list of query results
for data_source_scan in self._data_source_scans:
data_source_scan.execute_queries()
Expand All @@ -518,12 +524,6 @@ def execute(self) -> int:
for metric_dep in metric.derived_formula.metric_dependencies.values():
metric.queries += metric_dep.queries

# Run profiling, data samples, automated monitoring, sample tables
try:
self.run_data_source_scan()
except Exception as e:
self._logs.error("""An error occurred while executing data source scan""", exception=e)

# Evaluates the checks based on all the metric values
for check in self._checks:
# First get the metric values for this check
Expand Down

0 comments on commit 0903719

Please sign in to comment.