DEV Community

Cover image for Building an Agent That Turns DataHub Metadata Into Airflow DAGs
Mark
Mark

Posted on

Building an Agent That Turns DataHub Metadata Into Airflow DAGs

Built this with my teammate for DataHub's "Build with DataHub: The Agent Hackathon." The hackathon has wrapped up, but we're continuing to develop it.

The problem

If you're using DataHub, you already have lineage, freshness SLAs, PII tags, and glossary terms sitting there. But turning that into an actual Airflow DAG still means doing it by hand.

What it does

Give it a table name, and it:

Walks the lineage graph backwards to find every upstream dependency
Reads tags (pii, daily_refresh) and glossary terms (FreshnessSLA, EmptyLoad) on each table
Maps signals to tasks, pii → audit task, FreshnessSLA → freshness check
Topologically sorts and reduces the graph, then renders a clean, deterministic Airflow 3 DAG
Can optionally open a GitHub PR with a lineage summary

How it's built

Two modes: an agent mode, where an LLM (Claude, or any model via OpenRouter) explores the DataHub graph through the MCP protocol and produces a plan, and a script mode that skips the LLM entirely for CI use.

The design decision I'd love feedback on: the LLM never writes code directly. It only outputs a structured plan, and a separate deterministic renderer turns that into the actual Airflow task code. Felt like the right boundary between "useful agent" and "don't let an LLM generate arbitrary code that ends up scheduled in prod."

Still rough around the edges

No dbt or Spark operator support yet (just shell task stubs), no schema drift detection, and it's mostly only been tested against the DataHub NYC Taxi sample dataset so far.

Try it

GitHub: github.com/tdm291104/datahub-dag-generator
Devpost: devpost.com/software/datahub-dag-generator
Demo: youtube.com/watch?v=2f0uNNmSBfc

Feedback and contributions welcome, and if you find it useful, a star on the repo goes a long way!!!

Top comments (0)