Skip to content
Latchkey

Great Expectations "DataContextError ... no such datasource" in CI

Great Expectations loaded the Data Context but could not find the datasource your checkpoint references. Either the datasource is not defined in great_expectations.yml, or the context was found at the wrong path in CI.

What this error means

GE raises "DataContextError: Unable to load datasource warehouse" or "no such datasource", usually because CI runs from a directory where the great_expectations/ config is absent or differs from local.

great_expectations
great_expectations.exceptions.DataContextError: Unable to load datasource
"warehouse" -- no such datasource in this Data Context.

Common causes

The datasource is not defined in config

The checkpoint names warehouse, but great_expectations.yml has no datasource by that name, or it was added only to a local, uncommitted context.

CI loads a Data Context from the wrong directory

get_context() searches from the working directory; if the step runs elsewhere it may load an empty or default context that lacks your datasource.

How to fix it

Point the context at the committed config

  1. Confirm great_expectations/great_expectations.yml is committed and defines the datasource.
  2. Pass an explicit context_root_dir so CI loads the right config.
  3. Re-run the checkpoint and confirm the datasource resolves.
validate.py
import great_expectations as gx
context = gx.get_context(context_root_dir="great_expectations")

Define the datasource explicitly

Ensure the datasource block exists in great_expectations.yml with the same name the checkpoint uses, including the connection string sourced from a CI secret.

great_expectations.yml
datasources:
  warehouse:
    class_name: Datasource
    execution_engine:
      class_name: SqlAlchemyExecutionEngine
      connection_string: ${WAREHOUSE_URL}

How to prevent it

  • Commit the full great_expectations/ config, not just suites.
  • Pass an explicit context_root_dir in CI rather than relying on cwd.
  • Source connection strings from CI secrets, not local config.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →