You are viewing v0.0.12 version. Click here to see docs for the latest stable version.

Resource

Resources are the Runhouse abstraction for objects that can be saved, shared, and reused.

Resource Class

class runhouse.resources.resource.Resource(name: Optional[str] = None, dryrun: Optional[bool] = None, provenance=None, **kwargs)[source]
__init__(name: Optional[str] = None, dryrun: Optional[bool] = None, provenance=None, **kwargs)[source]

Runhouse abstraction for objects that can be saved, shared, and reused.

Runhouse currently supports the following builtin Resource types:

delete_configs()[source]

Delete the resource’s config from local working_dir and RNS config store.

classmethod from_name(name, dryrun=False, alt_options=None)[source]

Load existing Resource via its name.

history(num_entries: Optional[int] = None) List[Dict][source]

Return the history of the resource, including specific config fields (e.g. blob path) and which runs have overwritten it.

pin()[source]

Write the resource to the object store.

refresh()[source]

Update the resource in the object store.

property rns_address

Traverse up the filesystem until reaching one of the directories in rns_base_folders, then compute the relative path to that.

Maybe later, account for folders along the path with a different RNS name.

save(name: Optional[str] = None, overwrite: bool = True)[source]

Register the resource, saving it to local working_dir config and RNS config store. Uses the resource’s self.config_for_rns to generate the dict to save.

save_attrs_to_config(config: Dict, attrs: List[str])[source]

Save the given attributes to the config

share(users: list, access_type: Union[ResourceAccess, str] = ResourceAccess.READ, notify_users: bool = True, headers: Optional[Dict] = None) Tuple[Dict[str, ResourceAccess], Dict[str, ResourceAccess]][source]

Grant access to the resource for the list of users. If a user has a Runhouse account they will receive an email notifying them of their new access. If the user does not have a Runhouse account they will also receive instructions on creating one, after which they will be able to have access to the Resource.

Note

You can only grant resource access to other users if you have Write / Read privileges for the Resource.

Parameters:
  • users (list) – list of user emails and / or runhouse account usernames.

  • access_type (ResourceAccess, optional) – access type to provide for the resource.

  • notify_users (bool) – Send email notification to users who have been given access. Defaults to False.

  • headers (Optional[Dict]) – Request headers to provide for the request to RNS. Contains the user’s auth token. Example: {"Authorization": f"Bearer {token}"}

Returns:

added_users:

users who already have an account and have been granted access to the resource.

new_users:

users who do not have Runhouse accounts.

Return type:

Tuple(Dict, Dict)

Example

>>> added_users, new_users = my_resource.share(users=["username1", "user2@gmail.com"], access_type='write')
unname()[source]

Remove the name of the resource. This changes the resource name to anonymous and deletes any local or RNS configs for the resource.