Skip to content

Commit 5504841

Browse files
committed
feat: mount local DLS-filesystem mirror into dev backend for image serving
The backend image endpoints read atlas/grid-square files off disk using the absolute /dls/... paths stored in the DB, but a DB dump has no files. Mount a local mirror of Diamond's /dls filesystem into the dev API pod so those endpoints resolve. - smartem-workspace scaffolds testdata/dls-filesystem/ as the convention dir (a local mirror of /dls; populated by hand with imagery). Bump 0.6.1 -> 0.7.0. - dev-k8s.sh ensure_image_mount patches smartem-http-api with a hostPath <workspace>/testdata/dls-filesystem -> /dls (readOnly), overridable via SMARTEM_DLS_FILESYSTEM_DIR, skipped when absent. hostPath must be absolute and kustomize can't template, so this mirrors the existing ensure_* post-apply patch pattern. API service only: the worker never reads image files from disk.
1 parent 094cfe3 commit 5504841

4 files changed

Lines changed: 50 additions & 2 deletions

File tree

packages/smartem-workspace/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "smartem-workspace"
7-
version = "0.6.1"
7+
version = "0.7.0"
88
description = "CLI tool to automate SmartEM multi-repo workspace setup"
99
readme = "README.md"
1010
license = "Apache-2.0"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""SmartEM workspace setup CLI tool."""
22

3-
__version__ = "0.6.1"
3+
__version__ = "0.7.0"

packages/smartem-workspace/smartem_workspace/setup/workspace.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ def setup_workspace_structure(workspace_path: Path) -> bool:
1515
- repos/
1616
- tmp/
1717
- testdata/
18+
- testdata/dls-filesystem/ (local mirror of Diamond's /dls shared filesystem;
19+
populated by hand with microscopy imagery and mounted into the dev backend
20+
pod at /dls so image-serving endpoints can resolve DB /dls/... paths)
1821
1922
Returns:
2023
True if successful
@@ -26,6 +29,8 @@ def setup_workspace_structure(workspace_path: Path) -> bool:
2629
"repos",
2730
"tmp",
2831
"testdata",
32+
# Mirrors Diamond's /dls DFS root; mounted into the dev backend at /dls.
33+
"testdata/dls-filesystem",
2934
]
3035

3136
for dir_name in directories:

scripts/k8s/dev-k8s.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,46 @@ ensure_local_image() {
419419
fi
420420
}
421421

422+
# Mount the local DLS-filesystem mirror into the API pod so image-serving endpoints can
423+
# read atlas/grid-square files that the DB references by absolute /dls/... paths. hostPath
424+
# must be absolute and kustomize can't template, so (like the configmap/secret steps) we
425+
# patch the live deployment here. API service only: the worker never reads image files.
426+
# The mirror lives at <workspace>/testdata/dls-filesystem by convention; override with
427+
# SMARTEM_DLS_FILESYSTEM_DIR. Skipped silently when absent (images show placeholders).
428+
ensure_image_mount() {
429+
local workspace_root dls_dir
430+
workspace_root="$(cd "$PROJECT_ROOT/../../.." 2>/dev/null && pwd)"
431+
dls_dir="${SMARTEM_DLS_FILESYSTEM_DIR:-$workspace_root/testdata/dls-filesystem}"
432+
433+
if [[ ! -d "$dls_dir" ]]; then
434+
log_info "No DLS-filesystem mirror at $dls_dir - skipping image mount (atlas/grid-square images will show placeholders)"
435+
return 0
436+
fi
437+
438+
log_info "Mounting DLS-filesystem mirror into smartem-http-api: $dls_dir -> /dls"
439+
if kubectl patch deployment smartem-http-api -n "$NAMESPACE" --type strategic --patch "$(cat <<PATCH
440+
spec:
441+
template:
442+
spec:
443+
containers:
444+
- name: smartem-http-api
445+
volumeMounts:
446+
- name: dls-filesystem
447+
mountPath: /dls
448+
readOnly: true
449+
volumes:
450+
- name: dls-filesystem
451+
hostPath:
452+
path: $dls_dir
453+
type: Directory
454+
PATCH
455+
)" &> /dev/null; then
456+
log_success "DLS-filesystem mount applied to smartem-http-api"
457+
else
458+
log_warning "Could not apply DLS-filesystem mount (non-fatal; images will show placeholders)"
459+
fi
460+
}
461+
422462
# Deploy the environment
423463
deploy_environment() {
424464
log_info "Deploying development environment..."
@@ -440,6 +480,9 @@ deploy_environment() {
440480
# Ensure local image is built and available for development
441481
ensure_local_image
442482

483+
# Mount the local DLS-filesystem mirror so the API can serve atlas/grid-square images
484+
ensure_image_mount
485+
443486
log_success "Deployment initiated"
444487
}
445488

0 commit comments

Comments
 (0)