-
Notifications
You must be signed in to change notification settings - Fork 25
refactor!: move container options to shared containers key
#387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
agitter
merged 17 commits into
Reed-CompBio:main
from
tristan-f-r:container-schema-move
Oct 24, 2025
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
2374a2c
refactor!: move container options to shared `containers` key
tristan-f-r d0edde5
fix: update refs to other settings
tristan-f-r e9bddcc
test: correct containers inside config
tristan-f-r 77b5b11
test: use correct containers key
tristan-f-r 3cadfc4
docs: container_registry -> containeres.registry
tristan-f-r 2301443
docs: cmt
tristan-f-r d99db99
Merge branch 'main' into container-schema-move
tristan-f-r b1f2034
refactor!: prefer top-level hash length in config
tristan-f-r 5e2c1f1
fix: mv hash-length
tristan-f-r c436b07
Merge branch 'main' into container-schema-move
tristan-f-r 3f46af6
fix: add apptainer variant
tristan-f-r a26ef0b
fix: config indentation
tristan-f-r 2e9cbd8
Merge branch 'main' into container-schema-move
tristan-f-r d7ad402
style: fmt
tristan-f-r 45803d7
fix: apply corrected stacklevel
tristan-f-r f006033
Merge branch 'main' into container-schema-move
tristan-f-r 9eb8c90
docs: update containers references
tristan-f-r File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| """ | ||
| The separate container schema specification file. | ||
| For information about pydantic, see schema.py. | ||
|
|
||
| We move this to a separate file to allow `containers.py` to explicitly take in | ||
| this subsection of the configuration. | ||
| """ | ||
|
|
||
| import warnings | ||
| from dataclasses import dataclass | ||
|
|
||
| from pydantic import BaseModel, ConfigDict | ||
|
|
||
| from spras.config.util import CaseInsensitiveEnum | ||
|
|
||
| DEFAULT_CONTAINER_PREFIX = "docker.io/reedcompbio" | ||
|
|
||
| class ContainerFramework(CaseInsensitiveEnum): | ||
| docker = 'docker' | ||
| singularity = 'singularity' | ||
| apptainer = 'apptainer' | ||
| dsub = 'dsub' | ||
|
|
||
| class ContainerRegistry(BaseModel): | ||
| base_url: str = "docker.io" | ||
| "The domain of the registry" | ||
|
|
||
| owner: str = "reedcompbio" | ||
| "The owner or project of the registry" | ||
|
|
||
| model_config = ConfigDict(extra='forbid', use_attribute_docstrings=True) | ||
|
|
||
| class ContainerSettings(BaseModel): | ||
| framework: ContainerFramework = ContainerFramework.docker | ||
| unpack_singularity: bool = False | ||
| registry: ContainerRegistry | ||
|
|
||
| model_config = ConfigDict(extra='forbid') | ||
|
|
||
| @dataclass | ||
| class ProcessedContainerSettings: | ||
| framework: ContainerFramework = ContainerFramework.docker | ||
| unpack_singularity: bool = False | ||
| prefix: str = DEFAULT_CONTAINER_PREFIX | ||
| hash_length: int = 7 | ||
| """ | ||
| The hash length for container-specific usage. This does not appear in | ||
| the output folder, but it may show up in logs, and usually never needs | ||
| to be tinkered with. This will be the top-level `hash_length` specified | ||
| in the config. | ||
|
|
||
| We prefer this `hash_length` in our container-running logic to | ||
| avoid a (future) dependency diamond. | ||
| """ | ||
|
|
||
| @staticmethod | ||
| def from_container_settings(settings: ContainerSettings, hash_length: int) -> "ProcessedContainerSettings": | ||
| if settings.framework == ContainerFramework.dsub: | ||
| warnings.warn("'dsub' framework integration is experimental and may not be fully supported.", stacklevel=2) | ||
| container_framework = settings.framework | ||
|
|
||
| # Unpack settings for running in singularity mode. Needed when running PRM containers if already in a container. | ||
| if settings.unpack_singularity and container_framework != "singularity": | ||
| warnings.warn("unpack_singularity is set to True, but the container framework is not singularity. This setting will have no effect.", stacklevel=2) | ||
| unpack_singularity = settings.unpack_singularity | ||
|
|
||
| # Grab registry from the config, and if none is provided default to docker | ||
| container_prefix = DEFAULT_CONTAINER_PREFIX | ||
| if settings.registry and settings.registry.base_url != "" and settings.registry.owner != "": | ||
| container_prefix = settings.registry.base_url + "/" + settings.registry.owner | ||
|
|
||
| return ProcessedContainerSettings( | ||
| framework=container_framework, | ||
| unpack_singularity=unpack_singularity, | ||
| prefix=container_prefix, | ||
| hash_length=hash_length | ||
| ) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.