Skip to content

Commit

Permalink
Merge pull request #604 from benjwadams/dealloc_ds_error_fix
Browse files Browse the repository at this point in the history
Dealloc ds error fix
  • Loading branch information
Bob Fratantonio authored Aug 28, 2018
2 parents ad354a7 + 5053bc4 commit 833de21
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions compliance_checker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
from functools32 import lru_cache

class MemoizedDataset(Dataset):
"""
A NetCDF dataset which has its get_variables_by_attributes call memoized in
order to speed up repeated calls to the function. This should only really
be used against netCDF Datasets opened in 'r' mode, as the attributes should
not change upon reading the files.
"""
@lru_cache(128)
def get_variables_by_attributes(self, **kwargs):
return super(MemoizedDataset,
Expand Down
3 changes: 3 additions & 0 deletions compliance_checker/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ def run_checker(cls, ds_loc, checker_names, verbose, criteria,

score_groups = cs.run(ds, [] if skip_checks is None else skip_checks,
*checker_names)
# TODO: consider wrapping in a proper context manager instead
if hasattr(ds, 'close'):

This comment has been minimized.

Copy link
@benjwadams

benjwadams Aug 28, 2018

Contributor

Perhaps should have checked if this was callable as well.

ds.close()

if not score_groups:
raise ValueError("No checks found, please check the name of the checker(s) and that they are installed")
Expand Down

0 comments on commit 833de21

Please sign in to comment.