From 9ff0feb24ba0af3f01eae5724f13cfeb7e2ba165 Mon Sep 17 00:00:00 2001 From: Javier Vegas-Regidor Date: Fri, 24 Apr 2020 10:38:26 +0200 Subject: [PATCH 1/2] FIx tests --- test/unit/data_convention/test_preface.py | 2 +- test/unit/data_convention/test_specs.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit/data_convention/test_preface.py b/test/unit/data_convention/test_preface.py index 509222cc..1f549da9 100644 --- a/test/unit/data_convention/test_preface.py +++ b/test/unit/data_convention/test_preface.py @@ -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" diff --git a/test/unit/data_convention/test_specs.py b/test/unit/data_convention/test_specs.py index cebbc6bb..a0da6224 100644 --- a/test/unit/data_convention/test_specs.py +++ b/test/unit/data_convention/test_specs.py @@ -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" -- GitLab From 41c9f6c60d02a082844f845cac52e04a17a7bc81 Mon Sep 17 00:00:00 2001 From: Javier Vegas-Regidor Date: Fri, 24 Apr 2020 15:46:59 +0200 Subject: [PATCH 2/2] Support latest version --- earthdiagnostics/data_convention.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/earthdiagnostics/data_convention.py b/earthdiagnostics/data_convention.py index d21a2956..0ac704f0 100644 --- a/earthdiagnostics/data_convention.py +++ b/earthdiagnostics/data_convention.py @@ -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): -- GitLab