Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions docs/tools/catalog.rst
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
.. NEEDS UPDATING #TODO

For more complete information on the ``catalogbuilder`` tool, please see its offical `documentation <https://noaa-gfdl.github.io/CatalogBuilder/>`_.
For more complete information on the ``catalogbuilder`` tool, please see its official `documentation <https://noaa-gfdl.github.io/CatalogBuilder/>`_.

``builder``
``build``
-----------

Generate a catalog.

* Builds json and csv format catalogs from user input directory path
* Minimal Syntax: ``fre catalog builder -i [input path] -o [output path]``
* Minimal Syntax: ``fre catalog build -i [input path] -o [output path]``
* Module(s) needed: n/a
* Example: ``fre catalog builder -i /archive/am5/am5/am5f3b1r0/c96L65_am5f3b1r0_pdclim1850F/gfdl.ncrc5-deploy-prod-openmp/pp -o ~/output --overwrite``
* Example: ``fre catalog build -i /archive/am5/am5/am5f3b1r0/c96L65_am5f3b1r0_pdclim1850F/gfdl.ncrc5-deploy-prod-openmp/pp -o ~/output --overwrite``


``validate``
------------

Validate the catalog.
Validate a catalog

* Runs the comprehensive validator tool (validates vocabulary and ensures catalogs were generated properly)
* Minimal Syntax: ``fre catalog validate [json_path] --vocab OR
fre catalog validate [json_path] --proper_generation``
* Module(s) needed: n/a
* Example: ``fre catalog validate ~/example_catalog.json --vocab``

19 changes: 12 additions & 7 deletions fre/catalog/frecatalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

import click

#import catalogbuilder
from catalogbuilder.scripts import gen_intake_gfdl
from catalogbuilder.scripts import test_catalog
from catalogbuilder.tests import compval
from catalogbuilder.scripts import combine_cats


Expand All @@ -32,23 +31,29 @@ def catalog_cli():
@click.option('--append', is_flag = True, default = False)
@click.option('--slow', is_flag = True, default = False,
help = "Open NetCDF files to retrieve additional vocabulary (standard_name and intrafile static variables")
@click.option('--strict', is_flag = True, default = False,
help = "Ensure output catalog is strictly compliant with schema")
@click.pass_context
def builder(context, input_path = None, output_path = None, config = None, filter_realm = None,
filter_freq = None, filter_chunk = None, verbose = False, overwrite = False, append = False, slow = False):
def build(context, input_path = None, output_path = None, config = None, filter_realm = None,
filter_freq = None, filter_chunk = None, verbose = False, overwrite = False, append = False, slow = False, strict = False):
# pylint: disable=unused-argument
""" - Generate .csv and .json files for catalog """
context.forward(gen_intake_gfdl.create_catalog_cli)

@catalog_cli.command()
@click.argument('json_path', nargs = 1 , required = True)
@click.argument('json_template_path', nargs = 1 , required = False)
@click.option('--vocab', is_flag=True, default = False,
help="Validates catalog vocabulary")
@click.option('-pg','--proper_generation', is_flag=True, default = False,
help="Ensures that catalog has been 'properly generated' (No empty columns, reflects template)")
@click.option('-tf', '--test-failure', is_flag=True, default = False,
help="Errors are only printed. Program will not exit.")
@click.pass_context
def validate(context, json_path, json_template_path, test_failure):
def validate(context, json_path, json_template_path, vocab, proper_generation, test_failure):
# pylint: disable=unused-argument
""" - Validate a catalog against catalog schema """
context.forward(test_catalog.main)
""" - Validate catalogs against controlled vocabulary (CV) as provided by particular JSON schemas per vocabulary type OR Validate a catalog against catalog schema template """
context.forward(compval.main)

@catalog_cli.command()
@click.option('--input', required = True, multiple = True,
Expand Down
2 changes: 1 addition & 1 deletion fre/catalog/tests/test_fre_catalog.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

'''This test ensures that the catalog builder module can be imported'''
def test_fre_catalog_import():
from fre import catalog
assert catalog is not None
Loading