hats.io.summary_file#

Functions#

write_collection_summary_file(→ upath.UPath)

Write a summary readme file for a HATS catalog.

default_md_template(→ str)

Get the default Jinja2 template string for generating Markdown summary files.

generate_markdown_collection_summary(→ str)

Generate Markdown summary content for a HATS collection.

Module Contents#

write_collection_summary_file(collection_path: str | pathlib.Path | upath.UPath, *, fmt: Literal['markdown'], filename: str | None = None, output_dir: str | pathlib.Path | upath.UPath | None = None, name: str | None = None, description: str | None = None, uri: str | None = None, huggingface_metadata: bool = False, jinja2_template: str | None = None) upath.UPath[source]#

Write a summary readme file for a HATS catalog.

Parameters:
collection_path: str | Path | UPath

The path to the HATS collection.

fmtstr

The format of the summary file. Currently only “markdown” is supported.

filename: str | None, default=None

The name of the summary file. If None, default depends on a fmt: - “README.md” for “markdown” format.

output_dirstr | Path | UPath | None

The root directory to output the summary file to. If None, the summary file would be written to the collection_path. If the directory does not exist, it would be created.

namestr | None, default=None

Human-readable name of the catalog. By default, generated based on catalog metadata.

descriptionstr | None, default=None

Description of the catalog. By default, generated based on catalog metadata.

uristr | None, default=None

URI of the catalog to use for the hyperlinks and code-snippet examples. Not validated. If None, a placeholder would be used for the code-snippets.

huggingface_metadatabool, default=False

Whether to include Hugging Face specific metadata header in the Markdown file, by default False. Supported only when fmt=”markdown”.

jinja2_templatestr, default=None

jinja2 template string to use for generating the summary file. If provided, it would override the default template from these functions: - default_md_template() for fmt=”markdown”.

Returns:
UPath

The path to the written summary file.

Notes

  1. Not all options are supported for all formats.

  2. Default template is the subject of frequent changes, do not rely on it.

default_md_template() str[source]#

Get the default Jinja2 template string for generating Markdown summary files.

Returns:
str

The default Jinja2 template string.

generate_markdown_collection_summary(collection: hats.catalog.catalog_collection.CatalogCollection, *, name: str, description: str, uri: str | None, huggingface_metadata: bool, jinja2_template: str | None = None) str[source]#

Generate Markdown summary content for a HATS collection.

Parameters:
collectionCatalogCollection

HATS collection to generate summary for.

namestr

Title of the Markdown document.

descriptionstr

Description of the catalog.

uristr | None

URI of the catalog to use for the hyperlinks and code-snippet examples. Not validated. If None, a placeholder would be used for the code-snippets.

huggingface_metadatabool

Whether to include Hugging Face specific metadata header in the Markdown file.

jinja2_templatestr | None