Commit 58437187 authored by Javier Vegas-Regidor's avatar Javier Vegas-Regidor
Browse files

Support latest as version option

parent c48c7b11
......@@ -853,6 +853,7 @@ class Cmor3Convention(DataConvention):
def get_cmor_folder_path(
self, startdate, member, domain, var, frequency, grid, cmor_var
):
if not self.config.cmor.version:
raise ValueError(
"CMOR version is mandatory for PRIMAVERA and CMIP6"
......@@ -882,6 +883,12 @@ class Cmor3Convention(DataConvention):
grid,
self.config.cmor.version,
)
if self.config.cmor.version == "latest":
versions = os.listdir(os.path.dirname(folder_path))
versions.sort(reverse=True)
self.config.cmor.version = versions[0]
fodler_path = folder_path.replace('/latest/', f'/{versions[0]}/')
return folder_path
def _link_startdate(self, path, member_str):
......
......@@ -368,7 +368,7 @@ class TestPrefaceConvention(TestCase):
@mock.patch("os.path.isfile")
def test_is_cmorized_not_enough_vars(self, mock_is_file):
mock_is_file.return_value = True
mock_is_file.return_value = False
cmor_var = Mock()
omon = Mock()
omon.name = "Omon"
......
......@@ -487,7 +487,7 @@ class TestSpecsConvention(TestCase):
@mock.patch("os.path.isfile")
def test_is_cmorized_not_enough_vars(self, mock_is_file):
mock_is_file.return_value = True
mock_is_file.return_value = False
cmor_var = Mock()
omon = Mock()
omon.name = "Omon"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment