code: def test_conda_environment_cleaned_up_when_pip_fails(tmp_path):
      conda_yaml = tmp_path / "conda.yaml"
      content = f"""
  name: {uuid.uuid4().hex}
  channels:
    - conda-forge
  dependencies:
    - python={PYTHON_VERSION}
    - pip
    - pip:
        - mlflow==999.999.999
  """
      conda_yaml.write_text(content)
      envs_before = mlflow.utils.conda._list_conda_environments()
  
      # `conda create` should fail because mlflow 999.999.999 doesn't exist
      with pytest.raises(
          ShellCommandException, match=r"No matching distribution found"
      ):
          mlflow.utils.conda.get_or_create_conda_env(
              conda_yaml, capture_output=True
          )
  
      # Ensure the environment is cleaned up
      envs_after = mlflow.utils.conda._list_conda_environments()
      assert envs_before == envs_after
  
imports: import json
  import os
  import shutil
  import subprocess
  import uuid
  from unittest import mock
  import git
  import pytest
  import yaml
  from databricks_cli.configure.provider import DatabricksConfig
  import mlflow
  from mlflow import MlflowClient
  from mlflow.entities import RunStatus, SourceType, ViewType
  from mlflow.environment_variables import MLFLOW_CONDA_CREATE_ENV_CMD, MLFLOW_CONDA_HOME
  from mlflow.exceptions import ExecutionException, MlflowException
  from mlflow.projects import _parse_kubernetes_config, _resolve_experiment_id
  from mlflow.store.tracking.file_store import FileStore
  from mlflow.utils import PYTHON_VERSION
  from mlflow.utils.conda import CONDA_EXE, get_or_create_conda_env
  from mlflow.utils.mlflow_tags import LEGACY_MLFLOW_GIT_BRANCH_NAME, LEGACY_MLFLOW_GIT_REPO_URL, MLFLOW_GIT_BRANCH, MLFLOW_GIT_REPO_URL, MLFLOW_PARENT_RUN_ID, MLFLOW_PROJECT_BACKEND, MLFLOW_PROJECT_ENTRY_POINT, MLFLOW_PROJECT_ENV, MLFLOW_SOURCE_NAME, MLFLOW_SOURCE_TYPE, MLFLOW_USER
  from mlflow.utils.process import ShellCommandException
  from tests.projects.utils import TEST_PROJECT_DIR, TEST_PROJECT_NAME, validate_exit_status
label_desc: Use image node_id 17 for calling a global function with example usage: test_conda_environment_cleaned_up_when_pip_fails(tmp_path) without return types