code: def _filesystem_from_str(uri):
      # instantiate the file system from an uri, if the uri has a path
      # component then it will be treated as a path prefix
      filesystem, prefix = FileSystem.from_uri(uri)
      prefix = filesystem.normalize_path(prefix)
      if prefix:
          # validate that the prefix is pointing to a directory
          prefix_info = filesystem.get_file_info([prefix])[0]
          if prefix_info.type != FileType.Directory:
              raise ValueError(
                  "The path component of the filesystem URI must point to a "
                  "directory but it has a type: `{}`. The path component "
                  "is `{}` and the given filesystem URI is `{}`".format(
                      prefix_info.type.name, prefix_info.path, uri
                  )
              )
          filesystem = SubTreeFileSystem(prefix, filesystem)
      return filesystem
  
imports: from pyarrow.util import _is_path_like, _stringify_path
  from pyarrow._fs import FileSelector, FileType, FileInfo, FileSystem, LocalFileSystem, SubTreeFileSystem, _MockFileSystem, FileSystemHandler, PyFileSystem, _copy_files, _copy_files_selector
label_desc: Use image node_id 2 for calling a global function with example usage: _filesystem_from_str(uri) and returns: filesystem