class_docstr: Stores artifacts on Amazon S3.
class_docstr_tok: ["Stores","artifacts","on","Amazon","S3","."]
code: def list_artifacts(self, path=None):
      (bucket, artifact_path) = self.parse_s3_compliant_uri(
          self.artifact_uri
      )
      dest_path = artifact_path
      if path:
          dest_path = posixpath.join(dest_path, path)
      infos = []
      prefix = dest_path + "/" if dest_path else ""
      s3_client = self._get_s3_client()
      paginator = s3_client.get_paginator("list_objects_v2")
      results = paginator.paginate(
          Bucket=bucket, Prefix=prefix, Delimiter="/"
      )
      for result in results:
          # Subdirectories will be listed as "common prefixes" due to the way we made the request
          for obj in result.get("CommonPrefixes", []):
              subdir_path = obj.get("Prefix")
              self._verify_listed_object_contains_artifact_path_prefix(
                  listed_object_path=subdir_path,
                  artifact_path=artifact_path,
              )
              subdir_rel_path = posixpath.relpath(
                  path=subdir_path, start=artifact_path
              )
              if subdir_rel_path.endswith("/"):
                  subdir_rel_path = subdir_rel_path[:-1]
              infos.append(FileInfo(subdir_rel_path, True, None))
          # Objects listed directly will be files
          for obj in result.get("Contents", []):
              file_path = obj.get("Key")
              self._verify_listed_object_contains_artifact_path_prefix(
                  listed_object_path=file_path,
                  artifact_path=artifact_path,
              )
              file_rel_path = posixpath.relpath(
                  path=file_path, start=artifact_path
              )
              file_size = int(obj.get("Size"))
              infos.append(FileInfo(file_rel_path, False, file_size))
      return sorted(infos, key=lambda f: f.path)
  
imports: import json
  import os
  import posixpath
  import urllib.parse
  from datetime import datetime
  from functools import lru_cache
  from mimetypes import guess_type
  from mlflow.entities import FileInfo
  from mlflow.entities.multipart_upload import CreateMultipartUploadResponse, MultipartUploadCredential
  from mlflow.environment_variables import MLFLOW_S3_ENDPOINT_URL, MLFLOW_S3_IGNORE_TLS, MLFLOW_S3_UPLOAD_EXTRA_ARGS
  from mlflow.exceptions import MlflowException
  from mlflow.store.artifact.artifact_repo import ArtifactRepository, MultipartUploadMixin
  from mlflow.utils.file_utils import relative_path_to_artifact_path
label_desc: Use image node_id 8 for calling the S3ArtifactRepository obj's underlying member method code with example usage: obj.list_artifacts(path) and returns: sorted