-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathverify_fields.py
More file actions
67 lines (53 loc) · 2.1 KB
/
verify_fields.py
File metadata and controls
67 lines (53 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python3
"""Verify URL fields were added to the index"""
import os
import requests
# Load .env
env_path = os.path.join(os.path.dirname(__file__), "ui", ".env")
env_vars = {}
if os.path.exists(env_path):
with open(env_path) as f:
for line in f:
if '=' in line and not line.startswith('#'):
key, value = line.strip().split('=', 1)
env_vars[key] = value
SEARCH_ENDPOINT = env_vars.get("SEARCH_ENDPOINT")
SEARCH_KEY = env_vars.get("SEARCH_KEY")
SEARCH_INDEX_NAME = env_vars.get("SEARCH_INDEX_NAME", "segments")
API_VERSION = "2024-07-01"
def check_index():
url = f"{SEARCH_ENDPOINT}/indexes/{SEARCH_INDEX_NAME}?api-version={API_VERSION}"
headers = {"api-key": SEARCH_KEY}
response = requests.get(url, headers=headers)
if response.status_code == 200:
index = response.json()
fields = {f["name"]: f["type"] for f in index.get("fields", [])}
print("✅ Successfully connected to index!")
print(f"\nTotal fields: {len(fields)}")
print(f"\nChecking URL tracking fields:")
url_fields = {
"source_url": "Edm.String",
"source_type": "Edm.String",
"processed_at": "Edm.DateTimeOffset"
}
all_present = True
for field, expected_type in url_fields.items():
if field in fields:
print(f" ✅ {field}: {fields[field]}")
else:
print(f" ❌ {field}: MISSING")
all_present = False
if all_present:
print("\n🎉 SUCCESS! All URL tracking fields are present!")
print("\nYou can now:")
print("1. Restart your Streamlit app")
print("2. Process new videos - URLs will be stored automatically")
else:
print("\n⚠️ Some fields are missing. Run the add script again.")
return all_present
else:
print(f"❌ Failed to get index: {response.status_code}")
print(response.text)
return False
if __name__ == "__main__":
check_index()