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

✨ Add an artifact loader for .yaml #2172

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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: 12 additions & 1 deletion lamindb/core/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
load_h5mu
load_html
load_json
load_yaml
load_image
load_svg

Expand Down Expand Up @@ -107,9 +108,17 @@ def load_json(path: UPathStr) -> dict:
data = json.load(f)
return data

def load_yaml(path: UPathStr) -> dict:
"""Load `.yaml` to `dict`."""
import yaml

with open(path) as f:
data = yaml.safe_load(f)
return data


def load_image(path: UPathStr):
"""Display `.svg` in ipython, otherwise return path."""
"""Display `.jpg`, `.png` or `.gif` in ipython, otherwise return path."""
if is_run_from_ipython:
from IPython.display import Image, display

Expand Down Expand Up @@ -138,9 +147,11 @@ def load_svg(path: UPathStr) -> None | Path:
".zarr": load_anndata_zarr,
".html": load_html,
".json": load_json,
".yaml": load_yaml,
".h5mu": load_h5mu,
".jpg": load_image,
".png": load_image,
".gif": load_image,
".svg": load_svg,
}

Expand Down
Loading