Skip to content

Commit

Permalink
refactor: Rename File system options from PRELOAD/ON_DEMAND to COPIED…
Browse files Browse the repository at this point in the history
…/VIRTUAL

Signed-off-by: Phanindra Bhagavatula <[email protected]>
  • Loading branch information
pH-amz committed Sep 25, 2023
1 parent 2b89ad7 commit 31cb93c
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/deadline_worker_agent/api_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ class Attachments(TypedDict):
manifests: list[ManifestProperties]
"""A list of all manifests and their configuration"""

assetLoadingMethod: NotRequired[str]
fileSystem: NotRequired[str]
"""Method to use when loading assets required for a job"""


Expand Down
2 changes: 1 addition & 1 deletion src/deadline_worker_agent/boto/shim.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def batch_get_job_entity(
"jobId": "job-21432d89b44a46cbaaeb2f1d5254e548",
"attachments": {
"manifests": [],
"assetLoadingMethod": "PRELOAD",
"fileSystem": "COPIED",
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import Any, cast

from openjd.sessions import Parameter, ParameterType
from deadline.job_attachments.models import AssetLoadingMethod
from deadline.job_attachments.models import JobAttachmentsFileSystem

from ...api_models import (
FloatParameter,
Expand Down Expand Up @@ -84,7 +84,7 @@ class JobAttachmentDetails:
Each item in the list specifies its path, required input assets, and output assets.
"""

asset_loading_method: AssetLoadingMethod = AssetLoadingMethod.PRELOAD
job_attachments_file_system: JobAttachmentsFileSystem = JobAttachmentsFileSystem.COPIED
"""Method to use when loading assets required for a job"""

@classmethod
Expand Down Expand Up @@ -126,9 +126,9 @@ def from_boto(
)
for manifest_properties in job_attachments_details_data["attachments"]["manifests"]
],
asset_loading_method=AssetLoadingMethod(
job_attachments_file_system=JobAttachmentsFileSystem(
job_attachments_details_data["attachments"].get(
"assetLoadingMethod", AssetLoadingMethod.PRELOAD
"fileSystem", JobAttachmentsFileSystem.COPIED
)
),
)
Expand Down Expand Up @@ -185,7 +185,7 @@ def validate_entity_data(cls, entity_data: dict[str, Any]) -> JobAttachmentDetai
Field(key="inputManifestHash", expected_type=str, required=False),
),
),
Field(key="assetLoadingMethod", expected_type=str, required=False),
Field(key="fileSystem", expected_type=str, required=False),
),
),
),
Expand Down
4 changes: 2 additions & 2 deletions src/deadline_worker_agent/sessions/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ def progress_handler(job_upload_status: ProgressReportMetadata) -> bool:

attachments = Attachments(
manifests=manifest_properties_list,
assetLoadingMethod=self._job_attachment_details.asset_loading_method,
fileSystem=self._job_attachment_details.job_attachments_file_system,
)

storage_profiles_path_mapping_rules_dict: dict[str, str] = {
Expand Down Expand Up @@ -1064,7 +1064,7 @@ def _sync_asset_outputs(

attachments = Attachments(
manifests=manifest_properties_list,
assetLoadingMethod=job_attachment_details.asset_loading_method,
fileSystem=job_attachment_details.job_attachments_file_system,
)

storage_profiles_path_mapping_rules_dict: dict[str, str] = {
Expand Down
10 changes: 5 additions & 5 deletions test/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from typing import Generator, Optional

from deadline.job_attachments.models import (
AssetLoadingMethod,
JobAttachmentsFileSystem,
Attachments,
ManifestProperties,
OperatingSystemFamily,
Expand Down Expand Up @@ -215,19 +215,19 @@ def job_attachment_manifest_properties(


@pytest.fixture
def asset_loading_method() -> AssetLoadingMethod:
return AssetLoadingMethod.PRELOAD
def job_attachments_file_system() -> JobAttachmentsFileSystem:
return JobAttachmentsFileSystem.COPIED


@pytest.fixture
def job_attachment_details(
job_attachment_manifest_properties: JobAttachmentManifestProperties,
asset_loading_method: AssetLoadingMethod,
job_attachments_file_system: JobAttachmentsFileSystem,
) -> JobAttachmentDetails | None:
"""Job attachment settings for the job"""
return JobAttachmentDetails(
manifests=[job_attachment_manifest_properties],
asset_loading_method=asset_loading_method,
job_attachments_file_system=job_attachments_file_system,
)


Expand Down
4 changes: 2 additions & 2 deletions test/unit/scheduler/test_session_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from unittest.mock import MagicMock, Mock, patch
from collections import OrderedDict

from deadline.job_attachments.models import AssetLoadingMethod
from deadline.job_attachments.models import JobAttachmentsFileSystem
from openjd.model import SchemaVersion, UnsupportedSchema
from openjd.model.v2023_09 import (
Environment,
Expand Down Expand Up @@ -170,7 +170,7 @@ class TestSessionActionQueueDequeue:
SyncInputJobAttachmentsAction(
id="id",
job_attachment_details=JobAttachmentDetails(
asset_loading_method=AssetLoadingMethod.PRELOAD,
job_attachments_file_system=JobAttachmentsFileSystem.COPIED,
manifests=[],
),
),
Expand Down
10 changes: 5 additions & 5 deletions test/unit/sessions/test_job_attachment_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@

import pytest

from deadline.job_attachments.models import AssetLoadingMethod
from deadline.job_attachments.models import JobAttachmentsFileSystem
from deadline_worker_agent.sessions.job_entities.job_attachment_details import JobAttachmentDetails


@pytest.mark.parametrize("loading_method", [e.value for e in AssetLoadingMethod])
@pytest.mark.parametrize("loading_method", [e.value for e in JobAttachmentsFileSystem])
def test_asset_loading_method(loading_method):
"""Test that the loading method is read from the boto data into JobAttachmentDetails"""
entity_obj = JobAttachmentDetails.from_boto(
job_attachments_details_data={
"jobId": "myjob",
"attachments": {
"manifests": [],
"assetLoadingMethod": loading_method,
"fileSystem": loading_method,
},
},
)

assert entity_obj is not None
assert entity_obj.asset_loading_method == loading_method
assert entity_obj.job_attachments_file_system == loading_method


def test_asset_loading_method_default():
Expand All @@ -35,4 +35,4 @@ def test_asset_loading_method_default():
)

assert entity_obj is not None
assert entity_obj.asset_loading_method == AssetLoadingMethod.PRELOAD
assert entity_obj.job_attachments_file_system == JobAttachmentsFileSystem.COPIED
8 changes: 3 additions & 5 deletions test/unit/sessions/test_job_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Generator
from unittest.mock import MagicMock, patch

from deadline.job_attachments.models import AssetLoadingMethod
from deadline.job_attachments.models import JobAttachmentsFileSystem
from openjd.model import SchemaVersion
from openjd.model.v2023_09 import (
Action,
Expand Down Expand Up @@ -357,17 +357,15 @@ def test_job_attachment_details(self, deadline_client: MagicMock, job_id: str):
details_boto = JobAttachmentDetailsBoto(
jobAttachmentDetails=JobAttachmentDetailsData(
jobId=job_id,
attachments=Attachments(
manifests=[], assetLoadingMethod=AssetLoadingMethod.PRELOAD
),
attachments=Attachments(manifests=[], fileSystem=JobAttachmentsFileSystem.COPIED),
)
)
response: BatchGetJobEntityResponse = {
"entities": [details_boto],
"errors": [],
}
expected_details = JobAttachmentDetails(
manifests=[], asset_loading_method=AssetLoadingMethod.PRELOAD
manifests=[], job_attachments_file_system=JobAttachmentsFileSystem.COPIED
)
deadline_client.batch_get_job_entity.return_value = response
job_entities = JobEntities(
Expand Down
20 changes: 11 additions & 9 deletions test/unit/sessions/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
)
from deadline.job_attachments.models import (
Attachments,
AssetLoadingMethod,
JobAttachmentsFileSystem,
PosixFileSystemPermissionSettings,
)
import deadline_worker_agent.sessions.session as session_mod
Expand Down Expand Up @@ -482,17 +482,19 @@ def mock_asset_sync(self, session: Session) -> Generator[MagicMock, None, None]:
with patch.object(session, "_asset_sync") as mock_asset_sync:
yield mock_asset_sync

# This overrides the asset_loading_method fixture in tests/unit/conftest.py which feeds into
# This overrides the job_attachments_file_system fixture in tests/unit/conftest.py which feeds into
# the job_attachment_details fixture
@pytest.mark.parametrize("asset_loading_method", [e.value for e in AssetLoadingMethod])
@pytest.mark.parametrize(
"job_attachments_file_system", [e.value for e in JobAttachmentsFileSystem]
)
def test_asset_loading_method(
self,
session: Session,
asset_loading_method: AssetLoadingMethod,
job_attachments_file_system: JobAttachmentsFileSystem,
mock_asset_sync: MagicMock,
job_attachment_details: JobAttachmentDetails,
) -> None:
"""Tests that the asset_loading_method specified in session._job_details is properly passed to the sync_inputs function"""
"""Tests that the job_attachments_file_system specified in session._job_details is properly passed to the sync_inputs function"""
# GIVEN
mock_sync_inputs: MagicMock = mock_asset_sync.sync_inputs
mock_sync_inputs.return_value = ({}, {})
Expand All @@ -511,7 +513,7 @@ def test_asset_loading_method(
session_dir=ANY,
attachments=Attachments(
manifests=ANY,
assetLoadingMethod=asset_loading_method,
fileSystem=job_attachments_file_system,
),
fs_permission_settings=PosixFileSystemPermissionSettings(
os_group="some-group",
Expand All @@ -531,7 +533,7 @@ def test_asset_loading_method(
{
"job_attachment_details": JobAttachmentDetails(
manifests=[],
asset_loading_method="PRELOAD",
job_attachments_file_system="COPIED",
)
}
],
Expand All @@ -542,7 +544,7 @@ def test_asset_loading_method(
{
"job_attachment_details": JobAttachmentDetails(
manifests=[],
asset_loading_method="PRELOAD",
job_attachments_file_system="COPIED",
)
},
{"step_dependencies": ["step-1"]},
Expand Down Expand Up @@ -619,7 +621,7 @@ def test_job_attachments_path_mapping_rules_compatibility(
sync_asset_inputs_args = {
"job_attachment_details": JobAttachmentDetails(
manifests=[],
asset_loading_method=AssetLoadingMethod.PRELOAD,
job_attachments_file_system=JobAttachmentsFileSystem.COPIED,
)
}

Expand Down

0 comments on commit 31cb93c

Please sign in to comment.