Skip to content

Commit

Permalink
Getting the fully-qualified url of the resource.
Browse files Browse the repository at this point in the history
  • Loading branch information
phargogh committed Jan 14, 2025
1 parent d1edd1b commit c59624e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/ckanext-natcap/ckanext/natcap/update_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
'https://titiler-897938321824.us-west1.run.app')


def get_dataset_metadata(resources: list[dict]) -> dict:
def get_dataset_metadata(user: str, resources: list[dict]) -> dict:
"""
Load the dataset metadata from the dataset's resources.
"""
Expand All @@ -23,6 +23,10 @@ def get_dataset_metadata(resources: list[dict]) -> dict:

for resource in resources:
if resource['description'] == 'Geometamaker YML':
# get the resource from the API to make sure the resource download
# URL is fully-qualified.
resource = toolkit.get_action('resource_show')(
{'user': user}, {'id': resource['id']})
with urllib.request.urlopen(resource['url']) as response:
text = response.read()
return yaml.safe_load(text)
Expand Down Expand Up @@ -361,7 +365,7 @@ def update_dataset(user, dataset, resources):
LOGGER.info(f"Skipping update of dataset {dataset['id']}, was updated recently")
return

metadata = get_dataset_metadata(resources)
metadata = get_dataset_metadata(user, resources)

if not metadata:
LOGGER.info(f"Skipping update of dataset {dataset['id']}, no metadata found")
Expand Down

0 comments on commit c59624e

Please sign in to comment.