snakemake-interface-software-deployment-plugins 0.7.0__tar.gz → 0.7.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (10) hide show
  1. {snakemake_interface_software_deployment_plugins-0.7.0 → snakemake_interface_software_deployment_plugins-0.7.2}/PKG-INFO +1 -1
  2. {snakemake_interface_software_deployment_plugins-0.7.0 → snakemake_interface_software_deployment_plugins-0.7.2}/pyproject.toml +1 -1
  3. {snakemake_interface_software_deployment_plugins-0.7.0 → snakemake_interface_software_deployment_plugins-0.7.2}/snakemake_interface_software_deployment_plugins/__init__.py +2 -2
  4. {snakemake_interface_software_deployment_plugins-0.7.0 → snakemake_interface_software_deployment_plugins-0.7.2}/snakemake_interface_software_deployment_plugins/tests.py +50 -17
  5. {snakemake_interface_software_deployment_plugins-0.7.0 → snakemake_interface_software_deployment_plugins-0.7.2}/LICENSE +0 -0
  6. {snakemake_interface_software_deployment_plugins-0.7.0 → snakemake_interface_software_deployment_plugins-0.7.2}/README.md +0 -0
  7. {snakemake_interface_software_deployment_plugins-0.7.0 → snakemake_interface_software_deployment_plugins-0.7.2}/snakemake_interface_software_deployment_plugins/_common.py +0 -0
  8. {snakemake_interface_software_deployment_plugins-0.7.0 → snakemake_interface_software_deployment_plugins-0.7.2}/snakemake_interface_software_deployment_plugins/registry/__init__.py +0 -0
  9. {snakemake_interface_software_deployment_plugins-0.7.0 → snakemake_interface_software_deployment_plugins-0.7.2}/snakemake_interface_software_deployment_plugins/registry/plugin.py +0 -0
  10. {snakemake_interface_software_deployment_plugins-0.7.0 → snakemake_interface_software_deployment_plugins-0.7.2}/snakemake_interface_software_deployment_plugins/settings.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: snakemake-interface-software-deployment-plugins
3
- Version: 0.7.0
3
+ Version: 0.7.2
4
4
  Summary: This package provides a stable interface for interactions between Snakemake and its software deployment plugins.
5
5
  License: MIT
6
6
  Author: Johannes Köster
@@ -5,7 +5,7 @@ license = "MIT"
5
5
  name = "snakemake-interface-software-deployment-plugins"
6
6
  packages = [{include = "snakemake_interface_software_deployment_plugins"}]
7
7
  readme = "README.md"
8
- version = "0.7.0"
8
+ version = "0.7.2"
9
9
 
10
10
  [tool.poetry.dependencies]
11
11
  argparse-dataclass = "^2.0.0"
@@ -247,7 +247,7 @@ class PinnableEnvBase(ABC):
247
247
  def pinfile_extension(cls) -> str: ...
248
248
 
249
249
  @abstractmethod
250
- def pin(self) -> None:
250
+ async def pin(self) -> None:
251
251
  """Pin the environment to potentially more concrete versions than defined.
252
252
  Only implement this base class if pinning makes sense for your kind of
253
253
  environment. Pinfile has to be written to self.pinfile.
@@ -269,7 +269,7 @@ class CacheableEnvBase(ABC):
269
269
  async def get_cache_assets(self) -> Iterable[str]: ...
270
270
 
271
271
  @abstractmethod
272
- def cache_assets(self) -> None:
272
+ async def cache_assets(self) -> None:
273
273
  """Determine environment assets and store any associated information or data to
274
274
  self.cache_path.
