Skip to content

Commit

Permalink
fix: use the root folder define in fixture (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
12rambau authored Dec 18, 2023
2 parents ef38ba8 + 180b7ea commit f967c10
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pytest_gee/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ def export_asset(
return PurePosixPath(asset_id)


def init_tree(structure: dict, prefix: str, root: str) -> PurePosixPath:
def init_tree(
structure: dict, prefix: str, root: Union[str, PurePosixPath]
) -> PurePosixPath:
"""Create an EarthEngine folder tree from a dictionary.
The input ditionary should described the structure of the folder you want to create.
Expand Down Expand Up @@ -159,8 +161,8 @@ def _recursive_create(structure, prefix, folder):
export_asset(content, asset_id, description)

# create the root folder
root = ee.data.getAssetRoots()[0]["id"]
root_folder = f"{root}/{prefix}"
root = PurePosixPath(root) if isinstance(root, str) else root
root_folder = f"{root.as_posix()}/{prefix}"
ee.data.createAsset({"type": "FOLDER"}, root_folder)

# start the recursive function
Expand Down

0 comments on commit f967c10

Please sign in to comment.