Spaces:
Runtime error
Runtime error
sradc
commited on
Commit
·
15402aa
1
Parent(s):
253ef1f
fix: catch exception if can't get git hash
Browse files
video_semantic_search/app.py
CHANGED
|
@@ -3,7 +3,7 @@ import hashlib
|
|
| 3 |
import os
|
| 4 |
import subprocess
|
| 5 |
from dataclasses import dataclass
|
| 6 |
-
from typing import
|
| 7 |
|
| 8 |
import faiss
|
| 9 |
import numpy as np
|
|
@@ -48,8 +48,11 @@ def get_semantic_searcher():
|
|
| 48 |
|
| 49 |
|
| 50 |
@st.cache_data
|
| 51 |
-
def get_git_hash() -> str:
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
|
| 55 |
@dataclass
|
|
@@ -128,7 +131,8 @@ def main():
|
|
| 128 |
logger.info(f"Recieved query... {hashlib.md5(query.encode()).hexdigest()}")
|
| 129 |
st.text("Click image to open video")
|
| 130 |
display_search_results(searcher.search(query))
|
| 131 |
-
|
|
|
|
| 132 |
|
| 133 |
|
| 134 |
if __name__ == "__main__":
|
|
|
|
| 3 |
import os
|
| 4 |
import subprocess
|
| 5 |
from dataclasses import dataclass
|
| 6 |
+
from typing import Optional
|
| 7 |
|
| 8 |
import faiss
|
| 9 |
import numpy as np
|
|
|
|
| 48 |
|
| 49 |
|
| 50 |
@st.cache_data
|
| 51 |
+
def get_git_hash() -> Optional[str]:
|
| 52 |
+
try:
|
| 53 |
+
return subprocess.check_output(["git", "rev-parse", "HEAD"]).decode().strip()
|
| 54 |
+
except subprocess.CalledProcessError:
|
| 55 |
+
return None
|
| 56 |
|
| 57 |
|
| 58 |
@dataclass
|
|
|
|
| 131 |
logger.info(f"Recieved query... {hashlib.md5(query.encode()).hexdigest()}")
|
| 132 |
st.text("Click image to open video")
|
| 133 |
display_search_results(searcher.search(query))
|
| 134 |
+
if get_git_hash():
|
| 135 |
+
st.text(f"Build: {get_git_hash()[0:7]}")
|
| 136 |
|
| 137 |
|
| 138 |
if __name__ == "__main__":
|