diff --git a/.gitignore b/.gitignore index db7e7fcf9..b1caaf8a8 100644 --- a/.gitignore +++ b/.gitignore @@ -36,7 +36,7 @@ model_output/ /*.Rcheck/ # RStudio files -.Rproj.user/ +.Rproj.user flepiMoP.Rproj *.Rproj @@ -64,7 +64,8 @@ packrat/lib*/ dist/ SEIR.egg-info/ Outcomes.egg-info/ -.Rproj.user +venv/ +.venv/ # R package manuals man/ @@ -74,3 +75,6 @@ flepimop/gempyor_pkg/get_value.prof flepimop/gempyor_pkg/tests/seir/.coverage flepimop/gempyor_pkg/tests/seir/.coverage.kojis-mbp-8.sph.ad.jhsph.edu.90615.974746 flepimop/gempyor_pkg/.coverage + +# Environment variables +.env diff --git a/flepimop/gempyor_pkg/setup.cfg b/flepimop/gempyor_pkg/setup.cfg index f63f130da..e5fb0902a 100644 --- a/flepimop/gempyor_pkg/setup.cfg +++ b/flepimop/gempyor_pkg/setup.cfg @@ -42,7 +42,9 @@ install_requires = test = pytest mock - +aws = + boto3 + botocore [options.entry_points] console_scripts = diff --git a/flepimop/gempyor_pkg/src/gempyor/utils.py b/flepimop/gempyor_pkg/src/gempyor/utils.py index 85820d5b2..990acdf30 100644 --- a/flepimop/gempyor_pkg/src/gempyor/utils.py +++ b/flepimop/gempyor_pkg/src/gempyor/utils.py @@ -9,8 +9,6 @@ import time from typing import List, Dict, Literal -import boto3 -from botocore.exceptions import ClientError import confuse import numpy as np import numpy.typing as npt @@ -347,7 +345,7 @@ def as_random_distribution(self): def list_filenames( - folder: str | bytes | os.PathLike = ".", + folder: str | bytes | os.PathLike = ".", filters: str | list[str] = [], ) -> list[str]: """Return the list of all filenames and paths in the provided folder. @@ -636,12 +634,19 @@ def download_file_from_s3(name_map: Dict[str, str]) -> None: >>> download_file_from_s3(name_map) # This will raise a ValueError indicating the invalid S3 URI format. """ + try: + import boto3 + from botocore.exceptions import ClientError + except ModuleNotFoundError: + raise ModuleNotFoundError(( + "No module named 'boto3', which is required for " + "gempyor.utils.download_file_from_s3. Please install the aws target." + )) s3 = boto3.client("s3") first_output_filename = next(iter(name_map.values())) output_dir = os.path.dirname(first_output_filename) if not os.path.exists(output_dir): os.makedirs(output_dir) - for s3_uri in name_map: try: if s3_uri.startswith("s3://"):