Skip to content

Commit

Permalink
adjust to code review
Browse files Browse the repository at this point in the history
  • Loading branch information
jgriesfeller committed Oct 9, 2024
1 parent adc0af3 commit 2663ca2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 16 deletions.
7 changes: 4 additions & 3 deletions pyaerocom/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
7 changes: 0 additions & 7 deletions pyaerocom/data/paths.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 3 additions & 6 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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()
Expand Down Expand Up @@ -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"

Expand Down

0 comments on commit 2663ca2

Please sign in to comment.