Skip to content

Commit

Permalink
Merge pull request #32 from tranzmatt/master
Browse files Browse the repository at this point in the history
Failsafe because git_tag doesn't exist in vladmandic/automatic
  • Loading branch information
zixaphir authored Oct 22, 2023
2 parents 6f896ef + ac182d1 commit 93cff0e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
7 changes: 6 additions & 1 deletion scripts/ch_lib/model_action_civitai.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,12 @@ def dummy_model_info(path, sha256_hash, model_type):
# do store their training data.
trained_words = model_info["trainedWords"]

file_metadata = sd_models.read_metadata_from_safetensors(path)
try:
file_metadata = sd_models.read_metadata_from_safetensors(path)
except AssertionError:
# model is not a safetensors file. This is fine,
# it just doesn't have metadata we can read
pass

tag_frequency = file_metadata.get("ss_tag_frequency", {})

Expand Down
27 changes: 20 additions & 7 deletions scripts/ch_lib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,13 +393,26 @@ def webui_version() -> str:
returns the version in the form 'X.Y.Z'
'''
version = None
tag = launch.git_tag()
match = re.match(r"v([\d.]+)", tag)
if match:
version = match.group(1)
else:
# XXX assume a modern SD Webui version if one cannot be found.
version = "1.6.0"
try:
tag = launch.git_tag()
match = re.match(r"v([\d.]+)", tag)
if match:
version = match.group(1)
else:
# XXX assume a modern SD Webui version if one cannot be found.
version = "1.6.0"
except AttributeError as e:
try:
return subprocess.check_output([git, "describe", "--tags"], shell=False, encoding='utf8').strip()
except Exception:
try:
changelog_md = os.path.join(os.path.dirname(os.path.dirname(__file__)), "CHANGELOG.md")
with open(changelog_md, "r", encoding="utf-8") as file:
line = next((line.strip() for line in file if line.strip()), "<none>")
line = line.replace("## ", "")
version = line
except Exception:
version = "1.6.0"
return version


Expand Down

0 comments on commit 93cff0e

Please sign in to comment.