Try to fix metadata stuff again (does not work)
This commit is contained in:
@@ -47,7 +47,7 @@
|
||||
|
||||
/* Metadata popup */
|
||||
.metadata-popup {
|
||||
background: var(--card-background);
|
||||
background: var(--card-bg);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
|
||||
|
||||
@@ -47,3 +47,5 @@ metadata:
|
||||
sources:
|
||||
- name: "ttbar_analysis"
|
||||
path: "/work/kschmidt/NEEDLE/test_analysis/data/cf_store/test_analysis/cf.PlotVariables1D/run2_2016_nano_v9/"
|
||||
- name: "NEEDLE_benchmarks"
|
||||
path: "/work/kschmidt/NEEDLE/orchestrator/ml/benchmarks/plots"
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from pathlib import Path
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
|
||||
# Test template rendering
|
||||
env = Environment(loader=FileSystemLoader("."))
|
||||
template = env.get_template("templates/gallery.html")
|
||||
|
||||
# Mock data
|
||||
test_items = [{
|
||||
"name": "test_plot",
|
||||
"pdf_href": "test_plot.pdf",
|
||||
"png_href": "test_plot.png",
|
||||
"metadata": {"key1": "value1", "key2": "value2"}
|
||||
}]
|
||||
|
||||
test_config = {
|
||||
"paths": {"work_dir": "/work/kschmidt/web"},
|
||||
"ui": {"search_debounce_ms": 300, "max_recent_plots": 20}
|
||||
}
|
||||
|
||||
rendered = template.render(
|
||||
title="Test Gallery",
|
||||
items=test_items,
|
||||
subdirs=["test_subdir"],
|
||||
relpath="test/path",
|
||||
paths=test_config["paths"],
|
||||
ui=test_config["ui"],
|
||||
stats={"file_count": 1, "folder_count": 1, "total_size": "100 KB", "total_size_bytes": 100000},
|
||||
folder_metadata={},
|
||||
assets_path="../assets"
|
||||
)
|
||||
|
||||
# Extract just the metadata button part
|
||||
lines = rendered.split('\n')
|
||||
for i, line in enumerate(lines):
|
||||
if 'metadata-btn' in line:
|
||||
print(f"Line {i}: {line.strip()}")
|
||||
if i > 0:
|
||||
print(f"Line {i-1}: {lines[i-1].strip()}")
|
||||
if i < len(lines)-1:
|
||||
print(f"Line {i+1}: {lines[i+1].strip()}")
|
||||
break
|
||||
|
||||
print("\n--- Assets path in template ---")
|
||||
for i, line in enumerate(lines):
|
||||
if 'assets_path' in line:
|
||||
print(f"Line {i}: {line.strip()}")
|
||||
@@ -144,6 +144,11 @@ def build_gallery(source_dir: Path, web_dir: Path,
|
||||
|
||||
# Resolve metadata for this specific plot
|
||||
plot_metadata = resolve_metadata_for_plot(pdf_file, current_metadata)
|
||||
if not plot_metadata:
|
||||
plot_metadata = {}
|
||||
for k, v in plot_metadata.items():
|
||||
if isinstance(v, str):
|
||||
plot_metadata[k] = v.replace('<', '').replace('>', '').replace('&', '').replace('"', "'")
|
||||
plot_metadata_cache[pdf_file.stem] = plot_metadata
|
||||
|
||||
items.append({
|
||||
|
||||
@@ -45,7 +45,7 @@ def load_metadata_file(metadata_path: Path) -> Dict[str, Any]:
|
||||
return {}
|
||||
except (yaml.YAMLError, json.JSONDecodeError, IOError) as e:
|
||||
print(f"Warning: Could not parse metadata file {metadata_path}: {e}")
|
||||
return {}
|
||||
raise e
|
||||
|
||||
|
||||
def load_folder_metadata(folder_path: Path) -> Dict[str, Any]:
|
||||
|
||||
+9
-7
@@ -15,13 +15,15 @@ def main():
|
||||
|
||||
try:
|
||||
# Call the gallery generation script
|
||||
result = subprocess.run([
|
||||
"python3",
|
||||
"/work/kschmidt/web/generate_gallery.py"
|
||||
],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=300) # 5 minute timeout
|
||||
result = subprocess.run(
|
||||
[
|
||||
"python3",
|
||||
"/work/kschmidt/web/generate_gallery.py"
|
||||
],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=300,
|
||||
)
|
||||
|
||||
if result.returncode == 0:
|
||||
print("Gallery refresh successful!")
|
||||
|
||||
@@ -41,7 +41,11 @@
|
||||
<a href="{{ item.pdf_href }}">
|
||||
<img src="{{ item.png_href }}" alt="{{ item.name }}">
|
||||
</a>
|
||||
<button class="metadata-btn" onclick="event.stopPropagation(); showMetadataPopup(this, '{{ item.name|e }}', {{ (item.metadata or {})|tojson }})" title="View metadata">
|
||||
<button class="metadata-btn"
|
||||
data-plot-name="{{ item.name|e }}"
|
||||
data-metadata="{{ item.metadata|tojson|e if item.metadata is not none and item.metadata|length > 0 else '{}' }}"
|
||||
onclick="event.stopPropagation(); showMetadataPopup(this, this.dataset.plotName, JSON.parse(this.dataset.metadata))"
|
||||
title="View metadata">
|
||||
⋯
|
||||
</button>
|
||||
<div class="plot-name" title="{{ item.name }}">{{ item.name }}</div>
|
||||
|
||||
Reference in New Issue
Block a user