Skip to content

Commit

Permalink
work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
bouweandela committed Jul 8, 2022
1 parent 8e5130c commit eddd511
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 17 deletions.
10 changes: 1 addition & 9 deletions esmvalcore/cmor/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,14 @@ def get_var_info(project, mip, short_name):
return CMOR_TABLES[project].get_variable(mip, short_name)


def read_cmor_tables(cfg_developer=None):
def read_cmor_tables(cfg_developer):
"""Read cmor tables required in the configuration.
Parameters
----------
cfg_developer : dict of str
Parsed config-developer file
"""
if cfg_developer is None:
cfg_file = Path(__file__).parents[1] / 'config-developer.yml'
with cfg_file.open() as file:
cfg_developer = yaml.safe_load(file)

cwd = os.path.dirname(os.path.realpath(__file__))
var_alt_names_file = os.path.join(cwd, 'variable_alt_names.yml')
with open(var_alt_names_file, 'r') as yfile:
Expand Down Expand Up @@ -955,6 +950,3 @@ def _read_table_file(self, table_file, table=None):
continue
if not self._read_line():
return


read_cmor_tables()
8 changes: 1 addition & 7 deletions esmvalcore/experimental/config/_config_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import yaml

import esmvalcore
from esmvalcore._config import load_config_developer
from esmvalcore.cmor.check import CheckLevels

from ._config_validators import _validators
Expand Down Expand Up @@ -55,8 +54,6 @@ def _load_user_config(cls,
try:
mapping = _read_config_file(filename)
mapping['config_file'] = filename
if mapping.get('config_developer_file'):
load_config_developer(mapping['config_developer_file'])
except IOError:
if raise_exception:
raise
Expand All @@ -81,11 +78,8 @@ def _load_default_config(cls, filename: Union[os.PathLike, str]):
mapping['max_datasets'] = None
mapping['max_years'] = None
mapping['run_diagnostic'] = True
mapping[
'config_developer_file'] = DEFAULT_CONFIG_DIR / 'config-developer.yml'
new.update(mapping)

load_config_developer(mapping['config_developer_file'])
new.update(mapping)

return new

Expand Down
4 changes: 3 additions & 1 deletion esmvalcore/experimental/config/_config_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,12 @@ def validate_oldstyle_drs(value):
return mapping


@lru_cache
def validate_config_developer(value):
"""Validate and load config developer path."""
path = validate_path_or_none(value)

if path is None:
path = Path(__file__).parent.parent / 'config-developer.yml'
load_config_developer(path)

return path
Expand Down

0 comments on commit eddd511

Please sign in to comment.