Skip to content

Commit 217b965

Browse files
feat: make deploy async (#11)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced the deployment and archiving processes to run asynchronously, enabling more efficient and responsive operations, especially for I/O-intensive tasks. - **Tests** - Updated testing routines to ensure the deployment and archiving improvements function correctly under asynchronous conditions. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 3288eb9 commit 217b965

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

snakemake_interface_software_deployment_plugins/__init__.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ def source_path_attributes(self) -> Iterable[str]:
5151
...
5252

5353
def has_source_paths(self) -> bool:
54-
if any(self.source_path_attributes()):
54+
if any(
55+
getattr(self, attr) is not None for attr in self.source_path_attributes()
56+
):
5557
return True
5658
if self.within is not None and self.within.has_source_paths():
5759
return True
@@ -65,7 +67,10 @@ def modify_source_paths(self, modify_func) -> Self:
6567
else:
6668
return self
6769
for attr in self_or_copied.source_path_attributes():
68-
setattr(self_or_copied, attr, modify_func(getattr(self_or_copied, attr)))
70+
for attr_name in self_or_copied.source_path_attributes():
71+
current_value = getattr(self_or_copied, attr_name)
72+
if current_value is not None:
73+
setattr(self_or_copied, attr_name, modify_func(current_value))
6974

7075
if self_or_copied.within is not None:
7176
self_or_copied.within = self_or_copied.within.modify_source_paths(
@@ -209,7 +214,7 @@ class DeployableEnvBase(EnvBase):
209214
_deployment_prefix: Optional[Path] = None
210215

211216
@abstractmethod
212-
def deploy(self) -> None:
217+
async def deploy(self) -> None:
213218
"""Deploy the environment to self.deployment_path.
214219
215220
When issuing shell commands, the environment should use
@@ -251,7 +256,7 @@ class ArchiveableEnvBase(EnvBase):
251256
archive_prefix: Optional[Path] = None
252257

253258
@abstractmethod
254-
def archive(self) -> None:
259+
async def archive(self) -> None:
255260
"""Archive the environment to self.archive_path.
256261
257262
When issuing shell commands, the environment should use

snakemake_interface_software_deployment_plugins/tests.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from abc import ABC, abstractmethod
2+
import asyncio
23
from pathlib import Path
34
from typing import Optional, Type
45
import subprocess as sp
@@ -82,7 +83,7 @@ def test_archive(self, tmp_path):
8283

8384
self._deploy(env, tmp_path)
8485

85-
env.archive()
86+
asyncio.run(env.archive())
8687
assert any((tmp_path / "{_TEST_SDM_NAME}-archive").iterdir())
8788

8889
def test_report_software(self, tmp_path):
@@ -122,5 +123,5 @@ def _deploy(self, env: DeployableEnvBase, tmp_path):
122123
if not isinstance(env, DeployableEnvBase):
123124
pytest.skip("Environment is not deployable.")
124125

125-
env.deploy()
126+
asyncio.run(env.deploy())
126127
assert any((tmp_path / _TEST_SDM_NAME).iterdir())

0 commit comments

Comments
 (0)