code: def test_get_or_create_execution_directory_is_idempotent(tmp_path):
      class TestStep(BaseStepImplemented):
          def __init__(self):  # pylint: disable=super-init-not-called
              pass
  
          @property
          def name(self):
              return "test_step"
  
      test_step = TestStep()
  
      def assert_expected_execution_directory_contents_exist(
          execution_dir_path,
      ):
          assert (execution_dir_path / "Makefile").exists()
          assert (execution_dir_path / "steps").exists()
          assert (
              execution_dir_path / "steps" / test_step.name / "outputs"
          ).exists()
  
      execution_dir_path_1 = pathlib.Path(
          _get_or_create_execution_directory(
              recipe_root_path=tmp_path,
              recipe_steps=[test_step],
              template="regression/v1",
          )
      )
      execution_dir_path_2 = pathlib.Path(
          _get_or_create_execution_directory(
              recipe_root_path=tmp_path,
              recipe_steps=[test_step],
              template="regression/v1",
          )
      )
      assert execution_dir_path_1 == execution_dir_path_2
      assert_expected_execution_directory_contents_exist(
          execution_dir_path_1
      )
  
      shutil.rmtree(execution_dir_path_1)
  
      # Simulate a failure with Makefile creation
      with mock.patch(
          "mlflow.recipes.utils.execution._create_makefile",
          side_effect=Exception("Makefile creation failed"),
      ), pytest.raises(Exception, match="Makefile creation failed"):
          _get_or_create_execution_directory(
              recipe_root_path=tmp_path,
              recipe_steps=[test_step],
              template="regression/v1",
          )
  
      # Verify that the directory exists but is empty due to short circuiting after
      # failed Makefile creation
      assert execution_dir_path_1.exists()
      assert next(execution_dir_path_1.iterdir(), None) is None
  
      # Re-create the execution directory and verify that all expected contents are present
      execution_dir_path_3 = pathlib.Path(
          _get_or_create_execution_directory(
              recipe_root_path=tmp_path,
              recipe_steps=[test_step],
              template="regression/v1",
          )
      )
      assert execution_dir_path_3 == execution_dir_path_1
      assert_expected_execution_directory_contents_exist(
          execution_dir_path_3
      )
  
      shutil.rmtree(execution_dir_path_1)
  
      # Simulate a failure with step-specific directory creation
      with mock.patch(
          "mlflow.recipes.utils.execution._get_step_output_directory_path",
          side_effect=Exception("Step directory creation failed"),
      ), pytest.raises(
          Exception, match="Step directory creation failed"
      ):
          _get_or_create_execution_directory(
              recipe_root_path=tmp_path,
              recipe_steps=[test_step],
              template="regression/v1",
          )
  
      # Verify that the directory exists & that a Makefile is present but step-specific directories
      # were not created due to failures
      assert execution_dir_path_1.exists()
      assert [path.name for path in execution_dir_path_1.iterdir()] == [
          "Makefile"
      ]
  
      # Re-create the execution directory and verify that all expected contents are present
      execution_dir_path_4 = pathlib.Path(
          _get_or_create_execution_directory(
              recipe_root_path=tmp_path,
              recipe_steps=[test_step],
              template="regression/v1",
          )
      )
      assert execution_dir_path_4 == execution_dir_path_1
      assert_expected_execution_directory_contents_exist(
          execution_dir_path_4
      )
  
imports: import os
  import pathlib
  import shutil
  import time
  from unittest import mock
  import pandas
  import pytest
  from mlflow.environment_variables import MLFLOW_RECIPES_EXECUTION_TARGET_STEP_NAME
  from mlflow.recipes import Recipe
  from mlflow.recipes.step import StepStatus
  from mlflow.recipes.steps.ingest import IngestStep
  from mlflow.recipes.steps.split import SplitStep
  from mlflow.recipes.steps.transform import TransformStep
  from mlflow.recipes.utils.execution import _ExecutionPlan, _get_or_create_execution_directory, get_step_output_path, run_recipe_step
  from tests.recipes.helper_functions import BaseStepImplemented
label_desc: Use image node_id 5 for calling a global function with example usage: test_get_or_create_execution_directory_is_idempotent(tmp_path) and returns: str