From 708cc4190f53a792bb53c2f18a46dad394942842 Mon Sep 17 00:00:00 2001 From: Timothy Willard Date: Fri, 21 Jun 2024 16:26:34 -0400 Subject: [PATCH 1/5] Added missing boto3 dependency for gempyor, GH-238 --- flepimop/gempyor_pkg/setup.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/flepimop/gempyor_pkg/setup.cfg b/flepimop/gempyor_pkg/setup.cfg index f63f130da..f93c20221 100644 --- a/flepimop/gempyor_pkg/setup.cfg +++ b/flepimop/gempyor_pkg/setup.cfg @@ -35,6 +35,7 @@ install_requires = dask scipy graphviz + boto3 # see https://stackoverflow.com/questions/58826164/dependencies-requirements-for-setting-up-testing-and-installing-a-python-lib # installed for pip install -e ".[test]" From 0b32f2e2bd32a33b85a6751278fbbabed08de835 Mon Sep 17 00:00:00 2001 From: Timothy Willard Date: Fri, 21 Jun 2024 16:33:36 -0400 Subject: [PATCH 2/5] Moved .Rproj.user gitignore to the right place, added venv & .venv for isolated installs of gempyor. --- .gitignore | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index db7e7fcf9..9cc3a7c09 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/ From 7a832793cd8c76d9b38c634fec0579ddcdd700bc Mon Sep 17 00:00:00 2001 From: Timothy Willard Date: Tue, 25 Jun 2024 15:57:10 -0400 Subject: [PATCH 3/5] Made boto3/botocore optional installs and moved boto3/botocore imports into gempyor.utils.download_file_from_s3, GH-238 --- flepimop/gempyor_pkg/setup.cfg | 5 +++-- flepimop/gempyor_pkg/src/gempyor/utils.py | 11 ++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/flepimop/gempyor_pkg/setup.cfg b/flepimop/gempyor_pkg/setup.cfg index f93c20221..e5fb0902a 100644 --- a/flepimop/gempyor_pkg/setup.cfg +++ b/flepimop/gempyor_pkg/setup.cfg @@ -35,7 +35,6 @@ install_requires = dask scipy graphviz - boto3 # see https://stackoverflow.com/questions/58826164/dependencies-requirements-for-setting-up-testing-and-installing-a-python-lib # installed for pip install -e ".[test]" @@ -43,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 4d3209061..6c3b45d5a 100644 --- a/flepimop/gempyor_pkg/src/gempyor/utils.py +++ b/flepimop/gempyor_pkg/src/gempyor/utils.py @@ -12,10 +12,8 @@ import subprocess import shutil import logging -import boto3 from gempyor import file_paths from typing import List, Dict -from botocore.exceptions import ClientError logger = logging.getLogger(__name__) @@ -509,12 +507,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: + 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://"): From bed8d8b537c1cd722a4551262eb4766001df497b Mon Sep 17 00:00:00 2001 From: Timothy Willard Date: Thu, 27 Jun 2024 12:52:32 -0400 Subject: [PATCH 4/5] Change except to only catch ModuleNotFoundError, let other errors raise. --- flepimop/gempyor_pkg/src/gempyor/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flepimop/gempyor_pkg/src/gempyor/utils.py b/flepimop/gempyor_pkg/src/gempyor/utils.py index 6c3b45d5a..eb2f00da4 100644 --- a/flepimop/gempyor_pkg/src/gempyor/utils.py +++ b/flepimop/gempyor_pkg/src/gempyor/utils.py @@ -510,7 +510,7 @@ def download_file_from_s3(name_map: Dict[str, str]) -> None: try: import boto3 from botocore.exceptions import ClientError - except: + except ModuleNotFoundError: raise ModuleNotFoundError(( "No module named 'boto3', which is required for " "gempyor.utils.download_file_from_s3. Please install the aws target." From 58c312c2b12425c953dd7c311db73faf67a5d1aa Mon Sep 17 00:00:00 2001 From: Timothy Willard Date: Wed, 10 Jul 2024 15:17:48 -0400 Subject: [PATCH 5/5] Add `.env` to `.gitignore` Add dotenv file to gitignore since flepiMoP depends on having FLEPI_PATH and PROJECT_PATH env vars set. --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 9cc3a7c09..b1caaf8a8 100644 --- a/.gitignore +++ b/.gitignore @@ -75,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