|
8 | 8 |
|
9 | 9 | from datetime import datetime |
10 | 10 | from pathlib import Path |
| 11 | +from typing import Optional |
11 | 12 |
|
12 | 13 | import markdown |
13 | 14 |
|
14 | 15 | from .. import __version__ |
15 | 16 | from ..models.event import Event |
16 | 17 | from ..models.solution import Solution |
17 | 18 | from ..models.submission import Submission |
| 19 | +from .utils import resolve_dossier_asset_path |
18 | 20 |
|
19 | 21 |
|
20 | 22 | def generate_solution_page(solution: Solution, event: Event, submission: Submission, output_dir: Path) -> None: |
@@ -55,12 +57,49 @@ def generate_solution_page(solution: Solution, event: Event, submission: Submiss |
55 | 57 | Notes are rendered with syntax highlighting for code blocks. |
56 | 58 | """ |
57 | 59 | # Prepare output directory (already created) |
58 | | - html = _generate_solution_page_content(solution, event, submission) |
| 60 | + project_root = Path(submission.project_path) |
| 61 | + lc_plot = resolve_dossier_asset_path( |
| 62 | + solution.lightcurve_plot_path, |
| 63 | + project_root, |
| 64 | + output_dir, |
| 65 | + subdir="plots", |
| 66 | + prefix=f"{event.event_id}_{solution.solution_id}_lightcurve", |
| 67 | + ) |
| 68 | + lens_plot = resolve_dossier_asset_path( |
| 69 | + solution.lens_plane_plot_path, |
| 70 | + project_root, |
| 71 | + output_dir, |
| 72 | + subdir="plots", |
| 73 | + prefix=f"{event.event_id}_{solution.solution_id}_lens", |
| 74 | + ) |
| 75 | + posterior = resolve_dossier_asset_path( |
| 76 | + solution.posterior_path, |
| 77 | + project_root, |
| 78 | + output_dir, |
| 79 | + subdir="posteriors", |
| 80 | + prefix=f"{event.event_id}_{solution.solution_id}_posterior", |
| 81 | + ) |
| 82 | + html = _generate_solution_page_content( |
| 83 | + solution, |
| 84 | + event, |
| 85 | + submission, |
| 86 | + lc_plot=lc_plot, |
| 87 | + lens_plot=lens_plot, |
| 88 | + posterior=posterior, |
| 89 | + ) |
59 | 90 | with (output_dir / f"{solution.solution_id}.html").open("w", encoding="utf-8") as f: |
60 | 91 | f.write(html) |
61 | 92 |
|
62 | 93 |
|
63 | | -def _generate_solution_page_content(solution: Solution, event: Event, submission: Submission) -> str: |
| 94 | +def _generate_solution_page_content( |
| 95 | + solution: Solution, |
| 96 | + event: Event, |
| 97 | + submission: Submission, |
| 98 | + *, |
| 99 | + lc_plot: Optional[str] = None, |
| 100 | + lens_plot: Optional[str] = None, |
| 101 | + posterior: Optional[str] = None, |
| 102 | +) -> str: |
64 | 103 | """Generate the HTML content for a solution dossier page. |
65 | 104 |
|
66 | 105 | Creates the complete HTML content for a single solution page, including |
@@ -138,9 +177,9 @@ def _generate_solution_page_content(solution: Solution, event: Event, submission |
138 | 177 | # Higher-order effects |
139 | 178 | hoe_str = ", ".join(solution.higher_order_effects) if solution.higher_order_effects else "None" |
140 | 179 | # Plot paths (relative to solution page) |
141 | | - lc_plot = solution.lightcurve_plot_path or "" |
142 | | - lens_plot = solution.lens_plane_plot_path or "" |
143 | | - posterior = solution.posterior_path or "" |
| 180 | + lc_plot = lc_plot if lc_plot is not None else (solution.lightcurve_plot_path or "") |
| 181 | + lens_plot = lens_plot if lens_plot is not None else (solution.lens_plane_plot_path or "") |
| 182 | + posterior = posterior if posterior is not None else (solution.posterior_path or "") |
144 | 183 | # Physical parameters table |
145 | 184 | phys_rows = [] |
146 | 185 | phys = solution.physical_parameters or {} |
|
0 commit comments