Resources are the Runhouse abstraction for objects that can be saved, shared, and reused.
- __init__(name: str | None = None, dryrun: bool = False, access_level: ResourceAccess = ResourceAccess.WRITE, visibility: ResourceVisibility = ResourceVisibility.PRIVATE, **kwargs)[source]
Runhouse abstraction for objects that can be saved, shared, and reused.
- Parameters:
name (Optional[str], optional) – Name to assign the resource. (Default: None)
dryrun (bool, optional) – Whether to create the resource object, or load the object as a dryrun. (Default:
False
)access_level (
ResourceAccess
, optional) – Access level to provide for the resource. (Default:ResourceAccess.WRITE
)visibility (
ResourceVisibility
, optional) – Type of visibility to provide for the resource. (Default:ResourceVisibility.PRIVATE
)
Delete the resource’s config from local working_dir and RNS config store.
Load or construct resource from config.
config (Dict) – Resource config.
dryrun (bool, optional) – Whether to construct resource or load as dryrun (Default: False
)
Load existing Resource via its name.
name (str) – Name of the resource to load from name.
load_from_den (bool, optional) – Whether to try loading the module from Den. (Default: True
)
dryrun (bool, optional) – Whether to construct the object or load as dryrun. (Default: False
)
Return the history of the resource, including specific config fields (e.g. folder path) and which runs have overwritten it.
limit (int, optional) – If specified, return the last limit
number of entries in the history.
Otherwise, return the entire history. (Default: None
)
Write the resource to the object store.
Update the resource in the object store.
Revoke access to the resource.
users (Union[str, str], optional) – List of user emails and / or runhouse account usernames
(or a single user). If no users are specified will revoke access for all users. (Default: None
)
headers (Optional[Dict]) – Request headers to provide for the request to RNS. Contains the user’s auth token.
Example: {"Authorization": f"Bearer {token}"}
Traverse up the filesystem until reaching one of the directories in rns_base_folders, then compute the relative path to that.
Register the resource, saving it to local working_dir config and RNS config store. Uses the resource’s self.config() to generate the dict to save.
Save the given attributes to the config
Grant access to the resource for a list of users (or a single user). By default, the user will
receive an email notification of access (if they have a Runhouse account) or instructions on creating
an account to access the resource. If visibility
is set to public
, users will not be notified.
Note
You can only grant access to other users if you have write access to the resource.
users (Union[str, list], optional) – Single user or list of user emails and / or runhouse account usernames.
If none are provided and visibility
is set to public
, resource will be made publicly
available to all users. (Default: None
)
access_level (ResourceAccess
, optional) – Access level to provide for the resource.
(Default: read
).
visibility (ResourceVisibility
, optional) – Type of visibility to provide for the shared
resource. By default, the visibility is private. (Default: None
)
notify_users (bool, optional) – Whether to send an email notification to users who have been given access.
Note: This is relevant for resources which are not shareable
. (Default: True
)
headers (Dict, optional) – Request headers to provide for the request to RNS. Contains the user’s auth token.
Example: {"Authorization": f"Bearer {token}"}
Users who already have a Runhouse account and have been granted access to the resource.
Users who do not have Runhouse accounts and received notifications via their emails.
Set of valid usernames and emails from users
parameter.
Tuple(Dict, Dict, Set)
Example
>>> # Write access to the resource for these specific users. >>> # Visibility will be set to private (users can search for and view resource in Den dashboard) >>> my_resource.share(users=["username1", "user2@gmail.com"], access_level='write')
>>> # Make resource public, with read access to the resource for all users >>> my_resource.share(visibility='public')
Remove the name of the resource. This changes the resource name to anonymous and deletes any local or RNS configs for the resource.