Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
Signed-off-by: Godot Bian <[email protected]>
  • Loading branch information
godobyte committed Nov 19, 2024
1 parent 603c7e0 commit 2aa7cff
Showing 1 changed file with 18 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import sys
import json
from shlex import quote
from logging import getLogger, LoggerAdapter
from logging import LoggerAdapter
import sysconfig
from typing import Any, TYPE_CHECKING, Optional
from dataclasses import asdict
Expand All @@ -32,6 +32,7 @@

from openjd.sessions import (
LOG as OPENJD_LOG,
LogContent,
PathMappingRule as OpenjdPathMapping,
PosixSessionUser,
WindowsSessionUser,
Expand All @@ -52,30 +53,19 @@
from .openjd_action import OpenjdAction

if TYPE_CHECKING:
from concurrent.futures import Future
from ..session import Session
from ..job_entities import JobAttachmentDetails, StepDetails


logger = getLogger(__name__)


class SyncCanceled(Exception):
"""Exception indicating the synchronization was canceled"""

pass


class AttachmentDownloadAction(OpenjdAction):
"""Action to synchronize input job attachments for a AWS Deadline Cloud job
"""Action to synchronize input job attachments for a AWS Deadline Cloud Session
Parameters
----------
id : str
The unique action identifier
"""

_future: Future[None]
_job_attachment_details: Optional[JobAttachmentDetails]
_step_details: Optional[StepDetails]
_step_script: Optional[StepScript_2023_09]
Expand All @@ -102,6 +92,7 @@ def __init__(
self._logger = LoggerAdapter(OPENJD_LOG, extra={"session_id": session_id})

def set_step_script(self, manifests, path_mapping, s3_settings) -> None:
# TODO - update to run python as embedded file
profile = os.environ.get("AWS_PROFILE")
deadline_path = os.path.join(Path(sysconfig.get_path("scripts")), "deadline")

Expand Down Expand Up @@ -151,17 +142,24 @@ def start(
An executor for running futures
"""

self._logger.info(f"Syncing inputs using session {session}")

if self._step_details:
section_title = "Job Attachments Download for Step"
else:
section_title = "Job Attachments Download for Job"

# Banner mimicing the one printed by the openjd-sessions runtime
self._logger.info("==============================================")
self._logger.info(f"--------- AttachmentDownloadAction {section_title}")
self._logger.info("==============================================")
self._logger.info(
"==============================================",
extra={"openjd_log_content": LogContent.BANNER},
)
self._logger.info(
f"--------- AttachmentDownloadAction {section_title}",
extra={"openjd_log_content": LogContent.BANNER},
)
self._logger.info(
"==============================================",
extra={"openjd_log_content": LogContent.BANNER},
)

if not (job_attachment_settings := session._job_details.job_attachment_settings):
raise RuntimeError("Job attachment settings were not contained in JOB_DETAILS entity")
Expand Down Expand Up @@ -232,7 +230,7 @@ def start(
)
)

vfs_handled = self._vfs_handling(
vfs_handled = self._start_vfs(
session=session,
attachments=attachments,
merged_manifests_by_root=merged_manifests_by_root,
Expand Down Expand Up @@ -286,7 +284,7 @@ def start(
task_parameter_values=dict[str, ParameterValue](),
)

def _vfs_handling(
def _start_vfs(
self,
session: Session,
attachments: Attachments,
Expand Down

0 comments on commit 2aa7cff

Please sign in to comment.