Skip to content

Commit

Permalink
DVC_STAGE: Added environment variable to track DVC stage name (#10357)
Browse files Browse the repository at this point in the history
DVC_STAGE_NAME: Added environment variable to track DVC stage name

Fixes #10355

Co-authored-by: Rishabh Sharma <[email protected]>
  • Loading branch information
rishabhsharma22 and Rishabh Sharma authored Mar 20, 2024
1 parent f7a54bf commit 8d8939f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions dvc/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@
DVC_SQLALCHEMY_ECHO = "DVC_SQLALCHEMY_ECHO"
DVC_SYSTEM_CONFIG_DIR = "DVC_SYSTEM_CONFIG_DIR"
DVC_UPDATER_ENDPOINT = "DVC_UPDATER_ENDPOINT"
DVC_STAGE = "DVC_STAGE"
5 changes: 4 additions & 1 deletion dvc/stage/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def _enforce_cmd_list(cmd):


def prepare_kwargs(stage, run_env=None):
from dvc.env import DVC_ROOT
from dvc.env import DVC_ROOT, DVC_STAGE

kwargs = {"cwd": stage.wdir, "env": fix_env(None), "close_fds": True}

Expand All @@ -48,6 +48,9 @@ def prepare_kwargs(stage, run_env=None):
if DVC_ROOT not in kwargs["env"]:
kwargs["env"][DVC_ROOT] = stage.repo.root_dir

# Create DVC_STAGE env variable for every command
kwargs["env"][DVC_STAGE] = stage.addressing

# NOTE: when you specify `shell=True`, `Popen` [1] will default to
# `/bin/sh` on *nix and will add ["/bin/sh", "-c"] to your command.
# But we actually want to run the same shell that we are running
Expand Down

0 comments on commit 8d8939f

Please sign in to comment.