Skip to content

Commit

Permalink
add cache to detect_mount_points
Browse files Browse the repository at this point in the history
  • Loading branch information
rpmcginty committed Jun 26, 2024
1 parent b38f7fc commit ef3f552
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ requires-python = ">=3.9"

dependencies = [
"boto3~=1.26.49",
"aibs-informatics-core @ git+ssh://[email protected]/AllenInstitute/aibs-informatics-core.git@feature/update-batch-data-sync-models",
"aibs-informatics-core @ git+ssh://[email protected]/AllenInstitute/aibs-informatics-core.git@main",
]

[project.optional-dependencies]
Expand Down
2 changes: 2 additions & 0 deletions src/aibs_informatics_aws_utils/efs/mount_point.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import re
from functools import cache

__all__ = [
"MountPointConfiguration",
Expand Down Expand Up @@ -375,6 +376,7 @@ def __repr__(self) -> str:
)


@cache
def detect_mount_points() -> List[MountPointConfiguration]:
mount_points: List[MountPointConfiguration] = []

Expand Down
5 changes: 5 additions & 0 deletions test/aibs_informatics_aws_utils/data_sync/test_file_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
S3FileSystem,
)
from aibs_informatics_aws_utils.efs import MountPointConfiguration
from aibs_informatics_aws_utils.efs.mount_point import detect_mount_points


def any_s3_uri(bucket: str = "bucket", key: str = "key") -> S3URI:
Expand Down Expand Up @@ -282,6 +283,10 @@ def assertLocalFileSystem_partition(

@mock_sts
class EFSFileSystemTests(EFSTestsBase):
def setUp(self) -> None:
super().setUp()
detect_mount_points.cache_clear()

def setUpEFSFileSystem(
self, name: str, access_point_path: Optional[Union[str, Path]] = None
) -> Tuple[Path, EFSPath]:
Expand Down
4 changes: 4 additions & 0 deletions test/aibs_informatics_aws_utils/efs/test_mount_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@

@mock_sts
class MountPointConfigurationTests(EFSTestsBase):
def setUp(self) -> None:
super().setUp()
detect_mount_points.cache_clear()

def setUpEFS(self, *access_points: Tuple[str, Path], file_system_name: Optional[str] = None):
self.create_file_system(file_system_name)
for access_point_name, access_point_path in access_points:
Expand Down

0 comments on commit ef3f552

Please sign in to comment.