diff --git a/src/matcha_ml/runners/azure_runner.py b/src/matcha_ml/runners/azure_runner.py index 73cd7fd9..57c64afe 100644 --- a/src/matcha_ml/runners/azure_runner.py +++ b/src/matcha_ml/runners/azure_runner.py @@ -57,7 +57,7 @@ def provision(self) -> None: self._validate_terraform_config() self._validate_kubeconfig(base_path=".kube/config") self._initialize_terraform(msg="Matcha") - self._apply_terraform() + self._apply_terraform(msg="Matcha") tf_output = self.tfs.terraform_client.output() matcha_state_service = MatchaStateService(terraform_output=tf_output) self._show_terraform_outputs(matcha_state_service._state) diff --git a/src/matcha_ml/runners/base_runner.py b/src/matcha_ml/runners/base_runner.py index 925d0f3a..f6e394c0 100644 --- a/src/matcha_ml/runners/base_runner.py +++ b/src/matcha_ml/runners/base_runner.py @@ -131,9 +131,12 @@ def _check_matcha_directory_exists(self) -> None: ) raise typer.Exit() - def _apply_terraform(self) -> None: + def _apply_terraform(self, msg: str = "") -> None: """Run terraform apply to create resources on cloud. + Args: + msg (str) : Name of the type of resource (e.g. "Remote State" or "Matcha"). + Raises: MatchaTerraformError: if 'terraform apply' failed. """ @@ -147,11 +150,19 @@ def _apply_terraform(self) -> None: if tf_result.return_code != 0: raise MatchaTerraformError(tf_error=tf_result.std_err) - print_status( - build_substep_success_status( - f"{Emojis.CHECKMARK.value} Matcha resources have been provisioned!\n" + + if msg: + print_status( + build_substep_success_status( + f"{Emojis.CHECKMARK.value} {msg} resources have been provisioned!\n" + ) + ) + else: + print_status( + build_substep_success_status( + f"{Emojis.CHECKMARK.value} Resources have been provisioned!\n" + ) ) - ) def _destroy_terraform(self, msg: str = "") -> None: """Destroy the provisioned resources. diff --git a/src/matcha_ml/runners/remote_state_runner.py b/src/matcha_ml/runners/remote_state_runner.py index 921ada2e..99b72dfc 100644 --- a/src/matcha_ml/runners/remote_state_runner.py +++ b/src/matcha_ml/runners/remote_state_runner.py @@ -63,7 +63,7 @@ def provision(self) -> Tuple[str, str, str]: self._validate_terraform_config() self._validate_kubeconfig(base_path=".kube/config") self._initialize_terraform(msg="Remote State") - self._apply_terraform() + self._apply_terraform(msg="Remote State") return self._get_terraform_output() def deprovision(self) -> None: diff --git a/tests/test_runners/test_base_runner.py b/tests/test_runners/test_base_runner.py index c7a91a43..77d30656 100644 --- a/tests/test_runners/test_base_runner.py +++ b/tests/test_runners/test_base_runner.py @@ -119,9 +119,9 @@ def test_apply_terraform(capsys: SysCapture): """ template_runner = BaseRunner() template_runner.tfs.apply = MagicMock(return_value=TerraformResult(0, "", "")) - expected = "Matcha resources have been provisioned!" + expected = "Remote State resources have been provisioned!" - template_runner._apply_terraform() + template_runner._apply_terraform(msg="Remote State") captured = capsys.readouterr() assert expected in captured.out