Skip to content

Commit

Permalink
add dest_dir into pythonpath before loading modules (#2692)
Browse files Browse the repository at this point in the history
Signed-off-by: Nelson Chen <asd3431090@gmail.com>
  • Loading branch information
arbaobao authored Sep 23, 2024
1 parent 5643915 commit 15dee95
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 8 additions & 1 deletion flytekit/bin/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,14 @@ def fast_execute_task_cmd(additional_distribution: str, dest_dir: str, task_exec

# Use the commandline to run the task execute command rather than calling it directly in python code
# since the current runtime bytecode references the older user code, rather than the downloaded distribution.
p = subprocess.Popen(cmd)
env = os.environ.copy()
if dest_dir is not None:
dest_dir_resolved = os.path.realpath(os.path.expanduser(dest_dir))
if "PYTHONPATH" in env:
env["PYTHONPATH"] += os.pathsep + dest_dir_resolved
else:
env["PYTHONPATH"] = dest_dir_resolved
p = subprocess.Popen(cmd, env=env)

def handle_sigterm(signum, frame):
logger.info(f"passing signum {signum} [frame={frame}] to subprocess")
Expand Down
3 changes: 3 additions & 0 deletions tests/flytekit/integration/remote/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
PROJECT = "flytesnacks"
DOMAIN = "development"
VERSION = f"v{os.getpid()}"
DEST_DIR = "/tmp"


@pytest.fixture(scope="session")
Expand Down Expand Up @@ -66,6 +67,8 @@ def run(file_name, wf_name, *args):
CONFIG,
"run",
"--remote",
"--destination-dir",
DEST_DIR,
"--image",
IMAGE,
"--project",
Expand Down

0 comments on commit 15dee95

Please sign in to comment.