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

Added a run_dir option to be initialized by the user in ShellFunction constructor #1648

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions compute_sdk/globus_compute_sdk/sdk/shell_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def __init__(
stderr: str,
returncode: int,
exception_name: t.Optional[str] = None,
run_dir: t.Optional[str] = None,
):
"""

Expand All @@ -34,6 +35,7 @@ def __init__(
self.stderr = stderr
self.returncode = returncode
self.exception_name = exception_name
self.run_dir = run_dir

def __str__(self):
return f"Command {self.cmd} returned with exit status: {self.returncode}"
Expand All @@ -53,6 +55,7 @@ def __init__(
stderr: t.Optional[str] = None,
walltime: t.Optional[float] = None,
snippet_lines=1000,
run_dir: t.Optional[str] = None,
):
"""Initialize a ShellFunction

Expand Down Expand Up @@ -84,6 +87,7 @@ def __init__(
if walltime:
assert walltime >= 0, f"Negative walltime={walltime} is not allowed"
self.snippet_lines = snippet_lines
self.run_dir = run_dir

@property
def __name__(self):
Expand Down Expand Up @@ -125,11 +129,11 @@ def execute_cmd_line(

sandbox_error_message = None

run_dir = None
# run_dir takes priority over sandboxing
if os.environ.get("GC_TASK_SANDBOX_DIR"):
run_dir = os.environ["GC_TASK_SANDBOX_DIR"]
else:
sandbox_dir = os.environ.get("GC_TASK_SANDBOX_DIR")
# run_dir takes precedence over sandbox_dir
run_dir = self.run_dir or sandbox_dir

if not run_dir:
sandbox_error_message = (
"WARNING: Task sandboxing will not work due to "
"endpoint misconfiguration. Please enable sandboxing "
Expand Down Expand Up @@ -194,6 +198,7 @@ def execute_cmd_line(
stderr_snippet,
returncode,
exception_name=exception_name,
run_dir=run_dir,
)

def __call__(
Expand Down