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

add dest_dir into pythonpath before loading modules #2692

Merged
merged 13 commits into from
Sep 23, 2024
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
Loading