From 2663ca23e257bba8b524efb11a8075e4d3d6a17f Mon Sep 17 00:00:00 2001 From: Jan Griesfeller Date: Wed, 9 Oct 2024 10:46:44 +0200 Subject: [PATCH] adjust to code review --- pyaerocom/config.py | 7 ++++--- pyaerocom/data/paths.ini | 7 ------- tests/test_config.py | 9 +++------ 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/pyaerocom/config.py b/pyaerocom/config.py index df2b38247..5c4a901d1 100644 --- a/pyaerocom/config.py +++ b/pyaerocom/config.py @@ -216,7 +216,7 @@ def __init__(self, config_file=None, try_infer_environment=True): self._user = getpass.getuser() self.my_pyaerocom_dir = os.path.join(f"{os.path.expanduser('~')}", self._outhomename) - self.DONOTCACHEFILE = None + self.DO_NOT_CACHE_FILE = None self.ERA5_SURFTEMP_FILENAME = "era5.msl.t2m.201001-201012.nc" @@ -234,7 +234,7 @@ def __init__(self, config_file=None, try_infer_environment=True): basedir, config_file = os.path.split(config_file) elif try_infer_environment: try: - config_file = self.infer_basedir_and_config() + config_file = self.infer_config() except FileNotFoundError: pass @@ -290,7 +290,7 @@ def _infer_config_from_basedir(self, basedir): f"Could not infer environment configuration for input directory: {basedir}" ) - def infer_basedir_and_config(self): + def infer_config(self): """ check if ~/MyPyaerocom/paths.ini exists. if not, use the default paths.ini @@ -302,6 +302,7 @@ def infer_basedir_and_config(self): else: with resources.path("pyaerocom.data", self.PATHS_INI_NAME) as path: self._paths_ini = str(path) + logger.info(f"using default config file: {self._paths_ini}") return self._paths_ini diff --git a/pyaerocom/data/paths.ini b/pyaerocom/data/paths.ini index 40ad6c97d..a5a42cb9d 100644 --- a/pyaerocom/data/paths.ini +++ b/pyaerocom/data/paths.ini @@ -144,13 +144,6 @@ ObsOnlyModelname = OBSERVATIONS-ONLY #because it would be too time consuming determining the start year of #each observations network, it is noted here All=2000 -#Aeronet V2 -;AERONET_SUN_V2L15_AOD_DAILY = 2000 -;AERONET_SUN_V2L15_AOD_ALL_POINTS = 2011 -;AERONET_SUN_V2L2_AOD_DAILY = 1992 -;AERONET_SUN_V2L2_AOD_ALL_POINTS = 1992 -;AERONET_SUN_V2L2_SDA_DAILY = 1992 -;AERONET_SUN_V2L2_SDA_ALL_POINTS = 1992 #Aeronet V3 AERONET_SUN_V3L15_AOD_DAILY = 1992 AERONET_SUN_V3L15_AOD_ALL_POINTS = 1992 diff --git a/tests/test_config.py b/tests/test_config.py index b2a5e170d..0443c165c 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -116,11 +116,9 @@ def test_user_specific_paths_ini(): outfile.write(line) del_flag = True - # read default paths.ini - # compare assert os.path.exists(user_file) - # no real test here for now since we would need to get rif of the already loaded const module - # and recreate that + # no real test here for now since we would need to get rid of the already loaded const module + # and recreate that The following does not work due to caching # cfg = testmod.Config(try_infer_environment=False) # assert cfg.GAWTADSUBSETAASETAL == CHANGE_NAME @@ -135,7 +133,6 @@ def test_Config_read_config(): cfg.read_config(cfg_file) # not all paths from the default paths.ini are present on CI # Just test a few of them - # assert cfg.OBSLOCS_UNGRIDDED assert Path(cfg.OUTPUTDIR).exists() assert Path(cfg.COLOCATEDDATADIR).exists() assert Path(cfg.CACHEDIR).exists() @@ -237,7 +234,7 @@ def test_empty_class_header(empty_cfg): with resources.path("pyaerocom.data", "coords.ini") as path: assert cfg._coords_info_file == str(path) - assert cfg.DONOTCACHEFILE is None + assert cfg.DO_NOT_CACHE_FILE is None assert cfg.ERA5_SURFTEMP_FILENAME == "era5.msl.t2m.201001-201012.nc"