code: def test_log_artifact(tmp_path):
      # Create artifacts
      artifact_dir = tmp_path.joinpath("artifact_dir")
      artifact_dir.mkdir()
      path0 = artifact_dir.joinpath("file0")
      path1 = artifact_dir.joinpath("file1")
      path0.write_text("0")
      path1.write_text("1")
      # Log an artifact, verify it exists in the directory returned by get_artifact_uri
      # after the run finishes
      artifact_parent_dirs = ["some_parent_dir", None]
      for parent_dir in artifact_parent_dirs:
          with start_run():
              artifact_uri = mlflow.get_artifact_uri()
              run_artifact_dir = local_file_uri_to_path(artifact_uri)
              mlflow.log_artifact(path0, parent_dir)
          expected_dir = (
              os.path.join(run_artifact_dir, parent_dir)
              if parent_dir is not None
              else run_artifact_dir
          )
          assert os.listdir(expected_dir) == [os.path.basename(path0)]
          logged_artifact_path = os.path.join(expected_dir, path0)
          assert filecmp.cmp(logged_artifact_path, path0, shallow=False)
      # Log multiple artifacts, verify they exist in the directory returned by get_artifact_uri
      for parent_dir in artifact_parent_dirs:
          with start_run():
              artifact_uri = mlflow.get_artifact_uri()
              run_artifact_dir = local_file_uri_to_path(artifact_uri)
  
              mlflow.log_artifacts(artifact_dir, parent_dir)
          # Check that the logged artifacts match
          expected_artifact_output_dir = (
              os.path.join(run_artifact_dir, parent_dir)
              if parent_dir is not None
              else run_artifact_dir
          )
          dir_comparison = filecmp.dircmp(
              artifact_dir, expected_artifact_output_dir
          )
          assert len(dir_comparison.left_only) == 0
          assert len(dir_comparison.right_only) == 0
          assert len(dir_comparison.diff_files) == 0
          assert len(dir_comparison.funny_files) == 0
  
imports: import filecmp
  import json
  import os
  import pathlib
  import posixpath
  import random
  import re
  from collections import namedtuple
  from unittest import mock
  import pytest
  import yaml
  import mlflow
  from mlflow import MlflowClient, tracking
  from mlflow.entities import LifecycleStage, Metric, Param, RunStatus, RunTag, ViewType
  from mlflow.environment_variables import MLFLOW_RUN_ID
  from mlflow.exceptions import MlflowException
  from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE, RESOURCE_DOES_NOT_EXIST, ErrorCode
  from mlflow.store.tracking.file_store import FileStore
  from mlflow.tracking.fluent import start_run
  from mlflow.utils.file_utils import local_file_uri_to_path
  from mlflow.utils.mlflow_tags import MLFLOW_PARENT_RUN_ID, MLFLOW_RUN_NAME, MLFLOW_SOURCE_NAME, MLFLOW_SOURCE_TYPE, MLFLOW_USER
  from mlflow.utils.os import is_windows
  from mlflow.utils.time import get_current_time_millis
  from mlflow.utils.validation import MAX_METRICS_PER_BATCH, MAX_PARAMS_TAGS_PER_BATCH
label_desc: Use image node_id 28 for calling a global function with example usage: test_log_artifact(tmp_path) without return types