Skip to content

Commit

Permalink
Enable catalog generation for single feedstock (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
andersy005 authored Oct 21, 2024
1 parent 2a43792 commit cf28c84
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
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

0 comments on commit cf28c84

Please sign in to comment.