Remove API endpoint files that were created during freezing
(build_dir: Path)
| 198 | |
| 199 | |
| 200 | def _cleanup_api_files(build_dir: Path): |
| 201 | """Remove API endpoint files that were created during freezing""" |
| 202 | build_path = Path(build_dir) |
| 203 | |
| 204 | # List of files/directories to remove (API endpoints that shouldn't be in static build) |
| 205 | cleanup_patterns = [ |
| 206 | "download-file", |
| 207 | "load-log", |
| 208 | "load-trajectory-details", |
| 209 | "load-trajectory-diffs", |
| 210 | "delete-experiment", |
| 211 | "batch", |
| 212 | "analysis", |
| 213 | "picker/api", |
| 214 | ] |
| 215 | |
| 216 | for pattern in cleanup_patterns: |
| 217 | target = build_path / pattern |
| 218 | if target.exists(): |
| 219 | if target.is_file(): |
| 220 | target.unlink() |
| 221 | print(f" Removed file: {pattern}") |
| 222 | elif target.is_dir(): |
| 223 | shutil.rmtree(target) |
| 224 | print(f" Removed directory: {pattern}") |
| 225 | |
| 226 | |
| 227 | def _add_html_extensions(build_dir: Path): |