docstr: The Drive object provides a shared space to write and read files from.
  
  When the drive object is passed from one component to another, a copy is made and ownership
  is transferred to the new component.
  
  Arguments:
      id: Unique identifier for this Drive.
      allow_duplicates: Whether to enable files duplication between components.
      component_name: The component name which owns this drive.
          When not provided, it is automatically inferred by Lightning.
      root_folder: This is the folder from where the Drive perceives the data (e.g this acts as a mount dir).
docstr_tok: ["The","Drive","object","provides","a","shared","space","to","write","and","read","files","from",".","When","the","drive","object","is","passed","from","one","component","to","another",",","a","copy","is","made","and","ownership","is","transferred","to","the","new","component",".","Arguments",":","id",":","Unique","identifier","for","this","Drive",".","allow_duplicates",":","Whether","to","enable","files","duplication","between","components",".","component_name",":","The","component","name","which","owns","this","drive",".","When","not","provided",",","it","is","automatically","inferred","by","Lightning",".","root_folder",":","This","is","the","folder","from","where","the","Drive","perceives","the","data","(","e.g","this","acts","as","a","mount","dir",")","."]
code: def __init__(
      self,
      id: str,
      allow_duplicates: bool = False,
      component_name: Optional[str] = None,
      root_folder: Optional[str] = None,
  ):
      """The Drive object provides a shared space to write and read files from.
  
      When the drive object is passed from one component to another, a copy is made and ownership
      is transferred to the new component.
  
      Arguments:
          id: Unique identifier for this Drive.
          allow_duplicates: Whether to enable files duplication between components.
          component_name: The component name which owns this drive.
              When not provided, it is automatically inferred by Lightning.
          root_folder: This is the folder from where the Drive perceives the data (e.g this acts as a mount dir).
  
      """
      if id.startswith("s3://"):
          raise ValueError(
              "Using S3 buckets in a Drive is no longer supported. Please pass an S3 `Mount` to "
              "a Work's CloudCompute config in order to mount an s3 bucket as a filesystem in a work.\n"
              f"`CloudCompute(mount=Mount({id}), ...)`"
          )
  
      self.id = None
      self.protocol = None
      for protocol in self.__PROTOCOLS__:
          if id.startswith(protocol):
              self.protocol = protocol
              self.id = id.replace(protocol, "")
              break
      else:  # N.B. for-else loop
          raise ValueError(
              f"Unknown protocol for the drive 'id' argument '{id}`. The 'id' string "
              f"must start with one of the following prefixes {self.__PROTOCOLS__}"
          )
  
      if not self.id:
          raise Exception(
              f"The Drive id needs to start with one of the following protocols: {self.__PROTOCOLS__}"
          )
  
      if "/" in self.id:
          raise Exception(
              f"The id should be unique to identify your drive. Found `{self.id}`."
          )
  
      self.root_folder = (
          pathlib.Path(root_folder).resolve()
          if root_folder
          else pathlib.Path(os.getcwd())
      )
      if self.protocol != "s3://" and not os.path.isdir(
          self.root_folder
      ):
          raise Exception(
              f"The provided root_folder isn't a directory: {root_folder}"
          )
      self.component_name = component_name
      self.allow_duplicates = allow_duplicates
      self.fs = _filesystem()
  
imports: import os
  import pathlib
  import shutil
  import sys
  from copy import deepcopy
  from time import sleep, time
  from typing import Dict, List, Optional, Union
  from lightning.app.storage.path import LocalFileSystem, _filesystem, _shared_storage_path
  from lightning.app.utilities.component import _is_flow_context
label_desc: Use image node_id 1 to create a new Drive object  with example: obj = Drive(id, allow_duplicates, component_name, root_folder)