Skip to content

Commit

Permalink
add sb2hf version number to README
Browse files Browse the repository at this point in the history
  • Loading branch information
felixhultin committed Nov 28, 2024
1 parent c61df72 commit 6ff293d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion hf_gen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@

# Disclaimer

This repository has been automatically created using the [sb2hf](https://github.com/felixhultin/sb2hf/tree/main) tool.
This repository has been automatically created using the [sb2hf](https://github.com/felixhultin/sb2hf/tree/main) tool, version {{ sb2hf_version }}.
10 changes: 9 additions & 1 deletion hf_gen/create_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
"""

import codecs
import importlib
import logging
import pkg_resources
import requests
import yaml


from jinja2 import Template

from helpers import get_value
Expand All @@ -19,11 +22,16 @@ def write_readme(url_reader: URLReader, metadata : dict, fp : str):
bibtex_query = f"{TEMP_LINK}/bibtex?resource={url_reader.resource_name}&type={metadata['type']}"
logging.info(f"Fetching bibtex from {bibtex_query}")
bibtex = requests.get(bibtex_query).json()['bibtex']
try:
sb2hf_version = pkg_resources.get_distribution('sb2hf').version
except importlib.metadata.PackageNotFoundError:
sb2hf_version = "Unknown"
template_variables = {
'description': get_value(metadata, 'description'),
'title' : get_value(metadata, 'name'),
'bibtex': bibtex,
'url': url_reader.url
'url': url_reader.url,
'sb2hf_version': sb2hf_version
}
with open('hf_gen/README.md', 'r') as file:
template = Template(file.read(),trim_blocks=True)
Expand Down

0 comments on commit 6ff293d

Please sign in to comment.