Skip to content

Support custom paths for internal dbt project via env vars#2248

Merged
michael-myaskovsky merged 4 commits into
masterfrom
fix-file-permissions-issue
Jun 2, 2026
Merged

Support custom paths for internal dbt project via env vars#2248
michael-myaskovsky merged 4 commits into
masterfrom
fix-file-permissions-issue

Conversation

@michael-myaskovsky
Copy link
Copy Markdown
Contributor

@michael-myaskovsky michael-myaskovsky commented Jun 1, 2026

Summary by CodeRabbit

  • New Features

    • CLI now respects EDR_INTERNAL_TARGET_PATH and DBT_PACKAGES_FOLDER to control where its internal dbt project writes compiled artifacts and installs packages; cleanup targets the configured path.
  • Documentation

    • Added docs with examples for setting these environment variables and a note clarifying they are separate from the CLI's external --target-path option.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

👋 @michael-myaskovsky
Thank you for raising your pull request.
Please make sure to add tests and document all user-facing changes.
You can do this by editing the docs files in this pull request.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 1, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2a772c95-bd88-4de5-a4c6-9b991af30bc2

📥 Commits

Reviewing files that changed from the base of the PR and between 7dc786a and 7ae3d49.

📒 Files selected for processing (2)
  • docs/oss/cli-commands.mdx
  • elementary/monitor/dbt_project/dbt_project.yml

📝 Walkthrough

Walkthrough

Change dbt_project.yml to read the internal dbt project's compiled-artifact path from an environment variable and add documentation describing EDR_INTERNAL_TARGET_PATH and DBT_PACKAGES_FOLDER (with examples) and how they differ from the CLI --target-path.

Changes

Internal dbt project path configuration

Layer / File(s) Summary
dbt project configuration
elementary/monitor/dbt_project/dbt_project.yml
target-path and the compiled-artifacts entry in clean-targets now use env_var('EDR_INTERNAL_TARGET_PATH', 'target') instead of a hard-coded "target". DBT_PACKAGES_FOLDER remains referenced for package cleanup.
Documentation for internal dbt directories
docs/oss/cli-commands.mdx
Adds an “Internal dbt project directories” subsection documenting default internal artifact/package locations inside the installed elementary package, introduces EDR_INTERNAL_TARGET_PATH and DBT_PACKAGES_FOLDER with export examples, and clarifies these are separate from the CLI --target-path option controlling logs/reports.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through configs, soft and spry,
Paths once rigid now learn to fly,
Env whispers point where artifacts rest,
Packages settle where you think best,
A tiny change—flexible and shy.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: supporting custom paths for the internal dbt project through environment variables.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-file-permissions-issue

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
elementary/monitor/dbt_project/dbt_project.yml (1)

24-27: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Update clean-targets to respect the environment variable overrides.

The clean-targets section still hardcodes "target" and "dbt_packages", but when users set DBT_TARGET_PATH or DBT_PACKAGES_FOLDER to custom locations, dbt clean will attempt to remove the wrong directories (the defaults) and leave stale artifacts in the custom locations.

🧹 Proposed fix to make clean-targets consistent with configurable paths
 clean-targets: # directories to be removed by `dbt clean`
-  - "target"
-  - "dbt_packages"
+  - "{{ env_var('DBT_TARGET_PATH', 'target') }}"
+  - "{{ env_var('DBT_PACKAGES_FOLDER', 'dbt_packages') }}"
   - "dbt_modules"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@elementary/monitor/dbt_project/dbt_project.yml` around lines 24 - 27, The
clean-targets entries are hardcoded and ignore
DBT_TARGET_PATH/DBT_PACKAGES_FOLDER overrides; update the clean-targets list in
dbt_project.yml to use dbt's Jinja env_var lookups instead of literals (e.g.,
replace "target" and "dbt_packages" with "{{ env_var('DBT_TARGET_PATH',
'target') }}" and "{{ env_var('DBT_PACKAGES_FOLDER', 'dbt_packages') }}" and
likewise handle "dbt_modules" via env_var if needed) so dbt clean removes the
actual configured directories; modify the clean-targets block (symbol:
clean-targets in dbt_project.yml) accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@elementary/monitor/dbt_project/dbt_project.yml`:
- Around line 24-27: The clean-targets entries are hardcoded and ignore
DBT_TARGET_PATH/DBT_PACKAGES_FOLDER overrides; update the clean-targets list in
dbt_project.yml to use dbt's Jinja env_var lookups instead of literals (e.g.,
replace "target" and "dbt_packages" with "{{ env_var('DBT_TARGET_PATH',
'target') }}" and "{{ env_var('DBT_PACKAGES_FOLDER', 'dbt_packages') }}" and
likewise handle "dbt_modules" via env_var if needed) so dbt clean removes the
actual configured directories; modify the clean-targets block (symbol:
clean-targets in dbt_project.yml) accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dfddccf4-c636-4d8c-9de1-212ce34d9fea

📥 Commits

Reviewing files that changed from the base of the PR and between 57dfbdc and b82b7d4.

📒 Files selected for processing (2)
  • docs/oss/cli-commands.mdx
  • elementary/monitor/dbt_project/dbt_project.yml

@MikaKerman
Copy link
Copy Markdown
Contributor

DBT_TARGET_PATH conflicts with upload_source_freshness

DBT_TARGET_PATH is already used in upload_source_freshness.py with a different meaning — it overrides where edr looks for the user's sources.json:

def get_target_path(self) -> Path:
if not self.config.project_dir:
raise click.ClickException(
"Path to dbt project is missing. Please run the command with `--project-dir <DBT_PROJECT_DIR>`."
)
env_target_path = os.getenv("DBT_TARGET_PATH")
if env_target_path:
return Path(env_target_path)
project_dir = Path(self.config.project_dir)
project_yml = OrderedYaml().load(str(project_dir.joinpath("dbt_project.yml")))
return project_dir / project_yml.get("target-path", "target")

Setting DBT_TARGET_PATH=/var/tmp/edr_target to fix internal project permissions will also cause edr upload-source-freshness to look for sources.json there instead of in the user's project target directory — silently breaking that command.

Consider renaming to something like EDR_INTERNAL_TARGET_PATH, or at minimum document the side effect.

PR title

"fix file permissions issue" doesn't describe what changed — something like "Support custom paths for internal dbt project via env vars" would be clearer.

@michael-myaskovsky michael-myaskovsky changed the title fix file permissions issue Support custom paths for internal dbt project via env vars Jun 2, 2026
@michael-myaskovsky michael-myaskovsky merged commit ceafcd6 into master Jun 2, 2026
27 of 28 checks passed
@michael-myaskovsky michael-myaskovsky deleted the fix-file-permissions-issue branch June 2, 2026 08:51
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