Skip to content

Commit

Permalink
Refactor dependencies in pyproject.toml. The original monolithic li…
Browse files Browse the repository at this point in the history
…st has been split into optional dependencies under 'pangeo-forge' and 'catalog'.
  • Loading branch information
andersy005 committed May 6, 2024
1 parent fdca556 commit 4209de0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
10 changes: 6 additions & 4 deletions leap_data_management_utils/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import pydantic_core
import requests
import upath
import yaml
from ruamel.yaml import YAML

yaml = YAML(typ='safe')


def s3_to_https(s3_url: str) -> str:
Expand Down Expand Up @@ -80,10 +82,10 @@ class Feedstock(pydantic.BaseModel):

@classmethod
def from_yaml(cls, path: str):
content = yaml.safe_load(upath.UPath(path).read_text())
content = yaml.load(upath.UPath(path).read_text())
if 'ncviewjs:meta_yaml_url' in content:
meta_url = convert_to_raw_github_url(content['ncviewjs:meta_yaml_url'])
meta = yaml.safe_load(upath.UPath(meta_url).read_text())
meta = yaml.load(upath.UPath(meta_url).read_text())
content = content | meta
data = cls.model_validate(content)
return data
Expand Down Expand Up @@ -113,7 +115,7 @@ def collect_feedstocks(path: upath.UPath) -> list[upath.UPath]:
"""Collects all the datasets in the given directory."""

url = convert_to_raw_github_url(path)
if not (feedstocks := yaml.safe_load(upath.UPath(url).read_text())['feedstocks']):
if not (feedstocks := yaml.load(upath.UPath(url).read_text())['feedstocks']):
raise FileNotFoundError(f'No YAML files (.yaml or .yml) found in {path}')
return feedstocks

Expand Down
22 changes: 9 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,29 @@ classifiers = [
"Topic :: Scientific/Engineering",
]
dependencies = [
"apache-beam",
"cftime",
"db_dtypes",
"google-api-core",
"google-cloud-bigquery",
"pandas",
"pangeo-forge-esgf",
"pangeo-forge-recipes",
"pydantic-core",
"pydantic>=2",
"pyyaml",
"ruamel.yaml",
"universal-pathlib",
"xarray",
"zarr",
]

[project.optional-dependencies]

pangeo-forge=[ "db_dtypes",
"google-api-core",
"google-cloud-bigquery",
"pandas",
"pangeo-forge-esgf",
"pangeo-forge-recipes", "apache-beam"]
catalog = ["pydantic>=2","universal-pathlib", "pydantic-core"]
test = [
"pytest"
]

dev = [
"leap-data-leap_data_management_utils[test]",
"pre-commit"
]

complete = ["leap-data-leap_data_management_utils[pangeo-forge,catalog]"]

[project.scripts]
leap-catalog = "leap_data_management_utils.catalog:main"
Expand Down

0 comments on commit 4209de0

Please sign in to comment.