diff --git a/pyproject.toml b/pyproject.toml index 25d196d..0b83851 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,6 +22,7 @@ dependencies = [ "jsonschema", "pooch", "xarray", + "access-ipy-telemetry>=0.1.0", ] dynamic = ["version"] diff --git a/src/access_nri_intake/data/__init__.py b/src/access_nri_intake/data/__init__.py index ef44eb0..dcaf33d 100644 --- a/src/access_nri_intake/data/__init__.py +++ b/src/access_nri_intake/data/__init__.py @@ -5,15 +5,25 @@ import intake import intake.catalog +from access_ipy_telemetry.cli import configure_telemetry +from access_ipy_telemetry.utils import ApiHandler from access_nri_intake.utils import get_catalog_fp +api_handler = ApiHandler() + CATALOG_NAME_FORMAT = ( r"^v(?P2[0-9]{3})\-(?P1[0-2]|0[1-9])\-(?P0[1-9]|[1-2][0-9]|3[0-1])$" ) + try: data = intake.open_catalog(get_catalog_fp()).access_nri + cat_version = data._captured_init_kwargs.get("metadata", {}).get( + "version", "latest" + ) # Get the catalog version number and set it to "latest" if it can't be found + configure_telemetry(["--enable", "--silent"]) + api_handler.add_extra_field("catalog", {"catalog_version": cat_version}) except FileNotFoundError: warnings.warn( "Unable to access a default catalog location. Calling intake.cat.access_nri will not work.",