-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(asset_mapper) : all assets available
__update_asset_mapper_config_json.py now enable users (or best the developper of this library) to update each predefined collection assets to fasten query.
- Loading branch information
nicolasK
committed
Dec 15, 2023
1 parent
2461bb7
commit e76818f
Showing
4 changed files
with
736 additions
and
163 deletions.
There are no files selected for viewing
15 changes: 10 additions & 5 deletions
15
earthdaily/earthdatastore/cube_utils/asset_mapper/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
earthdaily/earthdatastore/cube_utils/asset_mapper/__update_asset_mapper_config_json.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Fri Dec 15 09:03:08 2023 | ||
@author: nkk | ||
""" | ||
|
||
import earthdaily | ||
import json | ||
|
||
eds = earthdaily.earthdatastore.Auth() | ||
asset_mapper_path = ( | ||
earthdaily.earthdatastore.cube_utils.asset_mapper.__asset_mapper_config_path | ||
) | ||
asset_mapper_config = ( | ||
earthdaily.earthdatastore.cube_utils.asset_mapper.__asset_mapper_config | ||
) | ||
|
||
for collection in eds.explore(): | ||
try: | ||
assets_name = list(eds.explore(collection).item.assets.keys()) | ||
except AttributeError: | ||
print(f"collection {collection} has no items") | ||
continue | ||
for asset_name in assets_name: | ||
if asset_mapper_config.get(collection) is None: | ||
asset_mapper_config[collection] = [{}] | ||
if asset_name not in asset_mapper_config[collection][0].values(): | ||
asset_mapper_config[collection][0][asset_name] = asset_name | ||
|
||
with open(asset_mapper_path, "w", encoding="utf-8") as f: | ||
json.dump(asset_mapper_config, f, ensure_ascii=False, indent=4) |
158 changes: 0 additions & 158 deletions
158
earthdaily/earthdatastore/cube_utils/asset_mapper/_asset_mapper_config.py
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.