Skip to content

Commit 23fe8fb

Browse files
committed
Enhance metric batch retrieval with configurable source options
1 parent e6f41e0 commit 23fe8fb

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

dashboard/state.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ def __init__(self):
2121
Initialize the app state.
2222
"""
2323
self.specs = specs
24-
self.metric_batches = get_metric_batches()
24+
self.metric_batches = get_metric_batches(source="all")
2525
if not self.metric_batches:
26-
log.warning("No metric batches found from Dagster. Is Dagster running?")
27-
self.metric_batches = []
26+
log.warning("No metric batches found.")
2827
self.specs_enabled = {batch: specs[batch] for batch in self.metric_batches}
2928
self.df_cache = {}
3029
self.chart_cache = {}

dashboard/utils.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import requests
88
from dotenv import load_dotenv
99

10+
from anomstack.config import specs
11+
1012

1113
log = logging.getLogger("fasthtml")
1214

@@ -92,12 +94,29 @@ def get_enabled_dagster_jobs(host: str = "localhost", port: str = "3000") -> lis
9294
return []
9395

9496

95-
def get_metric_batches():
97+
def get_metric_batches(source: str = "all"):
9698
"""
97-
Get the metric batches from the enabled Dagster jobs.
99+
Get the metric batches from the enabled Dagster jobs or from the config.
100+
101+
Args:
102+
source (str): The source of the metric batches.
103+
(e.g., "dagster" or "config" or "all").
104+
105+
Returns:
106+
list: A list of metric batches.
98107
"""
99-
enabled_jobs = get_enabled_dagster_jobs(host="http://localhost", port="3000")
100-
ingest_jobs = [job for job in enabled_jobs if job.endswith("_ingest")]
101-
metric_batches = [job[:-7] for job in ingest_jobs if job.endswith("_ingest")]
108+
metric_batches = []
109+
dagster_enabled_jobs = get_enabled_dagster_jobs(host="http://localhost", port="3000")
110+
dagster_ingest_jobs = [job for job in dagster_enabled_jobs if job.endswith("_ingest")]
111+
dagster_metric_batches = [job[:-7] for job in dagster_ingest_jobs if job.endswith("_ingest")]
112+
config_metric_batches = list(specs.keys())
113+
if source == "dagster":
114+
metric_batches = dagster_metric_batches
115+
elif source == "config":
116+
metric_batches = config_metric_batches
117+
elif source == "all":
118+
metric_batches = dagster_metric_batches + config_metric_batches
119+
else:
120+
raise ValueError(f"Invalid source: {source}")
102121

103122
return metric_batches

0 commit comments

Comments
 (0)