Skip to content

Commit

Permalink
feat(hermes): Use container (#3992)
Browse files Browse the repository at this point in the history
### Changed

- Use Hermes container instead of Conda env.
- Add container mount volume to cg config and use it to switch context
  • Loading branch information
henrikstranneheim authored Dec 9, 2024
1 parent 2456a19 commit 51e078e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
9 changes: 8 additions & 1 deletion cg/apps/hermes/hermes_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ class HermesApi:
"""Class to communicate with hermes"""

def __init__(self, config: dict):
self.process = Process(binary=config["hermes"]["binary_path"])
self.process = Process(
binary=config["hermes"]["binary_path"],
)
self.container_mount_volume = config["hermes"]["container_mount_volume"]

def convert_deliverables(
self,
Expand All @@ -27,6 +30,10 @@ def convert_deliverables(
"""Convert deliverables file in raw workflow format to CG format with Hermes."""
LOG.info("Converting workflow deliverables to CG deliverables")
convert_command = [
"run",
"--bind",
self.container_mount_volume,
"/home/proj/stage/singularity_containers/hermes_latest.sif",
"convert",
"deliverables",
"--workflow",
Expand Down
1 change: 1 addition & 0 deletions cg/models/cg_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class StatinaConfig(BaseModel):
class CommonAppConfig(BaseModel):
binary_path: str | None = None
config_path: str | None = None
container_mount_volume: str | None = None


class FluffyUploadConfig(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion cg/utils/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Process:
"""Class to handle communication with other programs via the shell.
The other parts of the code should not need to have any knowledge about how the processes are
called, that will be handled in this module.Output form stdout and stdin will be handled here.
called; that will be handled in this module.Output form stdout and stdin will be handled here.
"""

def __init__(
Expand Down
7 changes: 6 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1220,7 +1220,12 @@ def hermes_process() -> ProcessMock:
@pytest.fixture(name="hermes_api")
def hermes_api(hermes_process: ProcessMock) -> HermesApi:
"""Return a Hermes API with a mocked process."""
hermes_config = {"hermes": {"binary_path": "/bin/true"}}
hermes_config = {
"hermes": {
"binary_path": "/bin/true",
"container_mount_volume": "a_str",
}
}
hermes_api = HermesApi(config=hermes_config)
hermes_api.process = hermes_process
return hermes_api
Expand Down

0 comments on commit 51e078e

Please sign in to comment.