| 48 | self.has_provisioned = False |
| 49 | |
| 50 | async def provision(self) -> Self: |
| 51 | connect_params = ConnectParams.from_env() |
| 52 | |
| 53 | if connect_params and self.cfg.workdir: |
| 54 | msg = ( |
| 55 | "Cannot configure workdir for existing session " |
| 56 | "(please use --workdir or host.directory " |
| 57 | "with absolute paths instead)." |
| 58 | ) |
| 59 | raise ProvisionError(msg) |
| 60 | |
| 61 | if not connect_params: |
| 62 | self.has_provisioned = True |
| 63 | # Only start progress if we are provisioning, not on active sessions |
| 64 | # like `dagger run`. |
| 65 | await self.progress.start("Provisioning engine") |
| 66 | cli_bin = await self.get_cli() |
| 67 | |
| 68 | await self.progress.update("Creating new Engine session") |
| 69 | connect_params = await self.stack.enter_async_context( |
| 70 | start_cli_session(self.cfg, cli_bin) |
| 71 | ) |
| 72 | |
| 73 | self.connect_params = connect_params |
| 74 | self.connect_config = ConnectConfig( |
| 75 | timeout=self.cfg.timeout, |
| 76 | retry=self.cfg.retry, |
| 77 | ) |
| 78 | |
| 79 | return self |
| 80 | |
| 81 | async def get_cli(self) -> str: |
| 82 | """Get path to CLI.""" |