Skip to content

Fix bug that made preprocessor with fx files fail in rare cases#670

Merged
mattiarighi merged 2 commits into
masterfrom
fix_448
Jun 22, 2020
Merged

Fix bug that made preprocessor with fx files fail in rare cases#670
mattiarighi merged 2 commits into
masterfrom
fix_448

Conversation

@schlunma

@schlunma schlunma commented Jun 8, 2020

Copy link
Copy Markdown
Contributor
  • Create an issue to discuss what you are going to do, if you haven't done so already (and add the link at the bottom)
  • This pull request has a descriptive title that can be used in a changelog
  • Add unit tests
  • Public functions should have a numpy-style docstring so they appear properly in the API documentation. For all other functions a one line docstring is sufficient.
  • If writing a new/modified preprocessor function, please update the documentation
  • Circle/CI tests pass. Status can be seen below your pull request. If the tests are failing, click the link to find out why.
  • Codacy code quality checks pass. Status can be seen below your pull request. If there is an error, click the link to find out why. If you suspect Codacy may be wrong, please ask by commenting.
  • Please use yamllint to check that your YAML files do not contain mistakes
  • If you make backward incompatible changes to the recipe format, make a new pull request in the ESMValTool repository and add the link below

If you need help with any of the tasks above, please do not hesitate to ask by commenting in the issue or pull request.


Closes #448.

@schlunma schlunma added the bug Something isn't working label Jun 8, 2020
@schlunma schlunma requested review from bouweandela and jvegreg June 8, 2020 10:31
@schlunma schlunma self-assigned this Jun 8, 2020
@schlunma schlunma added this to the v2.0.0 milestone Jun 8, 2020
@schlunma

schlunma commented Jun 8, 2020

Copy link
Copy Markdown
Contributor Author

Circle CI fails because the following test:

def test_get_variable_from_custom(self):
"""Get a variable from default."""
self.variables_info.strict = False
var = self.variables_info.get_variable('A1', 'swcre')
self.assertEqual(var.short_name, 'swcre')
self.assertEqual(var.frequency, '')
var = self.variables_info.get_variable('day', 'swcre')
self.assertEqual(var.short_name, 'swcre')
self.assertEqual(var.frequency, '')

This fails because var.frequency is None in the second case now instead of the expected ''. Is this behavior intended @jvegasbsc ? In this test, the custom table swcre is read, which does not specify frequency. So I guess somehow the use of day sets the frequency to None. Before this fix, the frequency was (falsely) set to '' in the call var = self.variables_info.get_variable('A1', 'swcre'), so this test didn't fail.

All other tables entries are fine though (e.g. long_name, dimensions, etc.), only the frequency part fails.

@jvegreg

jvegreg commented Jun 8, 2020

Copy link
Copy Markdown
Contributor

The frequency for custom variables was set to None at read time. I changed it to be set to the empty string so it is consistent with all the others

@schlunma

schlunma commented Jun 8, 2020

Copy link
Copy Markdown
Contributor Author

I successfully tested recipe_anav13jclim.yml with this, so this fixes ESMValGroup/ESMValTool#1548.

@bouweandela bouweandela left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattiarighi Could you please run a final test and merge?

@valeriupredoi valeriupredoi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cheers @schlunma 🍺

@mattiarighi mattiarighi merged commit c5ffda0 into master Jun 22, 2020
@mattiarighi mattiarighi deleted the fix_448 branch June 22, 2020 13:39
@bouweandela bouweandela added the preprocessor Related to the preprocessor label Jul 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working preprocessor Related to the preprocessor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using fx_files for preprocessor fails in rare cases

5 participants