Skip to content

Commit

Permalink
Added missing tag variable
Browse files Browse the repository at this point in the history
  • Loading branch information
joshua-hampton committed Nov 19, 2024
1 parent 20e623c commit 0b7fdec
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/ncas_amof_netcdf_template/remove_empty_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
import requests
import numpy as np
from typing import Union, Optional
from . import values


def get_product_variables_metadata(
product: str, skip_check: bool = False
product: str, skip_check: bool = False, tag: str = "latest"
) -> tuple[list[str], dict[str, dict[str, Union[str, float]]]]:
"""
Get variables and their metadata associated with a product.
Expand All @@ -24,28 +25,32 @@ def get_product_variables_metadata(
instrument for the netCDF file.
skip_check (bool): Skips checking if product in the
product json file. Default False.
tag (str): Tagged release version of AMF_CVs to check
Returns:
list: All product-specific variables.
dict: Dictionary of variables and their attributes.
"""
if tag == "latest":
tag = values.get_latest_CVs_version()

Check warning on line 36 in src/ncas_amof_netcdf_template/remove_empty_variables.py

View check run for this annotation

Codecov / codecov/patch

src/ncas_amof_netcdf_template/remove_empty_variables.py#L36

Added line #L36 was not covered by tests

if not skip_check:
product_list = get_json_from_github(
"https://raw.githubusercontent.com/ncasuk/AMF_CVs/main/AMF_CVs/AMF_product.json"
f"https://raw.githubusercontent.com/ncasuk/AMF_CVs/{tag}/AMF_CVs/AMF_product.json"
)["product"]

# Check for valid product
if product not in product_list:
msg = (
f"product {product} is not in "
"https://github.com/ncasuk/AMF_CVs/blob/main/AMF_CVs/AMF_product.json"
f"https://github.com/ncasuk/AMF_CVs/blob/{tag}/AMF_CVs/AMF_product.json"
)
raise ValueError(msg)

# Get the stuff
var_dict = get_json_from_github(
f"https://raw.githubusercontent.com/ncasuk/AMF_CVs/main/AMF_CVs/AMF_product_{product}_variable.json"
f"https://raw.githubusercontent.com/ncasuk/AMF_CVs/{tag}/AMF_CVs/AMF_product_{product}_variable.json"
)[f"product_{product}_variable"]
variables = list(var_dict.keys())

Expand Down

0 comments on commit 0b7fdec

Please sign in to comment.