Skip to content

Commit

Permalink
Updates where old-style data file import was located
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-white committed Aug 29, 2024
1 parent b487a34 commit 7341436
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
9 changes: 6 additions & 3 deletions src/access_nri_intake/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
""" Command line interfaces for access-nri-intake """

import argparse
import importlib
import logging
import os
import re
Expand Down Expand Up @@ -214,10 +215,12 @@ def _get_project(path):
# Save the catalog
cm.save()

_here = os.path.abspath(os.path.dirname(__file__))
if update:
# FIXME use correct package data handling
with open(os.path.join(_here, "data", "catalog.yaml"), "w") as fobj:
with (

Check warning on line 219 in src/access_nri_intake/cli.py

View check run for this annotation

Codecov / codecov/patch

src/access_nri_intake/cli.py#L219

Added line #L219 was not covered by tests
importlib.resources.files("access_nri_intake")
.joinpath("data/catalog.yaml")
.open(mode="w") as fobj
):
yaml.dump(yaml_dict, fobj)


Expand Down
9 changes: 5 additions & 4 deletions src/access_nri_intake/data/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Copyright 2023 ACCESS-NRI and contributors. See the top-level COPYRIGHT file for details.
# SPDX-License-Identifier: Apache-2.0

import os
import importlib

import intake

## FIXME use correct package data handling
_here = os.path.abspath(os.path.dirname(__file__))
data = intake.open_catalog(os.path.join(_here, "catalog.yaml")).access_nri
data = intake.open_catalog(
importlib.resources.files("access_nri_intake").joinpath("data/catalog.yaml")
# os.path.join(_here, "catalog.yaml")
).access_nri

0 comments on commit 7341436

Please sign in to comment.