Skip to content

Commit

Permalink
feat: ability to supply openjd-sessions Python wheel
Browse files Browse the repository at this point in the history
Signed-off-by: Josh Usiskin <[email protected]>
  • Loading branch information
jusiskin committed Nov 20, 2024
1 parent 5d3e52d commit 82f2811
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/deadline_test_fixtures/example_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ export AWS_DATA_PATH
# Default is to pip install the latest "deadline-cloud-worker-agent" package
export WORKER_AGENT_WHL_PATH

# Local path to the openjd-sessions .whl file to use for the tests
# Default is to pip install the latest openjd-sessions package
export OPENJD_SESSIONS_WHL_PATH

# DEPRECATED: Use REGION instead
# The AWS region to configure the worker for
# Falls back to AWS_DEFAULT_REGION, then defaults to us-west-2
Expand Down
34 changes: 31 additions & 3 deletions src/deadline_test_fixtures/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ def worker_config(
Builds the configuration for a DeadlineWorker.
Environment Variables:
OPENJD_SESSIONS_WHL_PATH: Path to the openjd-sessions wheel file to use.
WORKER_POSIX_USER: The POSIX user to configure the worker for
Defaults to "deadline-worker"
WORKER_POSIX_SHARED_GROUP: The shared POSIX group to configure the worker user and job user with
Expand All @@ -434,6 +435,8 @@ def worker_config(
"DEPRECATED: The environment variable WORKER_REGION is no longer supported. Please use REGION instead."
)

pip_install_requirement_specifiers: list[str] = []

# Prepare the Worker agent Python package
worker_agent_whl_path = os.getenv("WORKER_AGENT_WHL_PATH")
if worker_agent_whl_path:
Expand All @@ -453,14 +456,39 @@ def worker_config(
)
file_mappings = [(resolved_whl_path, dest_path)]

LOG.info(f"The whl file will be copied to {dest_path} on the Worker environment")
worker_agent_requirement_specifier = dest_path
LOG.info(
f"The worker agent whl file will be copied to {dest_path} on the Worker environment"
)
pip_install_requirement_specifiers.append(dest_path)
else:
worker_agent_requirement_specifier = os.getenv(
"WORKER_AGENT_REQUIREMENT_SPECIFIER",
"deadline-cloud-worker-agent",
)
LOG.info(f"Using Worker agent package {worker_agent_requirement_specifier}")
pip_install_requirement_specifiers.append(worker_agent_requirement_specifier)

openjd_sessions_whl_path = os.getenv("OPENJD_SESSIONS_WHL_PATH")
if openjd_sessions_whl_path:
LOG.info(f"Using openjd-sessions agent whl file: {openjd_sessions_whl_path}")
resolved_whl_paths = glob.glob(openjd_sessions_whl_path)
assert (
len(resolved_whl_paths) == 1
), f"Expected exactly one openjd-sessions whl path, but got {resolved_whl_paths} (from pattern {openjd_sessions_whl_path})"
resolved_whl_path = resolved_whl_paths[0]

if operating_system.name == "AL2023":
dest_path = posixpath.join("/tmp", os.path.basename(resolved_whl_path))
else:
dest_path = posixpath.join(
"C:\\Windows\\System32\\Config\\systemprofile\\AppData\\Local\\Temp",
os.path.basename(resolved_whl_path),
)
file_mappings.append((resolved_whl_path, dest_path))
LOG.info(
f"The openjd-sessions whl file will be copied to {dest_path} on the Worker environment"
)
pip_install_requirement_specifiers.append(dest_path)

# Path map the service model
with tempfile.TemporaryDirectory() as tmpdir:
Expand All @@ -485,7 +513,7 @@ def worker_config(
region=region,
allow_shutdown=True,
worker_agent_install=PipInstall(
requirement_specifiers=[worker_agent_requirement_specifier],
requirement_specifiers=pip_install_requirement_specifiers,
codeartifact=codeartifact,
),
service_model_path=dst_path,
Expand Down

0 comments on commit 82f2811

Please sign in to comment.