0

I'm trying to build a LocalCatalogEntry for Python's Intake package (as part of a larger catalog, which might have multiple entries, one of which I'm trying to create here). However, I can't seem to figure out how to feed it user parameters to describe group variable names (from within an hdf5 file) without getting an error.

from intake.catalog.local import LocalCatalogEntry
import intake_xarray

LocalCatalogEntry(name='is2_local', 
                   description= '', 
                   driver=intake_xarray.netcdf.NetCDFSource, 
                   args= {'urlpath': '/full/path/to/data/file/ATL06-20181214041627-Sample.h5', 
                            'path_as_pattern': 'ATL{product:2}-{datetime:%Y%m%d%H%M%S}-Sample.h5', 
                            'xarray_kwargs': {'engine': 'h5netcdf', 
                                              'group': '/{{laser}}/land_ice_segments'}},
                    parameters= [{'name': 'laser',
                              'description': 'Laser Beam Number', 
                              'type': 'str', 
                              'default': 'gt1l', 
                              'allowed': ['gt1l', 'gt1r', 'gt2l', 'gt2r', 'gt3l', 'gt3r']}]
)

results in an AttributeError: 'dict' object has no attribute 'describe'. I've tried all sorts of permutations and dug through the source code/docs, and can't figure out how I'm supposed to enter this information for it to be a valid input. Am I trying to input the user parameters incorrectly?

Jessica
  • 505
  • 1
  • 3
  • 11

1 Answers1

1

You were close! When instantiating directly like this, you need to explicitly create the UserParameter, not just pass a dict:

from intake.catalog.local import LocalCatalogEntry, UserParameter
import intake_xarray

LocalCatalogEntry(
    name='is2_local',
    description= '',
    driver=intake_xarray.netcdf.NetCDFSource,
    args= {'urlpath': '/full/path/to/data/file/ATL06-20181214041627-Sample.h5',
           'path_as_pattern': 'ATL{product:2}-{datetime:%Y%m%d%H%M%S}-Sample.h5',
           'xarray_kwargs': {'engine': 'h5netcdf',
           'group': '/{{laser}}/land_ice_segments'}},
    parameters= [UserParameter(**{
        'name': 'laser',
        'description': 'Laser Beam Number',
        'type': 'str',
        'default': 'gt1l',
        'allowed': ['gt1l', 'gt1r', 'gt2l', 'gt2r', 'gt3l', 'gt3r']})]
)
mdurant
  • 27,272
  • 5
  • 45
  • 74
  • Thanks @mdurant! I appreciate your taking time to respond and put me on the right path as I get to know Intake better! – Jessica Jul 21 '21 at 16:22