class_docstr: A drop-in replacement for :class:`pathlib.Path` for all paths in Lightning.
  
  The Lightning Path works exactly the same as :class:`pathlib.Path` but it also remembers in which LightningWork
  it was created. If the Path gets passed to a different LightningWork, the file or folder can then be easily
  accessed no matter where it is located in the other Work's filesystem.
  
  Args:
      *args: Accepts the same arguments as in :class:`pathlib.Path`
      **kwargs: Accepts the same keyword arguments as in :class:`pathlib.Path`
class_docstr_tok: ["A","drop-in","replacement","for",":","class",":","`","pathlib.Path","`","for","all","paths","in","Lightning",".","The","Lightning","Path","works","exactly","the","same","as",":","class",":","`","pathlib.Path","`","but","it","also","remembers","in","which","LightningWork","it","was","created",".","If","the","Path","gets","passed","to","a","different","LightningWork",",","the","file","or","folder","can","then","be","easily","accessed","no","matter","where","it","is","located","in","the","other","Work","'s","filesystem",".","Args",":","*","args",":","Accepts","the","same","arguments","as","in",":","class",":","`","pathlib.Path","`","*","*","kwargs",":","Accepts","the","same","keyword","arguments","as","in",":","class",":","`","pathlib.Path","`"]
docstr: This gets called from the super class in ``pathlib.Path.__new__``.
  
  The Lightning Path overrides this to validate the instantiation in the case parts are passed in individually. In
  such a case we need to validate that all parts have the same `origin` and if not, an error is raised.
docstr_tok: ["This","gets","called","from","the","super","class","in","``","pathlib.Path.__new__","``",".","The","Lightning","Path","overrides","this","to","validate","the","instantiation","in","the","case","parts","are","passed","in","individually",".","In","such","a","case","we","need","to","validate","that","all","parts","have","the","same","`","origin","`","and","if","not",",","an","error","is","raised","."]
code: def _from_parts(cls, args: Any, **__unused) -> "Path":
      """This gets called from the super class in ``pathlib.Path.__new__``.
  
      The Lightning Path overrides this to validate the instantiation in the case parts are passed in individually. In
      such a case we need to validate that all parts have the same `origin` and if not, an error is raised.
  
      """
      if (
          args
          and isinstance(args[0], str)
          and args[0].startswith("lit://")
      ):
          parts = list(args)
          parts[0] = parts[0][len("lit://") :]
          args = (_storage_root_dir(), *parts)
  
      if (sys.version_info.major, sys.version_info.minor) < (3, 10):
          __unused.setdefault("init", True)
          new_path = super()._from_parts(args, **__unused)
      else:
          new_path = super()._from_parts(args)
  
      new_path._init_attributes()  # we use this instead of defining a __init__() method
  
      paths_from_parts = [
          part for part in args if isinstance(part, Path)
      ]
      if not paths_from_parts:
          return new_path
      top_path = paths_from_parts[0]
      origins = [part._origin for part in paths_from_parts]
      if not all(
          origins[0] == origin or origin is None for origin in origins
      ):
          raise TypeError(
              "Tried to instantiate a Lightning Path from multiple other Paths that originate from different"
              " LightningWork."
          )
      new_path._copy_properties_from(top_path)
      return new_path
  
imports: import hashlib
  import os
  import pathlib
  import shutil
  import sys
  from time import sleep
  from typing import TYPE_CHECKING, Any, List, Optional, Sequence, Union
  from fsspec import AbstractFileSystem
  from fsspec.implementations.local import LocalFileSystem
  from lightning.app.core.constants import REMOTE_STORAGE_WAIT
  from lightning.app.core.queues import BaseQueue
  from lightning.app.storage.requests import _ExistsRequest, _ExistsResponse, _GetRequest, _GetResponse
  from lightning.app.utilities.app_helpers import Logger
  from lightning.app.utilities.component import _is_flow_context
  from lightning.app.utilities.imports import _is_s3fs_available
label_desc: Use image node_id 1 for calling the Path obj's underlying member method code with example usage: obj._from_parts(cls, args) and returns: new_path, new_path