pytest_gee.utils#
functions used to build the API that we don’t want to expose to end users.
Danger
This module is for internal use only and should not be used directly.
Attributes#
Functions#
|
Create a container for the asset request depending on the requested type. |
|
Generate a fullpath from parameters of the test. |
|
Check if the serialized GEE object is the same as the saved one. |
|
Delete the selected asset and all its content. |
|
Export assets to the GEE platform, only working for very simple objects. |
|
Get all the assets from the parameter folder. every nested asset will be displayed. |
|
Search for the described task in the user Task list return None if nothing is found. |
|
Create an EarthEngine folder tree from a dictionary. |
|
Recusrsively Round the values of a list to the given prescision. |
|
Wait until the selected process is finished or we reached timeout value. |
Module Contents#
- pytest_gee.utils._create_container(asset_request)[source]#
Create a container for the asset request depending on the requested type.
- pytest_gee.utils.build_fullpath(datadir, request, extension, basename=None, fullpath=None, with_test_class_names=False)[source]#
Generate a fullpath from parameters of the test.
- Parameters:
datadir (pathlib.Path) – Fixture embed_data.
request (pytest.FixtureRequest) – Pytest request object.
extension (str) – Extension of files compared by this check.
basename (Optional[str]) – basename of the file to test/record. If not given the name of the test is used. Use either basename or fullpath.
fullpath (Optional[os.PathLike[str]]) – complete path to use as a reference file. This option will ignore
datadirfixture when reading expected files but will still use it to write obtained files. Useful if a reference file is located in the session data dir for example.with_test_class_names (bool) – if true it will use the test class name (if any) to compose the basename.
- Return type:
- pytest_gee.utils.check_serialized(object, path, datadir, original_datadir, request, force_regen=False, with_test_class_names=False)[source]#
Check if the serialized GEE object is the same as the saved one.
- Parameters:
object (ee.ComputedObject) – the earthnegine object to check
path (pathlib.Path) – the full path to the file to check against.
datadir (pathlib.Path) – Fixture embed_data.
original_datadir (pathlib.Path) – Fixture embed_data.
request (pytest.FixtureRequest) – Pytest request object.
force_regen (bool) – if True, the file will be regenerated even if it exists.
with_test_class_names (bool) – if true it will use the test class name (if any) to compose the basename.
- Raises:
AssertionError if the serialized object is different from the saved one. –
- pytest_gee.utils.delete_assets(asset_id, dry_run=True)[source]#
Delete the selected asset and all its content.
This method will delete all the files and folders existing in an asset folder. By default a dry run will be launched and if you are satisfyed with the displayed names, change the
dry_runvariable toFalse. No other warnng will be displayed.Warning
If this method is used on the root directory you will loose all your data, it’s highly recommended to use a dry run first and carefully review the destroyed files.
- Parameters:
asset_id (Union[str, pathlib.Path]) – the Id of the asset or a folder
dry_run (bool) – whether or not a dry run should be launched. dry run will only display the files name without deleting them.
- Returns:
a list of all the files deleted or to be deleted
- Return type:
- pytest_gee.utils.export_asset(object, asset_id, description)[source]#
Export assets to the GEE platform, only working for very simple objects.
- Parameters:
object (ee.ComputedObject) – the object to export
asset_id (Union[str, pathlib.Path]) – the name of the asset to create
description (str) – the description of the task
- Returns:
the path of the created asset
- Return type:
- pytest_gee.utils.get_assets(folder)[source]#
Get all the assets from the parameter folder. every nested asset will be displayed.
- Parameters:
folder (Union[str, pathlib.Path]) – the initial GEE folder
- Returns:
‘type’, ‘name’ and ‘id’
- Return type:
the asset list. each asset is a dict with 3 keys
- pytest_gee.utils.get_task(task_descripsion)[source]#
Search for the described task in the user Task list return None if nothing is found.
- Parameters:
task_descripsion (str) – the task description
- Returns:
return the found task else None
- Return type:
Optional[ee.batch.Task]
- pytest_gee.utils.init_tree(structure, prefix, root)[source]#
Create an EarthEngine folder tree from a dictionary.
The input ditionary should described the structure of the folder you want to create. The keys are the folder names and the values are the subfolders. Once you reach an
ee.FeatureCollectionand/or anee.Imageset it in the dictionary and the function will export the object.- Parameters:
structure (dict) – the structure of the folder to create
prefix (str) – the prefix to use on every item (folder, tasks, asset_id, etc.)
root (Union[str, pathlib.PurePosixPath]) – the root folder of the test where to create the test folder.
- Returns:
the path of the created folder
- Return type:
Examples
>>> structure = { ... "folder_1": { ... "image": ee.image(1), ... "fc": ee.FeatureCollection(ee.Geometry.Point([0, 0])), ... }, ... } ... init_tree(structure, "toto")
- pytest_gee.utils.round_data(data, prescision=6)[source]#
Recusrsively Round the values of a list to the given prescision.