ncasuk / amf-check-writer

Library to write AMF compliance checks
BSD 3-Clause "New" or "Revised" License
0 stars 4 forks source link

Rule for "Exact match in vocabulary" - develop and test #40

Closed gapintheclouds closed 3 years ago

gapintheclouds commented 3 years ago

A new compliance checking rule for global attributes called "Exact match in vocabulary" needs to check whether the corresponding issue exists in the corresponding volcabulary.

Eg. In the 'global_attributes' sheet in the file '_common.xlsx', the check called 'source' needs an "Exact match in vocabulary" from the list contained in the 'Descriptor' column of the 'ncas_instrument_name_and_descriptors' (or in this case possibly also 'community-instrument-name-and-descriptors') sheet in the file '_vocabularies.xlsx'.

The file I've been testing with is the training file 'ncas-anemometer-1_ral_29001225_mean-winds_v0.1.nc'. For this file the source global attribute needs to equal "NCAS Mechanicle Anemometer unit 1" as given in cell L37.

gapintheclouds commented 3 years ago

We need to write a new check type for global attributes, but I'm not entirely sure what the check needs to contain.

agstephens commented 3 years ago

Thanks @gapintheclouds 👍

gapintheclouds commented 3 years ago

Some progress: I need to create a new global attribute check using GlobalAttrVocabCheck from https://github.com/cedadev/compliance-check-lib/blob/186817ea2cda3cc4cd711da9e43b5e5fa2b8e26a/checklib/register/nc_file_checks_register.py#L57.

I've tried making a yaml check:

- check_id: hugo_test
  check_name: checklib.register.nc_file_checks_register.GlobalAttrVocabCheck
  parameters:
    vocab_lookup: ncas-instrument
    attribute: source
    vocabulary_ref: ncas:amf

but get the following error message:

product_aerosol-backscatter_land_checks:2.0.check_hugo_test: 'NoneType' object is not iterable

Probably something simple. @agstephens, any ideas?

agstephens commented 3 years ago

@gapintheclouds: I wonder if the error is because it can't find a value in the current version of the controlled vocabularies that you are using. It depends which directory your code is looking in for the vocabs, but on my system I'd be searching in:

.../compliance-check-lib/cc-vocab-cache/pyessv-archive-eg-cvs/ncas/amf/ncas-instrument/
agstephens commented 3 years ago

@gapintheclouds: when you have completed your latest changes and made a pull request, you can report on it here and we can close this issue.

gapintheclouds commented 3 years ago

Done