Skip to content

Commit

Permalink
feat: make os_user optional in cleanup_session (#232)
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Axelson <baxelson@amazon.com>
  • Loading branch information
baxeaz committed Mar 23, 2024
1 parent 02a211d commit 241d12b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/deadline/job_attachments/asset_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@
mount_vfs_from_manifests,
)

from .exceptions import AssetSyncError, VFSExecutableMissingError, JobAttachmentsS3ClientError
from .exceptions import (
AssetSyncError,
VFSExecutableMissingError,
JobAttachmentsS3ClientError,
VFSOSUserNotSetError,
)
from .vfs import VFSProcessManager
from .models import (
Attachments,
Expand Down Expand Up @@ -566,10 +571,15 @@ def sync_outputs(
return summary_stats

def cleanup_session(
self, session_dir: Path, file_system: JobAttachmentsFileSystem, os_user: str
self,
session_dir: Path,
file_system: JobAttachmentsFileSystem,
os_user: Optional[str] = None,
):
if file_system == JobAttachmentsFileSystem.COPIED.value:
return
if not os_user:
raise VFSOSUserNotSetError("No os user set - can't clean up vfs session")
try:
VFSProcessManager.find_vfs()
# Shutdown all running Deadline VFS processes since session is complete
Expand Down
6 changes: 6 additions & 0 deletions src/deadline/job_attachments/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ class VFSFailedToMountError(JobAttachmentsError):
"""


class VFSOSUserNotSetError(JobAttachmentsError):
"""
Exception attempting to use the vfs without an os user
"""


class UnsupportedHashingAlgorithmError(JobAttachmentsError):
"""
Exception for when an unsupported hashing algorithm is provided.
Expand Down
13 changes: 13 additions & 0 deletions test/unit/deadline_job_attachments/test_asset_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from deadline.job_attachments.exceptions import (
VFSExecutableMissingError,
JobAttachmentsS3ClientError,
VFSOSUserNotSetError,
)
from deadline.job_attachments.models import (
Attachments,
Expand Down Expand Up @@ -877,3 +878,15 @@ def test_cleanup_session_vfs_terminate_called(self, tmp_path):
)

mock_find_vfs.assert_called_once()

def test_cleanup_session_virtual_witout_os_user_raises(self, tmp_path):
self.default_asset_sync.cleanup_session(
session_dir=tmp_path,
file_system=JobAttachmentsFileSystem.COPIED,
)

with pytest.raises(VFSOSUserNotSetError):
self.default_asset_sync.cleanup_session(
session_dir=tmp_path,
file_system=JobAttachmentsFileSystem.VIRTUAL,
)

0 comments on commit 241d12b

Please sign in to comment.