|
1 | | -from typing import Generic |
2 | | - |
3 | 1 | __author__ = "Johannes Köster" |
4 | 2 | __copyright__ = "Copyright 2024, Johannes Köster" |
5 | 3 | __email__ = "johannes.koester@uni-due.de" |
|
23 | 21 | Self, |
24 | 22 | Tuple, |
25 | 23 | Type, |
26 | | - TypeVar, |
27 | 24 | Union, |
28 | 25 | Callable, |
29 | 26 | ) |
30 | 27 | import subprocess as sp |
31 | 28 |
|
32 | | -from snakemake_interface_software_deployment_plugins.settings import ( |
33 | | - SoftwareDeploymentSettingsBase, |
34 | | -) |
35 | 29 | from snakemake_interface_common.exceptions import WorkflowError |
36 | 30 |
|
37 | 31 |
|
@@ -63,8 +57,14 @@ def technical_init(self): |
63 | 57 | self._obj_hash: Optional[int] = None |
64 | 58 |
|
65 | 59 | @classmethod |
66 | | - def env_cls(cls): |
67 | | - return cls.module().EnvBase |
| 60 | + def env_cls(cls) -> Type["EnvBase"]: |
| 61 | + try: |
| 62 | + return cls.module().EnvBase |
| 63 | + except AttributeError: |
| 64 | + raise AttributeError( |
| 65 | + "No class Env found next to EnvSpec class. " |
| 66 | + "Make sure to import or define it there." |
| 67 | + ) |
68 | 68 |
|
69 | 69 | @classmethod |
70 | 70 | @abstractmethod |
@@ -168,28 +168,25 @@ def run(self, cmd: str, **kwargs) -> sp.CompletedProcess: |
168 | 168 | return sp.run([self.executable] + self.args + [self.command_arg, cmd], **kwargs) |
169 | 169 |
|
170 | 170 |
|
171 | | -TSettings = TypeVar("TSettings", bound="Optional[SoftwareDeploymentSettingsBase]") |
172 | | -TEnvSpec = TypeVar("TEnvSpec", bound="EnvSpecBase") |
173 | | - |
174 | | - |
175 | | -class EnvBase(ABC, Generic[TEnvSpec, TSettings]): |
| 171 | +class EnvBase(ABC): |
176 | 172 | _cache: ClassVar[Dict[Tuple[Type["EnvBase"], Optional["EnvBase"]], Any]] = {} |
177 | 173 |
|
178 | 174 | def __init__( |
179 | 175 | self, |
180 | | - spec: TEnvSpec, |
| 176 | + spec, |
181 | 177 | within: Optional["EnvBase"], |
182 | | - settings: TSettings, |
| 178 | + settings, |
183 | 179 | shell_executable: ShellExecutable, |
184 | 180 | tempdir: Path, |
185 | 181 | source_cache: Path, |
186 | 182 | cache_prefix: Path, |
187 | 183 | deployment_prefix: Path, |
188 | 184 | pinfile_prefix: Path, |
189 | 185 | ): |
190 | | - self.spec: TEnvSpec = spec |
| 186 | + # type annotation for spec and settings is left for implementing plugins |
| 187 | + self.spec = spec |
191 | 188 | self.within = within |
192 | | - self.settings: TSettings = settings |
| 189 | + self.settings = settings |
193 | 190 | self.shell_executable = shell_executable |
194 | 191 | self.tempdir = tempdir |
195 | 192 | self.source_cache: Path = source_cache |
|
0 commit comments