A Folder represents a specified location for organizing and storing other Runhouse primitives across various systems.
Creates a Runhouse folder object, which can be used to interact with the folder at the given path.
name (Optional[str]) – Name to give the folder, to be re-used later on.
path (Optional[str or Path]) – Path (or path) that the folder is located at.
system (Optional[str or Cluster]) – File system or cluster name. If providing a file system this must be one of:
We are working to add additional file system support.
dryrun (bool) – Whether to create the Folder if it doesn’t exist, or load a Folder object as a dryrun.
local_mount (bool) – Whether or not to mount the folder locally. (Default:
data_config (Optional[Dict]) – The data config to pass to the underlying fsspec handler.
The resulting folder.
Returns a new Folder object pointing to the destination folder.
Generate the FSSpec URL using the file system and path of the folder
Locate the local path of a Folder given an rns path.
List the contents of the folder.
full_paths (Optional[bool]) – Whether to list the full paths of the folder contents.
sort (Optional[bool]) – Whether to sort the folder contents by time modified.
Mount the folder locally.
remote_folder = rh.folder(“folder/path”, system=”s3”) local_mount = remote_folder.mount()
Move the folder to a new filesystem or cluster.
Returns an fsspec file, which must be used as a content manager to be opened.
Put given contents in folder.
contents (Dict[str, Any] or Resource or List[Resource]) – Contents to put in folder. Must be a dict with keys being the file names (without full paths) and values being the file-like objects to write, or a Resource object, or a list of Resources.
overwrite (bool) – Whether to dump the file contents as json. By default expects data to be encoded.
mode (Optional(str)) – Write mode to use for fsspec. Defaults to
write_fn (Optional(Callable)) – Function to use for writing file contents. Example: ``write_fn = lambda f, data: json.dump(data, f)
Delete a folder from the file system. Optionally provide a list of folder contents to delete.
contents (Optional[List]) – Specific contents to delete in the folder.
recursive (bool) – Delete the folder itself (including all its contents).
Traverse up the filesystem until reaching one of the directories in rns_base_folders, then compute the relative path to that.
Copy the folder to a new filesystem, and return a new Folder object pointing to the new location.