Skip to content

Commit

Permalink
feat: allow local session logs to be turned off in worker tests (#155)
Browse files Browse the repository at this point in the history
Signed-off-by: Yutong Li <52769999+YutongLi291@users.noreply.github.com>
  • Loading branch information
YutongLi291 authored Oct 15, 2024
1 parent d75f580 commit 656db75
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/deadline_test_fixtures/deadline/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class DeadlineWorkerConfiguration:
start_service: bool = False
no_install_service: bool = False
service_model_path: str | None = None
no_local_session_logs: str | None = None

"""Mapping of files to copy from host environment to worker environment"""
file_mappings: list[tuple[str, str]] | None = None
Expand Down Expand Up @@ -460,6 +461,12 @@ def configure_worker_common(self, *, config: DeadlineWorkerConfiguration) -> str
f"Copy-Item -Path ~\\.aws\\* -Destination C:\\Users\\{config.job_user}\\.aws\\models -Recurse"
)

if config.no_local_session_logs:
cmds.append(
"[System.Environment]::SetEnvironmentVariable('DEADLINE_WORKER_LOCAL_SESSION_LOGS', 'false', [System.EnvironmentVariableTarget]::Machine); "
"$env:DEADLINE_WORKER_LOCAL_SESSION_LOGS = [System.Environment]::GetEnvironmentVariable('DEADLINE_WORKER_LOCAL_SESSION_LOGS','Machine')",
)

if os.environ.get("DEADLINE_WORKER_ALLOW_INSTANCE_PROFILE"):
LOG.info(
f"Using DEADLINE_WORKER_ALLOW_INSTANCE_PROFILE: {os.environ.get('DEADLINE_WORKER_ALLOW_INSTANCE_PROFILE')}"
Expand Down Expand Up @@ -667,6 +674,10 @@ def configure_agent_user_environment(
f"runuser -l {config.agent_user} -s /bin/bash -c 'aws configure add-model --service-model file://{config.service_model_path}'"
)

if config.no_local_session_logs:
cmds.append(
f"runuser -l {config.agent_user} -s /bin/bash -c 'echo export DEADLINE_WORKER_LOCAL_SESSION_LOGS=false >> ~/.bashrc'",
)
if os.environ.get("DEADLINE_WORKER_ALLOW_INSTANCE_PROFILE"):
LOG.info(
f"Using DEADLINE_WORKER_ALLOW_INSTANCE_PROFILE: {os.environ.get('DEADLINE_WORKER_ALLOW_INSTANCE_PROFILE')}"
Expand Down

0 comments on commit 656db75

Please sign in to comment.