class_docstr: Distribute spark directory from driver to executors.
docstr: Given a SparkSession and a model_path which refers to a pyfunc directory locally,
  we will zip the directory up, enable it to be distributed to executors, and return
  the "archive_path", which should be used as the path in get_or_load().
docstr_tok: ["Given","a","SparkSession","and","a","model_path","which","refers","to","a","pyfunc","directory","locally",",","we","will","zip","the","directory","up",",","enable","it","to","be","distributed","to","executors",",","and","return","the","``","archive_path","''",",","which","should","be","used","as","the","path","in","get_or_load","(",")","."]
code: def add_dir(spark, dir_path):
      """Given a SparkSession and a model_path which refers to a pyfunc directory locally,
      we will zip the directory up, enable it to be distributed to executors, and return
      the "archive_path", which should be used as the path in get_or_load().
      """
      _, archive_basepath = tempfile.mkstemp()
      # NB: We must archive the directory as Spark.addFile does not support non-DFS
      # directories when recursive=True.
      archive_path = shutil.make_archive(
          archive_basepath, "zip", dir_path
      )
  
      if (
          nfs_cache_dir := _get_spark_distributor_nfs_cache_dir()
      ) is not None:
          # If NFS directory (shared by all spark nodes) is available, use NFS directory
          # instead of `SparkContext.addFile` to distribute files.
          # Because `SparkContext.addFile` is not secure, so it is not allowed to be called
          # on a shared cluster.
          dest_path = os.path.join(
              nfs_cache_dir, os.path.basename(archive_path)
          )
          shutil.copy(archive_path, dest_path)
          return _NFS_PATH_PREFIX + dest_path
  
      spark.sparkContext.addFile(archive_path)
      return archive_path
  
file_path: mlflow/mlflow/utils/_spark_utils.py
imports: import contextlib
  import os
  import shutil
  import tempfile
  import zipfile
label_desc: Use image node_id 2 for calling the _SparkDirectoryDistributor obj's underlying member method code with example usage: obj.add_dir(spark, dir_path) and returns: archive_path, unknown