Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions .github/workflows/syntax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Python Setup
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.10'
architecture: x64
- name: Checkout Source
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install flake8
run: pip install flake8
- name: Syntax Error Check
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tagpr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
tagpr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: Songmu/tagpr@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ jobs:
pyTestCov:
strategy:
matrix:
python-version: [3.8, 3.9, "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
runs-on: ubuntu-latest
steps:
- name: Python Setup
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Checkout Source
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install Dependencies
run: |
pip install --upgrade pip
Expand All @@ -32,7 +32,7 @@ jobs:
git clone https://github.com/metno/mmd $MMD_PATH
python -m pytest -v --cov=py_mmd_tools --cov=script --timeout=120
- name: Upload to Codecov
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
flags: unittests # optional
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,5 @@ dmypy.json

# Custom
/*.nc
issue358.md
summary.md
1 change: 1 addition & 0 deletions py_mmd_tools/mmd_elements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ storage_information:
file_size:
checksum:
storage_expiry_date:
responsible_unit:

related_information:
maxOccurs: unbounded
Expand Down
5 changes: 3 additions & 2 deletions py_mmd_tools/mmd_to_nc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import netCDF4 as nc
import lxml.etree as ET
import py_mmd_tools
from pkg_resources import resource_string
from importlib.resources import files


class Mmd_to_nc(object):
Expand All @@ -40,7 +40,8 @@ def __init__(self, mmd_product, nc_file):
self.namespaces.update({'xml': 'http://www.w3.org/XML/1998/namespace'})
# Translation file between MMD and ACDD
self.mmd_yaml = yaml.load(
resource_string(py_mmd_tools.__name__, 'mmd_elements.yaml'), Loader=yaml.FullLoader
files(py_mmd_tools.__name__).joinpath('mmd_elements.yaml').read_bytes(),
Loader=yaml.FullLoader
)
# Dictionary that will contain all ACDD attributes
self.acdd_metadata = None
Expand Down
4 changes: 2 additions & 2 deletions py_mmd_tools/nc_to_mmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

from filehash import FileHash
from itertools import zip_longest
from pkg_resources import resource_string
from importlib.resources import files
from dateutil.parser import isoparse
from uuid import UUID

Expand Down Expand Up @@ -1709,7 +1709,7 @@ def to_mmd(
# Get list of MMD elements
if mmd_yaml is None:
mmd_yaml = yaml.load(
resource_string(self.__module__.split(".")[0], "mmd_elements.yaml"),
files(self.__module__.split(".")[0]).joinpath("mmd_elements.yaml").read_bytes(),
Loader=yaml.FullLoader,
)

Expand Down
4 changes: 2 additions & 2 deletions py_mmd_tools/script/nc2mmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import yaml
import warnings

from pkg_resources import resource_string
from importlib.resources import files

from py_mmd_tools import nc_to_mmd

Expand Down Expand Up @@ -145,7 +145,7 @@ def main(args=None):
if args.file_location is not None:
overrides = {"file_location": args.file_location}
mmd_yaml = yaml.load(
resource_string(md.__module__.split(".")[0], "mmd_elements.yaml"),
files(md.__module__.split(".")[0]).joinpath("mmd_elements.yaml").read_bytes(),
Loader=yaml.FullLoader
)
metadata_id = md.get_metadata_identifier(mmd_yaml["metadata_identifier"],
Expand Down
12 changes: 5 additions & 7 deletions py_mmd_tools/yaml_to_adoc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import yaml
import jinja2

from pkg_resources import resource_string
from importlib.resources import files


def repetition_allowed(field):
Expand Down Expand Up @@ -130,15 +130,13 @@ def nc_attrs_from_yaml():
defined as ACDD extensions.
"""
mmd_yaml = yaml.load(
resource_string(
globals()['__name__'].split('.')[0], 'mmd_elements.yaml'
), Loader=yaml.FullLoader
files(globals()['__name__'].split('.')[0]).joinpath('mmd_elements.yaml').read_bytes(),
Loader=yaml.FullLoader
)

cf_yaml = yaml.load(
resource_string(
globals()['__name__'].split('.')[0], 'cf_elements.yaml'
), Loader=yaml.FullLoader
files(globals()['__name__'].split('.')[0]).joinpath('cf_elements.yaml').read_bytes(),
Loader=yaml.FullLoader
)

attributes = {}
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ classifiers = [
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Atmospheric Science",
Expand All @@ -26,7 +26,7 @@ dependencies = [
"filehash",
"jinja2",
"lxml>=4.5",
"netCDF4 ~= 1.5",
"netCDF4 >=1.5",
"pandas",
"parmap",
"pytest",
Expand All @@ -42,7 +42,7 @@ dependencies = [
name = "py-mmd-tools"
description = "This is a tools for generating MMD files from netCDF-CF files with ACDD attributes, for documenting netCDF-CF files from MMD information."
readme = "README.md"
requires-python = ">=3.8"
requires-python = ">=3.9"

[project.scripts]
nc2mmd = "py_mmd_tools.script.nc2mmd:_main"
Expand Down
5 changes: 3 additions & 2 deletions tests/test_mmd_yaml_vs_xsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import unittest
import py_mmd_tools

from pkg_resources import resource_string
from importlib.resources import files


class TestMDDElementsInYAMLAndXSD(unittest.TestCase):
Expand All @@ -25,7 +25,8 @@ def setUp(self):
with open(xml_file) as xml:
self.mmd_xml = xmltodict.parse(xml.read())
self.mmd_yaml = yaml.load(
resource_string(py_mmd_tools.__name__, 'mmd_elements.yaml'), Loader=yaml.FullLoader
files(py_mmd_tools.__name__).joinpath('mmd_elements.yaml').read_bytes(),
Loader=yaml.FullLoader
)

def check_elements(self, elements, type_defs=None):
Expand Down
Loading
Loading