-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathfrecatalog.py
More file actions
67 lines (58 loc) · 3.36 KB
/
Copy pathfrecatalog.py
File metadata and controls
67 lines (58 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
"""This module defines the ``fre catalog`` CLI commands."""
import click
from catalogbuilder.scripts import gen_intake_gfdl
from catalogbuilder.scripts import compval
from catalogbuilder.scripts import combine_cats
@click.group(help=click.style(" - catalog subcommands", fg=(64,94,213)))
def catalog_cli():
"""This command group exposes the ``fre catalog`` subcommands."""
@catalog_cli.command()
#TODO arguments dont have help message. So consider changing arguments to options?
@click.argument('input_path', required = False, nargs = 1)
#, help = 'The directory path with the datasets to be cataloged. E.g a GFDL PP path till /pp')
@click.argument('output_path', required = False, nargs = 1)
#, help = 'Specify output filename suffix only. e.g. catalog')
@click.option('--config', required = False, type = click.Path(exists = True), nargs = 1,
help = 'Path to your yaml config, Use the config_template in intakebuilder repo')
@click.option('--filter_realm', nargs = 1)
@click.option('--filter_freq', nargs = 1)
@click.option('--filter_chunk', nargs = 1)
@click.option('--verbose', is_flag = True, default = False)
@click.option('--overwrite', is_flag = True, default = False)
@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 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
"""Build catalog CSV and JSON files from the provided input data."""
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, vocab, proper_generation, test_failure):
# pylint: disable=unused-argument
""" - Validate catalogs against controlled vocabulary as provided by particular JSON schemas
per vocabulary type (vocabulary validation) OR Validate a catalog against catalog schema
template (proper generation checking) """
context.forward(compval.main)
@catalog_cli.command()
@click.option('--input', required = True, multiple = True,
help = 'Catalog json files to be merged, space-separated')
@click.option('--output', required = True, nargs = 1,
help = 'Merged catalog')
@click.pass_context
def merge(context, input, output):
"""Merge two or more catalogs into one catalog file."""
context.invoke(combine_cats.combine_cats, inputfiles=input, output_path=output)