Decouple Docker/Singularity backend infrastructure
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
Research direction
Start by reading brats/docker.py, brats/singularity.py, and brats_algorithm.py, focusing on the referenced helper imports, client initialization, year-based volume selection, and backend dispatch. Done means shared helpers live in brats/core/_backend_shared.py, clients initialize lazily, RunArgs exposes the layout choice, and BackendRunner provides a typed dispatch contract for both backends.
Written by the indexing model from the issue text.
Description
Summary
docker.py and singularity.py are tightly coupled, have latent bugs, and duplicate logic. This issue covers extracting shared code, fixing import-time side effects, and adding type safety.
Steps
1. Extract shared helpers into brats/core/_backend_shared.py
singularity.py:15-26 imports 8 private (underscore-prefixed) functions from docker.py. These are shared concerns (volume mappings, device handling, sanity checks, algorithm info logging) that both backends need. Move them to a shared module. Both backends import from _backend_shared.py instead of from each other.
2. Lazy-init Docker clients (fixes latent NameError)
docker.py:27-33 and singularity.py:29-37 initialize Docker clients at module scope:
try:
client = docker.from_env()
except DockerException as e:
logger.error(...)
docker.py has a bug: when docker.from_env() fails, client is never assigned — not even to None. Any subsequent call referencing client raises NameError. singularity.py handles this correctly by setting docker_client = None in the except block. Move initialization into a lazy function or cached_property in both modules.
3. Move year-based branching to data model
Both docker.py:452 and singularity.py:197 duplicate:
if algorithm.meta.year <= 2024:
volume_mappings = _get_volume_mappings_mlcube(...)
else:
volume_mappings = _get_volume_mappings_docker_only(...)
These branches select between the MLCube volume layout and the native /input//output layout. Add a property to RunArgs (e.g. use_mlcube_layout: bool) that encodes this. Both backends read the property instead of branching on year.
4. Add a BackendRunner Protocol
brats_algorithm.py:169 uses Callable[..., object] for the backend dispatch dict — no type safety. Define a typing.Protocol specifying the run_container signature. This would also expose that singularity.run_container has an extra overlay_size parameter not present in docker.run_container.
- Dominant language
- Python
- Stars
- 89
- Forks
- 19
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 4
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from BrainLesion/BraTS
-
documentation
Difficulty 1/5 Under an hour Newbie friendliness 74/100
BrainLesion/BraTS#200 ·
-
[FEATURE] 2024 challenge proceedings are released and need to be referenced correctlyPossibly taken @MarcelRosier claimed this 10 days ago. Openenhancement
Difficulty 1/5 Under an hour Newbie friendliness 55/100
BrainLesion/BraTS#198 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
BrainLesion/BraTS#191 ·
-
BraTS-GoAT 2025 container images (BraTS25_1A-1D) are not published on Docker HubPossibly taken @PaulaTBz claimed this 24 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 38/100
BrainLesion/BraTS#189 · 4 comments · 1 assignee ·
-
[FEATURE] Integration smoke-test suite for containerized algorithmsPossibly taken @MarcelRosier claimed this 39 days ago. Openenhancement
Difficulty 5/5 Over a week Newbie friendliness 35/100
BrainLesion/BraTS#185 ·
All issues in BrainLesion/BraTS
Similar issues
-
[Bug]: reme CLI crashes when the running server used a relative config pathPossibly taken @nurlanmnn claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
agentscope-ai/ReMe#770 ·
Maintainers usually reply within 1 day
-
Pi: paused model calls are reported as "not signed in" when the model's provider comes from an extensionPossibly taken @balcsida claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
microsoft/TokenEconomizer#288 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 67/100
sickn33/agentic-awesome-skills#2437 ·
Maintainers usually reply within 1 day
-
site-bug triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ethereum/consensus-specs#5846 ·
Maintainers usually reply within 1 day