code: def snapshot_path_prefix(
      request: FixtureRequest,
      snapshot_group: str,
      snapshot_id: str,
      additional_sub_directories: Tuple[str, ...] = (),
  ) -> str:
      """Returns a path prefix that can be used to build filenames for files associated with the snapshot.
  
      The snapshot prefix is generated from the name of the test file, the name of the test, name of the snapshot class,
      and the name of the snapshot.
  
      e.g.
      .../snapshots/test_file.py/DataflowPlan/test_name__plan1
  
      which can be used to construct paths like
  
      .../snapshots/test_file.py/DataflowPlan/test_name__plan1.xml
      .../snapshots/test_file.py/DataflowPlan/test_name__plan1.svg
      """
      test_name = request.node.name
  
      snapshot_file_name_parts = []
      # Parameterized test names look like 'test_case[some_param]'. "[" and "]" are annoying to deal with in the shell,
      # so replace them with dunders.
      snapshot_file_name_parts.extend(re.split(r"[\[\]]", test_name))
      # A trailing ] will produce an empty string in the list, so remove that.
      snapshot_file_name_parts = [
          part for part in snapshot_file_name_parts if len(part) > 0
      ]
      snapshot_file_name_parts.append(snapshot_id)
  
      snapshot_file_name = "__".join(snapshot_file_name_parts)
  
      path_items: List[str] = []
  
      test_file_path_items = os.path.normpath(
          request.node.fspath
      ).split(os.sep)
      test_file_name = test_file_path_items[-1]
      # Default to where this is defined, but use more appropriate directories if found.
      test_directory_root_index = -1
      for i, path_item in enumerate(test_file_path_items):
          if path_item in (
              "test",
              "metricflow",
              "metricflow_extensions",
          ):
              test_directory_root_index = i + 1
  
      path_to_store_snapshots = os.sep.join(
          test_file_path_items[:test_directory_root_index]
      )
      path_items.extend(
          [
              path_to_store_snapshots,
              "snapshots",
              test_file_name,
              snapshot_group,
          ]
      )
  
      if additional_sub_directories:
          path_items.extend(additional_sub_directories)
      path_items.append(snapshot_file_name)
  
      return os.path.abspath(os.path.join(*path_items))
  
imports: from __future__ import annotations
  import difflib
  import logging
  import os
  import re
  import webbrowser
  from typing import Any, Callable, List, Optional, Tuple, TypeVar
  import tabulate
  from _pytest.fixtures import FixtureRequest
  from dbt_semantic_interfaces.pretty_print import pformat_big_objects
  from metricflow.dag.mf_dag import MetricFlowDag
  from metricflow.dataflow.dataflow_plan import DataflowPlan
  from metricflow.dataflow.dataflow_plan_to_text import dataflow_plan_as_text
  from metricflow.execution.execution_plan import ExecutionPlan
  from metricflow.execution.execution_plan_to_text import execution_plan_to_text
  from metricflow.mf_logging.pretty_print import mf_pformat
  from metricflow.model.semantics.linkable_spec_resolver import LinkableElementSet
  from metricflow.naming.object_builder_scheme import ObjectBuilderNamingScheme
  from metricflow.protocols.sql_client import SqlClient
  from metricflow.specs.specs import InstanceSpecSet, LinkableSpecSet
  from metricflow.test.fixtures.setup_fixtures import MetricFlowTestSessionState, check_sql_engine_snapshot_marker
label_desc: Use image node_id 3 for calling a global function with example usage: snapshot_path_prefix(request, snapshot_group, snapshot_id, additional_sub_directories) and returns: os