Skip to content

docs(hub): document refresh a single resource in triggers - #4324

Open
ShreyasGS wants to merge 1 commit into
develfrom
docs/refresh-single-resource-triggers
Open

docs(hub): document refresh a single resource in triggers#4324
ShreyasGS wants to merge 1 commit into
develfrom
docs/refresh-single-resource-triggers

Conversation

@ShreyasGS

@ShreyasGS ShreyasGS commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Description

Adds a "Refresh a single resource" subsection under hub/pipeline-operations/triggers.md#refresh-cascade, plus a short "three sources of refresh" bullet list to make signal origins explicit.

Why

Users following the refresh="always" pattern in triggers.md had no on-page guide for the common case of "rebuild only these named tables". They'd hit KeyError-shaped confusion or reach for drop_sources (which wipes the whole source). The addition covers the missing patterns and links out to the canonical refresh-mode reference.

What's new in triggers.md#refresh-cascade

  • Three sources of run_context["refresh"]: first run (never completed), explicit --refresh on CLI, or cascade from an upstream refresh="always" (with refresh="block" severing).
  • Scoped rebuild pattern: @run.pipeline(..., refresh="always") combined with pipeline.run(source.with_resources(*resources), ...) and pipeline.refresh = "drop_resources".
  • Config-driven resource list: [jobs.<module>.<job>] in .dlt/<profile>.config.toml, so dev and prod can name different tables without a code change.
  • CLI override: dlthub local run refresh_tables -c 'resources=["..."]' for one-off runs.
  • Bulk trigger by tag: dlthub job trigger tag:refresh.
  • Cross-link to Doing a full or partial refresh for drop_data vs drop_resources vs drop_sources semantics.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
docs 01f0ada Commit Preview URL

Branch Preview URL
Aug 07 2026, 01:54 PM

@lis365b lis365b left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checked this against the runtime code, comments inline. the snippet itself works: the pipeline.refresh assignment is honored, both toml section forms resolve, and tag:refresh is synthesized from expose.tags so the job needs no declared trigger.


### Refresh a single resource

For a targeted rebuild, combine `refresh="always"` with `with_resources(*resources)` and drive the resource list from configuration so one job covers every table. The job below drops and reloads only the tables named at runtime:

@lis365b lis365b Aug 18, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refresh="always" does not affect the scoping here. the body sets pipeline.refresh = "drop_resources" and never reads run_context["refresh"].

what it does affect: start_run sees policy == "always" and clears prev_completed_run on this job and everything transitively downstream in the freshness graph (block nodes excluded). those jobs get run_context["refresh"] = True on their next run and their interval window restarts, so the effect reaches past the resources named here.

either remove refresh="always", or read run_context["refresh"] in the body and document the downstream effect.


- **First run:** the job has never completed successfully, which is the natural moment for a backfill.
- **Explicit request:** you pass `--refresh` to `dlthub run`, `dlthub local run`, or `dlthub job trigger`.
- **Cascade:** an upstream job with `refresh="always"` (or a `--refresh` triggered on an upstream) propagates the signal through the freshness graph. `refresh="block"` on a job severs the cascade at that node.

@lis365b lis365b Aug 18, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

block also ignores an explicit --refresh on the job itself, not just the cascade. start_run skips the clear and logs the request as ignored. add that to the bullet above.

also: the policy table says always originates on every run, but the cascade fires at run start, not on completion. a failed refresh run still clears prev_completed_run downstream.

dlthub job trigger tag:refresh
```

See [doing a full or partial refresh](../../general-usage/incremental-loading.md#doing-a-full-or-partial-refresh) for `drop_data` vs `drop_resources` vs `drop_sources` semantics. Use `drop_data` when the schema is still correct and only the rows should be replaced. Use `drop_resources` when the schema changed and the table should be recreated.

@lis365b lis365b Aug 18, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add the drop_sources caveat here instead of only linking it: it ignores with_resources and drops the whole source.

@lis365b lis365b left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

four smaller ones.

resources = ["inventory"]
```

The section key is `[jobs.<module>.<job>]`. Use `[jobs.<module>]` to configure every job in the module. Since configuration is per profile, `dev.config.toml` can point at a small table for fast local runs while `prod.config.toml` names the real one.

@lis365b lis365b Aug 18, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the middle segment is the module name, and the snippet above has no filename. in jobs.py the key would be [jobs.jobs.refresh_tables]. name the file in the snippet, or state that the segment is the module.

Override on the CLI for a one-off:

```sh
dlthub local run refresh_tables -c 'resources=["purchases"]'

@lis365b lis365b Aug 18, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-c only exists on dlthub local run, there is no equivalent on dlthub run. state that on the platform the resource list comes from the profile config.toml uploaded at deploy, and that this line is the local check before deploying.

Then trigger every refresh job on the platform with a tag selector:

```sh
dlthub job trigger tag:refresh

@lis365b lis365b Aug 18, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

job trigger only matches deployed jobs and does not sync. add dlthub deploy before this.

```
Above we tell `dlt` to truncate all tables belonging to resources in `data_source()` if the refresh signal got passed in the `refresh` flag.

### Refresh a single resource

@lis365b lis365b Aug 18, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this uses expose={"tags": [...]} and job trigger tag:... before the section that introduces them. the cascade and explicit-request bullets also repeat the policy table and the dlthub run backfill --refresh line above. suggest keeping only the first-run bullet and moving this subsection below tags and bulk triggering.

`run_context["refresh"]` is `True` in three cases:

- **First run:** the job has never completed successfully, which is the natural moment for a backfill.
- **Explicit request:** you pass `--refresh` to `dlthub run`, `dlthub local run`, or `dlthub job trigger`.

@lis365b lis365b Aug 18, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the first-run rule above is platform state. locally there is no completion history, refresh is resolved from --refresh and the declared policy only. say the list describes platform runs, and keep dlthub local run to the explicit case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants