Skip to content

Setting static environment variables for stage commands in dvc.yaml #10825

@JulianJvn

Description

@JulianJvn

Scenario: In a DVC stage, I want to run the main function of a Python module that's located in src/my_package/main.py in my DVC repository, i.e., python -m my_package.main. In order to make Python find it, the environment variable PYTHONPATH needs to be set to src when running this command.

Currently, this doesn't seem to be possible in an easy way. dvc.yaml only supports cmd and doesn't have an env key. dvc.stage.run already supports environment variables in theory via run_env, but they can't be set from outside. I would like a platform-independent way, i.e., no shell-specific syntax and no shell script wrapper, so that my stage runs on any platform.

#1416 is related, but is about parametrization, which I don't need. #2042 and #5332 have been closed in favor of #1416. This issue is explicitly about static, i.e., non-parametrized and non-parametrizing, values of environment variables.

I think DVC would already benefit a lot if static environment variables were supported via an env key in dvc.yaml (see #2042) and this would be a good starting point to add parametrization later (#1416).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A: pipelinesRelated to the pipelines featurediscussionrequires active participation to reach a conclusionp3-nice-to-haveIt should be done this or next sprint

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions