|
19 | 19 | from dvsim.utils import clean_odirs, mk_symlink, rm_path |
20 | 20 |
|
21 | 21 | if TYPE_CHECKING: |
22 | | - from dvsim.job.deploy import Deploy |
| 22 | + from dvsim.job.deploy import Deploy, WorkspaceConfig |
23 | 23 |
|
24 | 24 |
|
25 | 25 | class LauncherError(Exception): |
@@ -97,18 +97,18 @@ def __init__(self, deploy: "Deploy") -> None: |
97 | 97 | deploy: deployment object that will be launched. |
98 | 98 |
|
99 | 99 | """ |
100 | | - cfg = deploy.sim_cfg |
| 100 | + workspace_cfg = deploy.workspace_cfg |
101 | 101 |
|
102 | 102 | # One-time preparation of the workspace. |
103 | 103 | if not Launcher.workspace_prepared: |
104 | | - # TODO: CLI args should be processed far earlier than this |
105 | | - self.prepare_workspace(cfg.project, cfg.proj_root, cfg.args) |
| 104 | + self.prepare_workspace(workspace_cfg) |
106 | 105 | Launcher.workspace_prepared = True |
107 | 106 |
|
108 | 107 | # One-time preparation of the workspace, specific to the cfg. |
109 | | - if cfg not in Launcher.workspace_prepared_for_cfg: |
110 | | - self.prepare_workspace_for_cfg(cfg) |
111 | | - Launcher.workspace_prepared_for_cfg.add(cfg) |
| 108 | + project = workspace_cfg.project |
| 109 | + if project not in Launcher.workspace_prepared_for_cfg: |
| 110 | + self.prepare_workspace_for_cfg(workspace_cfg) |
| 111 | + Launcher.workspace_prepared_for_cfg.add(project) |
112 | 112 |
|
113 | 113 | # Store the deploy object handle. |
114 | 114 | self.deploy = deploy |
@@ -155,34 +155,40 @@ def set_pyvenv(project: str) -> None: |
155 | 155 | # The code below allows each launcher variant to set its own virtualenv |
156 | 156 | # because the loading / activating mechanism could be different between |
157 | 157 | # them. |
158 | | - Launcher.pyvenv = os.environ.get( |
159 | | - f"{project.upper()}_PYVENV_{Launcher.variant.upper()}", |
160 | | - ) |
| 158 | + common_venv = f"{project.upper()}_PYVENV" |
| 159 | + variant = Launcher.variant.upper() |
| 160 | + |
| 161 | + venv_path = os.environ.get(f"{common_venv}_{variant}") |
| 162 | + |
| 163 | + if not venv_path: |
| 164 | + venv_path = os.environ.get(common_venv) |
161 | 165 |
|
162 | 166 | if not Launcher.pyvenv: |
163 | 167 | Launcher.pyvenv = os.environ.get(f"{project.upper()}_PYVENV") |
164 | 168 |
|
165 | 169 | @staticmethod |
166 | 170 | @abstractmethod |
167 | | - def prepare_workspace(project: str, repo_top: str, args: Mapping) -> None: |
| 171 | + def prepare_workspace(cfg: "WorkspaceConfig") -> None: |
168 | 172 | """Prepare the workspace based on the chosen launcher's needs. |
169 | 173 |
|
170 | 174 | This is done once for the entire duration for the flow run. |
171 | 175 |
|
172 | 176 | Args: |
173 | | - project: the name of the project. |
174 | | - repo_top: the path to the repository. |
175 | | - args: command line args passed to dvsim. |
| 177 | + cfg: workspace configuration |
176 | 178 |
|
177 | 179 | """ |
178 | 180 |
|
179 | 181 | @staticmethod |
180 | 182 | @abstractmethod |
181 | | - def prepare_workspace_for_cfg(cfg: Mapping) -> None: |
| 183 | + def prepare_workspace_for_cfg(cfg: "WorkspaceConfig") -> None: |
182 | 184 | """Prepare the workspace for a cfg. |
183 | 185 |
|
184 | 186 | This is invoked once for each cfg. |
185 | 187 | 'cfg' is the flow configuration object. |
| 188 | +
|
| 189 | + Args: |
| 190 | + cfg: workspace configuration |
| 191 | +
|
186 | 192 | """ |
187 | 193 |
|
188 | 194 | def __str__(self) -> str: |
|
0 commit comments