Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds condition to check XDG_DATA_HOME to set global_dir value #2361

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from

Conversation

goosethedev
Copy link

Description

Check for XDG_DATA_HOME env var when setting the global directory for storing pipeline data.

If the variable if set but ~/.dlt exists, then it is used with a warning raised to move it manually and not break backwards compatibility.

Related Issues

Additional Context

Copy link

netlify bot commented Feb 28, 2025

Deploy Preview for dlt-hub-docs canceled.

Name Link
🔨 Latest commit 9ba4871
🔍 Latest deploy log https://app.netlify.com/sites/dlt-hub-docs/deploys/67e0311bbfbccd0008959348

Copy link
Collaborator

@sh-rp sh-rp left a comment

Choose a reason for hiding this comment

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

thanks for the contribution :) I have one note, and it would be good to have a test for this. maybe in test_run_context.py

@goosethedev
Copy link
Author

For the test, for now I have this test passing in test_run_context.py:

def test_context_with_xdg_dir() -> None:
    import tempfile
    temp_data_home = os.path.join(tempfile.gettempdir(), "test")

    os.environ["XDG_DATA_HOME"] = temp_data_home

    ctx = PluggableRunContext()
    run_context = ctx.context
    assert run_context.global_dir == os.path.join(temp_data_home, "dlt")

    os.environ.pop("XDG_DATA_HOME")

As for the failing CI above, it seems I have to do if "XDG_DATA_HOME" in os.environ to avoid a KeyError. I'll fix it and rerun tests locally.

Copy link
Collaborator

@rudolfix rudolfix left a comment

Choose a reason for hiding this comment

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

@goosethedev are you planning to still work on this? to complete the PR we need to:

  1. fix the KeyError
  2. add a test that you mentioned in PR. just unit testing global_dir is also good. test_run_context.py is the right place~
  3. merge the current devel... we fixed a few tests that stopped working recently (outdated test rest API)

thanks!

@goosethedev goosethedev force-pushed the feat/2319-xdg-data-dir-support branch from ec8f5e8 to 2aa8880 Compare March 16, 2025 02:13
@goosethedev
Copy link
Author

Sorry for the delay, I was waiting for feedback on the test 😅

I decided to force-push to incorporate the new changes from devel and tidy the changes and test into one single commit. Let me know if everything's OK.

@goosethedev goosethedev force-pushed the feat/2319-xdg-data-dir-support branch from 2aa8880 to 9ba4871 Compare March 23, 2025 16:04
@goosethedev goosethedev requested review from rudolfix and sh-rp March 23, 2025 16:05
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.

Follow the XDG Base Directory spec for local pipelines' data
3 participants