geeViz.migrateGEEAssets¶
Recursively migrate Google Earth Engine assets from one repository to another, manage their permissions, and (optionally) delete the originals.
Requirements — the credential you use must either:
have editor permissions in both the source and destination repositories, OR
have editor permissions in the destination repository AND be willing to change the permissions of all original assets to “Anyone Can Read” (set
changePermissions = Truein the__main__block below).
Usage: edit the sourceRoot / destinationRoot / permission variables
at the bottom of this file, then run it directly:
$ python -m geeViz.migrateGEEAssets
Importing this module (as autodoc / other tooling does) is a no-op — the
migration logic only executes under the if __name__ == "__main__": guard.
- Written by:
Ian Housman ian.housman@usda.gov / ian.housman@gmail.com Leah Campbell leah.campbell@usda.gov / leahs.campbell@gmail.com RedCastle Resources Inc. (MIT License)
Functions
|
Sets permissions for all files under a specified root level or for a provided list of assets. |
|
Copies all folders, imageCollections, images, and tables under a given folder or imageCollection level. |
|
Deletes all folders, imageCollections, images, and tables under a given folder or imageCollection level. |
|
Recursively gets all folders, imageCollections, images, and tables under a given folder or imageCollection level. |
- geeViz.migrateGEEAssets.getTree(fromRoot, toRoot, treeList=[])[source]¶
Recursively gets all folders, imageCollections, images, and tables under a given folder or imageCollection level.
- Parameters:
fromRoot (str) – The source root asset path.
toRoot (str) – The destination root asset path.
treeList (list, optional) – List to accumulate results.
- Returns:
List of [type, fromID, toID] for all assets found.
- Return type:
list
Example
>>> getTree('users/source/folder', 'users/dest/folder')
- geeViz.migrateGEEAssets.batchChangePermissions(assetList=None, root=None, readers=[], writers=[], all_users_can_read=False)[source]¶
Sets permissions for all files under a specified root level or for a provided list of assets.
- Parameters:
assetList (list, optional) – List of asset IDs to change permissions for.
root (str, optional) – Root asset path to start from if assetList not provided.
readers (list, optional) – List of readers.
writers (list, optional) – List of writers.
all_users_can_read (bool, optional) – If True, anyone can read.
- Returns:
None
Example
>>> batchChangePermissions(root='users/youruser/folder', writers=['user:someone@gmail.com'])
- geeViz.migrateGEEAssets.copyAssetTree(fromRoot, toRoot, changePermissions=False, readers=[], writers=[], all_users_can_read=False)[source]¶
Copies all folders, imageCollections, images, and tables under a given folder or imageCollection level.
- Parameters:
fromRoot (str) – Source root asset path.
toRoot (str) – Destination root asset path.
changePermissions (bool, optional) – Whether to change permissions after copy.
readers (list, optional) – List of readers for permissions.
writers (list, optional) – List of writers for permissions.
all_users_can_read (bool, optional) – If True, anyone can read.
- Returns:
None
Example
>>> copyAssetTree('users/source/folder', 'users/dest/folder', changePermissions=True)