275
275
  """
@@ -1,18 +1,18 @@
1
1
  from abc import ABC, abstractmethod
2
2
  import asyncio
3
3
  from copy import deepcopy
4
- import tempfile
5
4
  from typing import Optional, Type
6
5
  import subprocess as sp
7
6
 
8
7
  import pytest
9
8
 
10
9
  from snakemake_interface_software_deployment_plugins import (
11
- ArchiveableEnvBase,
10
+ CacheableEnvBase,
12
11
  DeployableEnvBase,
13
12
  EnvBase,
14
13
  EnvSpecBase,
15
14
  EnvSpecSourceFile,
15
+ PinnableEnvBase,
16
16
  SoftwareReport,
17
17
  )
18
18
  from snakemake_interface_software_deployment_plugins.settings import (
@@ -52,10 +52,22 @@ class TestSoftwareDeploymentBase(ABC):
52
52
  ...
53
53
 
54
54
  @abstractmethod
55
- def get_software_deployment_provider_settings(
55
+ def get_settings(
56
56
  self,
57
57
  ) -> Optional[SoftwareDeploymentSettingsBase]: ...
58
58
 
59
+ @abstractmethod
60
+ def get_settings_cls(self) -> Optional[Type[SoftwareDeploymentSettingsBase]]: ...
61
+
62
+ def test_envspec_str(self):
63
+ print("env spec", str(self.get_env_spec()))
64
+
65
+ def test_default_settings(self):
66
+ settings_cls = self.get_settings_cls()
67
+ if settings_cls is None:
68
+ pytest.skip("No settings class defined.")
69
+ settings_cls()
70
+
59
71
  def test_shellcmd(self, tmp_path):
60
72
  env = self._get_env(tmp_path)
61
73
 
@@ -80,13 +92,24 @@ class TestSoftwareDeploymentBase(ABC):
80
92
 
81
93
  def test_archive(self, tmp_path):
82
94
  env = self._get_env(tmp_path)
83
- if not isinstance(env, ArchiveableEnvBase):
84
- pytest.skip("Environment either not deployable or not archiveable.")
95
+ if not isinstance(env, CacheableEnvBase):
96
+ pytest.skip("Environment either not deployable or not cacheable.")
97
+
98
+ asyncio.run(env.cache_assets())
85
99
 
86
100
  self._deploy(env, tmp_path)
87
101
 
88
- asyncio.run(env.archive())
89
- assert any((tmp_path / "archives").iterdir())
102
+ assert any(env.cache_path.iterdir())
103
+
104
+ def test_pin(self, tmp_path):
105
+ env = self._get_env(tmp_path)
106
+ if not isinstance(env, PinnableEnvBase):
107
+ pytest.skip("Environment is not pinnable.")
108
+
109
+ asyncio.run(env.pin())
110
+ assert env.pinfile.exists()
111
+ print("Pinfile content:", env.pinfile.read_text(), sep="\n")
112
+ self._deploy(env, tmp_path)
90
113
 
91
114
  def test_report_software(self, tmp_path):
92
115
  env = self._get_env(tmp_path)
@@ -113,22 +136,32 @@ class TestSoftwareDeploymentBase(ABC):
113
136
  spec = deepcopy(self.get_env_spec())
114
137
  for attr in spec.source_path_attributes():
115
138
  source_file = getattr(spec, attr)
116
- source_file.cached = source_file.path_or_uri
139
+ if source_file is not None:
140
+ source_file.cached = source_file.path_or_uri
117
141
  return spec
118
142
 
119
143
  def _get_env(self, tmp_path) -> EnvBase:
120
144
  env_cls = self.get_env_cls()
121
145
  spec = self._get_cached_env_spec()
122
- args = {
123
- "settings": self.get_software_deployment_provider_settings(),
124
- "tempdir": tempfile.gettempdir(),
125
- }
126
- if issubclass(env_cls, DeployableEnvBase):
127
- args["deployment_prefix"] = tmp_path / "deployments"
128
- if issubclass(env_cls, ArchiveableEnvBase):
129
- args["archive_prefix"] = tmp_path / "archives"
146
+
147
+ tempdir = tmp_path / "temp"
148
+ deployment_prefix = tmp_path / "deployments"
149
+ cache_prefix = tmp_path / "cache"
150
+ pinfile_prefix = tmp_path / "pinfiles"
151
+ tempdir.mkdir(parents=True, exist_ok=True)
152
+ deployment_prefix.mkdir(parents=True, exist_ok=True)
153
+ cache_prefix.mkdir(parents=True, exist_ok=True)
154
+ pinfile_prefix.mkdir(parents=True, exist_ok=True)
155
+
130
156
  return env_cls(
131
- spec=spec, within=None, shell_executable=self.shell_executable, **args
157
+ spec=spec,
158
+ within=None,
159
+ settings=self.get_settings(),
160
+ shell_executable=self.shell_executable,
161
+ tempdir=tempdir,
162
+ deployment_prefix=deployment_prefix,
163
+ cache_prefix=cache_prefix,
164
+ pinfile_prefix=pinfile_prefix,
132
165
  )
133
166
 
134
167
  def _deploy(self, env: DeployableEnvBase, tmp_path):