Skip to content

Commit 65dddce

Browse files
ravenac95Copilot
andauthored
feat(dagster): instrument resource loading times (#4658)
* feat(dagster): create a resource registry to lazily load resources * fix(dagster): fixes sql factory * fix(dagster): remove ecosystems data * fix(dagster): fix instrumented defintions loading * fix(dagster): typing fixes for dlt factory * chore(ops): set to deploy with dagster eagerly loading tables * fix * Update warehouse/oso_dagster/definitions/resources.py Co-authored-by: Copilot <[email protected]> * update * fix(dagster): move some things around * fix docs * more docs fixes --------- Co-authored-by: Copilot <[email protected]>
1 parent 993cfea commit 65dddce

File tree

20 files changed

+909
-418
lines changed

20 files changed

+909
-418
lines changed

lib/oso-core/oso_core/logging/decorators.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
Some potentially useful logging decorators
33
"""
44

5+
import functools
56
import logging
67

78

89
def time_function(logger: logging.Logger):
910
"""Decorator to time a function and log the duration."""
1011

1112
def decorator(func):
13+
@functools.wraps(func)
1214
def wrapper(*args, **kwargs):
1315
import time
1416

ops/helm-charts/oso-dagster/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: oso-dagster
33
description: Extension of the dagster template
44

55
type: application
6-
version: 0.18.0
6+
version: 0.19.0
77
appVersion: "1.0.0"
88
dependencies:
99
- name: dagster

ops/helm-charts/oso-dagster/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ dagster:
1313

1414
osoDagster:
1515
verboseLogs: 0
16+
eagerlyLoadSqlTables: 0
1617

1718
global:
1819
dagsterInternalName: "dagster"

ops/k8s-apps/base/dagster/dagster.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ spec:
4444
# Include internal python libraries in the dagster logs.
4545
managedPythonLoggers:
4646
- metrics_tools
47+
- oso_core
4748
- oso_dagster
4849
nameOverride: "dagster"
4950
ingress:

ops/k8s-apps/production/dagster/custom-helm-values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ metadata:
44
name: production-dagster
55
spec:
66
values:
7+
# We should eventually set this to 0, but we are setting it to 1 to gather
8+
# timing data
9+
osoDagster:
10+
eagerlyLoadSqlTables: 1
711
pg:
812
host: production-cloudsql-proxy-gcloud-sqlproxy.production-cloudsql-proxy.svc.cluster.local
913
port: "5432"

warehouse/oso_dagster/assets/ecosystems.py

Lines changed: 0 additions & 32 deletions
This file was deleted.

warehouse/oso_dagster/assets/sqlmesh.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
class SQLMeshRunConfig(dg.Config):
2020
# Set this to True to restate the selected models
2121
restate_models: list[str] | None = None
22-
22+
2323
# Set this to True to dynamically identify models to restate based on entity_category tags
2424
restate_by_entity_category: bool = False
2525
# List of entity categories to restate (e.g., ["project", "collection"])
@@ -79,30 +79,34 @@ async def sqlmesh_project(
7979
trino: TrinoResource,
8080
config: SQLMeshRunConfig,
8181
):
82-
8382
restate_models = config.restate_models[:] if config.restate_models else []
84-
85-
# Ensure that both trino and the mcs are available
83+
8684
async with multiple_async_contexts(
8785
trino=trino.ensure_available(log_override=context.log),
8886
):
8987
# If restate_by_entity_category is True, dynamically identify models based on entity categories
9088
if config.restate_by_entity_category:
9189
# Ensure we have entity categories to filter by
9290
if not config.restate_entity_categories:
93-
context.log.info("restate_by_entity_category is True but no entity categories specified. Using both 'project' and 'collection'.")
91+
context.log.info(
92+
"restate_by_entity_category is True but no entity categories specified. Using both 'project' and 'collection'."
93+
)
9494
entity_categories = ["project", "collection"]
9595
else:
9696
entity_categories = config.restate_entity_categories
97-
context.log.info(f"Filtering models by entity categories: {entity_categories}")
97+
context.log.info(
98+
f"Filtering models by entity categories: {entity_categories}"
99+
)
98100

99101
for category in entity_categories:
100102
restate_models.append(f"tag:entity_category={category}")
101103

102104
plan_options: PlanOptions = {"skip_tests": config.skip_tests}
103105
if config.allow_destructive_models:
104-
plan_options["allow_destructive_models"] = config.allow_destructive_models
105-
106+
plan_options["allow_destructive_models"] = (
107+
config.allow_destructive_models
108+
)
109+
106110
# If we specify a dev_environment, we will first plan it for safety
107111
if dev_environment:
108112
context.log.info("Planning dev environment")
@@ -130,7 +134,7 @@ async def sqlmesh_project(
130134
yield result
131135

132136
all_assets_selection = AssetSelection.assets(sqlmesh_project)
133-
137+
134138
return AssetFactoryResponse(
135139
assets=[sqlmesh_project],
136140
jobs=[

warehouse/oso_dagster/config.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,16 @@ class DagsterConfig(BaseSettings):
8383
mcs_k8s_deployment_name: str = ""
8484
mcs_connect_timeout: int = 240
8585

86+
# This is a bit of a legacy configuration that we need to remove
87+
cbt_search_paths: list[str] = Field(
88+
default_factory=lambda: [os.path.join(os.path.dirname(__file__), "models")]
89+
)
90+
91+
clickhouse_importer_secret_group_name: str = "clickhouse_importer"
92+
clickhouse_secret_group_name: str = "clickhouse"
93+
94+
eagerly_load_sql_tables: bool = False
95+
8696
@model_validator(mode="after")
8797
def handle_generated_config(self):
8898
"""Handles any configurations that can be generated from other configuration values"""

0 commit comments

Comments
 (0)