Skip to content

Commit

Permalink
Merge pull request #11 from AllenInstitute/feature/add-privileged
Browse files Browse the repository at this point in the history
add privileged to batch job builder
  • Loading branch information
rpmcginty authored Jul 1, 2024
2 parents cb32318 + 6fb067e commit 44618ad
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/aibs_informatics_aws_lambda/handlers/batch/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def handle(
resource_requirements=request.resource_requirements,
mount_points=request.mount_points,
volumes=request.volumes,
privileged=request.privileged,
)

response = register_job_definition(
Expand Down
1 change: 1 addition & 0 deletions src/aibs_informatics_aws_lambda/handlers/batch/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class CreateDefinitionAndPrepareArgsRequest(SchemaModel):
mount_points: List[MountPointTypeDef] = custom_field(default_factory=list)
volumes: List[VolumeTypeDef] = custom_field(default_factory=list)
retry_strategy: Optional[RetryStrategyTypeDef] = custom_field(default=None)
privileged: bool = custom_field(default=False)


@dataclass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,8 @@ def generate_batch_job_builder(
mount_points=[_.mount_point for _ in vol_configurations],
volumes=[_.volume for _ in vol_configurations],
env_base=env_base,
# TODO: need to make this configurable
privileged=True,
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def handle(self, request: PrepareDemandScaffoldingRequest) -> PrepareDemandScaff
mount_points=batch_job_builder.mount_points,
volumes=batch_job_builder.volumes,
retry_strategy=build_retry_strategy(num_retries=5),
privileged=batch_job_builder.privileged,
),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
EFS_TMP_ACCESS_POINT_NAME,
EFS_TMP_PATH,
)
from aibs_informatics_aws_utils.efs import MountPointConfiguration
from aibs_informatics_aws_utils.efs import MountPointConfiguration, detect_mount_points
from aibs_informatics_core.env import EnvBase
from aibs_informatics_core.models.aws.efs import EFSPath
from aibs_informatics_core.models.aws.s3 import S3URI
Expand Down Expand Up @@ -316,6 +316,8 @@ def setUp(self) -> None:
self.mock_efs.start()
self.set_aws_credentials()
self.setUpEFS()
# NOTE: detect_mount_points is cached. We need to clear the cache
detect_mount_points.cache_clear()

def tearDown(self) -> None:
self.mock_efs.stop()
Expand Down Expand Up @@ -590,7 +592,7 @@ def test__batch_job_builder__conditional_write_mode__not_required(self):

def test__batch_job_builder__conditional_write_mode__required(self):
demand_execution = get_any_demand_execution(
execution_id=uuid_str("123"),
execution_id=uuid_str("1234"),
execution_parameters=DemandExecutionParameters(
command=["cmd", "${ENV_BASE}"],
params={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ def test__handle__simple_case(self, mock_construct_batch_efs_configuration) -> N
batch_job_builder.resource_requirements = []
batch_job_builder.mount_points = []
batch_job_builder.volumes = []
batch_job_builder.privileged = False

expected = PrepareDemandScaffoldingResponse(
demand_execution=self.demand_execution,
Expand Down Expand Up @@ -279,6 +280,7 @@ def test__handle__file_system_overrides(self, mock_construct_batch_efs_configura
batch_job_builder.resource_requirements = []
batch_job_builder.mount_points = []
batch_job_builder.volumes = []
batch_job_builder.privileged = False

expected = PrepareDemandScaffoldingResponse(
demand_execution=self.demand_execution,
Expand Down

0 comments on commit 44618ad

Please sign in to comment.