Rebuild: Dagster code location with the sample dlt and dbt assets

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rockdrigo
2026-11-24 11:18:08 -06:00
commit 3558e24a46
6 changed files with 124 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
import mlflow
def test_logs_a_run(tmp_path):
mlflow.set_tracking_uri(f"sqlite:///{tmp_path / 'mlflow.db'}")
with mlflow.start_run() as run:
mlflow.log_param("seed", 7)
mlflow.log_metric("auc", 0.5)
got = mlflow.get_run(run.info.run_id)
assert got.data.params == {"seed": "7"} and got.data.metrics == {"auc": 0.5}
+47
View File
@@ -0,0 +1,47 @@
import os
import subprocess
import pytest
from sqlalchemy import create_engine, make_url, text
from synthetic.hospital import generate
POSTGRES = os.environ.get("POSTGRES_TEST_URL") # set by CI's postgres job
@pytest.mark.parametrize(
"backend",
["sqlite", pytest.param("postgres", marks=pytest.mark.skipif(not POSTGRES, reason="no PG"))],
)
def test_sample_job_loads_and_reloads_without_duplicates(backend, tmp_path):
generate(tmp_path / "synthetic", seed=7, patients_per_domain=20)
(tmp_path / "dagster").mkdir()
env = {
**os.environ,
"ISSSTELEON_DATA": str(tmp_path),
"DLT_DATA_DIR": str(tmp_path / "dlt"),
"DAGSTER_HOME": str(tmp_path / "dagster"),
}
if backend == "sqlite":
url = env["PLATFORM_DATABASE_URL"] = f"sqlite:///{tmp_path / 'platform.db'}"
attach = [f"ATTACH '{tmp_path}/platform__{s}.db' AS {s}" for s in ("bronze", "silver")]
else:
env.update(PLATFORM_DATABASE_URL=POSTGRES, DBT_TARGET="postgres")
url = make_url(POSTGRES).set(drivername="postgresql+psycopg2") # dlt's driver
attach = []
with create_engine(url).begin() as con:
con.exec_driver_sql("drop schema if exists bronze cascade")
con.exec_driver_sql("drop schema if exists silver cascade")
for _ in range(2): # each run in its own process, as the Dagster daemon launches them
subprocess.run(
["dagster", "job", "execute", "-m", "models.definitions", "-j", "sample"],
env=env,
check=True,
capture_output=True,
)
with create_engine(url).connect() as con:
for statement in attach:
con.exec_driver_sql(statement)
assert con.execute(text("select count(*) from bronze.patients")).scalar() == 20
assert con.execute(text("select count(*) from silver.cacu_patients")).scalar() == 20