From ef3f5527a224932632080a84d33e38dd3714050b Mon Sep 17 00:00:00 2001 From: Ryan McGinty Date: Tue, 25 Jun 2024 23:42:33 -0700 Subject: [PATCH] add cache to detect_mount_points --- pyproject.toml | 2 +- src/aibs_informatics_aws_utils/efs/mount_point.py | 2 ++ .../aibs_informatics_aws_utils/data_sync/test_file_system.py | 5 +++++ test/aibs_informatics_aws_utils/efs/test_mount_point.py | 4 ++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 9ab1efd..92c6596 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ requires-python = ">=3.9" dependencies = [ "boto3~=1.26.49", - "aibs-informatics-core @ git+ssh://git@github.com/AllenInstitute/aibs-informatics-core.git@feature/update-batch-data-sync-models", + "aibs-informatics-core @ git+ssh://git@github.com/AllenInstitute/aibs-informatics-core.git@main", ] [project.optional-dependencies] diff --git a/src/aibs_informatics_aws_utils/efs/mount_point.py b/src/aibs_informatics_aws_utils/efs/mount_point.py index dd98eb1..7651d8c 100644 --- a/src/aibs_informatics_aws_utils/efs/mount_point.py +++ b/src/aibs_informatics_aws_utils/efs/mount_point.py @@ -1,6 +1,7 @@ from __future__ import annotations import re +from functools import cache __all__ = [ "MountPointConfiguration", @@ -375,6 +376,7 @@ def __repr__(self) -> str: ) +@cache def detect_mount_points() -> List[MountPointConfiguration]: mount_points: List[MountPointConfiguration] = [] diff --git a/test/aibs_informatics_aws_utils/data_sync/test_file_system.py b/test/aibs_informatics_aws_utils/data_sync/test_file_system.py index b532d8c..45f950b 100644 --- a/test/aibs_informatics_aws_utils/data_sync/test_file_system.py +++ b/test/aibs_informatics_aws_utils/data_sync/test_file_system.py @@ -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: @@ -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]: diff --git a/test/aibs_informatics_aws_utils/efs/test_mount_point.py b/test/aibs_informatics_aws_utils/efs/test_mount_point.py index f431bb3..f049da8 100644 --- a/test/aibs_informatics_aws_utils/efs/test_mount_point.py +++ b/test/aibs_informatics_aws_utils/efs/test_mount_point.py @@ -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: