Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable catalog generation for single feedstock #58

Merged
merged 2 commits into from
Oct 21, 2024
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
13 changes: 6 additions & 7 deletions .github/workflows/catalog-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ name: Catalog
on:
pull_request:
branches:
- main
push:
branches:
- main
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down Expand Up @@ -34,11 +39,5 @@ jobs:
run: |
leap-catalog --help
leap-catalog validate --single https://github.com/leap-stc/proto_feedstock/blob/main/feedstock/catalog.yaml
leap-catalog generate --path https://raw.githubusercontent.com/leap-stc/data-management/staging/catalog/input.yaml --output catalog/
leap-catalog generate --single https://github.com/carbonplan/ocean-carbon-sink-data-feedstock/blob/main/feedstock/catalog.yaml --output catalog/
cat catalog/output/consolidated-web-catalog.json | jq

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: consolidated-web-catalog.json
path: catalog/output/consolidated-web-catalog.json
12 changes: 7 additions & 5 deletions leap_data_management_utils/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def __init__(self, errors: list[dict[str, str]] | str) -> None:
super().__init__(self.errors)


def collect_feedstocks(path: upath.UPath) -> list[upath.UPath]:
def collect_feedstocks(path: upath.UPath) -> list[str]:
"""Collects all the datasets in the given directory."""

url = convert_to_raw_github_url(path)
Expand Down Expand Up @@ -229,7 +229,7 @@ def check_single_store(store: Store) -> None:
store.last_updated = ds.attrs.get('pangeo_forge_build_timestamp', None)


def validate_feedstocks(*, feedstocks: list[upath.UPath]) -> list[Feedstock]:
def validate_feedstocks(*, feedstocks: list[str]) -> list[Feedstock]:
errors = []
valid = []
catalog = []
Expand Down Expand Up @@ -286,7 +286,7 @@ def validate(args):


def generate(args):
feedstocks = collect_feedstocks(args.path)
feedstocks = [args.single] if args.single else collect_feedstocks(args.path)
catalog = validate_feedstocks(feedstocks=feedstocks)
output = upath.UPath(args.output).resolve() / 'output'
output.mkdir(parents=True, exist_ok=True)
Expand All @@ -310,9 +310,11 @@ def main():

# Subparser for the "generate" command
parser_generate = subparsers.add_parser('generate', help='Generate the catalog')
parser_generate.add_argument(
'--path', type=str, required=True, help='Path to the feedstocks input YAML file'
group = parser_generate.add_mutually_exclusive_group(required=True)
group.add_argument(
'--path', type=str, help='Path to the feedstocks input YAML file or directory'
)
group.add_argument('--single', type=str, help='Path to a single feedstock YAML file')
parser_generate.add_argument(
'--output', type=str, required=True, help='Path to the output directory'
)
Expand Down