MCPcopy
hub / github.com/google/earthengine-api / run

Method run

python/ee/cli/commands.py:987–1021  ·  view source on GitHub ↗

Runs the du command.

(
      self, args: argparse.Namespace, config: utils.CommandLineConfig
  )

Source from the content-addressed store, hash-verified

985 help='Display only a total.')
986
987 def run(
988 self, args: argparse.Namespace, config: utils.CommandLineConfig
989 ) -> None:
990 """Runs the du command."""
991 config.ee_init()
992
993 # Select all available asset roots if no asset ids are given.
994 if not args.asset_id:
995 assets = ee.data.getAssetRoots()
996 else:
997 assets = [ee.data.getInfo(asset) for asset in args.asset_id]
998
999 # If args.summarize is True, list size+name for every leaf child asset,
1000 # and show totals for non-leaf children.
1001 # If args.summarize is False, print sizes of all children.
1002 for index, asset in enumerate(assets):
1003 if args.asset_id and not asset:
1004 asset_id = args.asset_id[index]
1005 print('Asset does not exist or is not accessible: %s' % asset_id)
1006 continue
1007 is_parent = asset['type'] in (
1008 ee.data.ASSET_TYPE_FOLDER,
1009 ee.data.ASSET_TYPE_IMAGE_COLL,
1010 ee.data.ASSET_TYPE_FOLDER_CLOUD,
1011 ee.data.ASSET_TYPE_IMAGE_COLL_CLOUD,
1012 )
1013 if not is_parent or args.summarize:
1014 self._print_size(asset)
1015 else:
1016 children = ee.data.getList({'id': asset['id']})
1017 if not children:
1018 # A leaf asset
1019 children = [asset]
1020 for child in children:
1021 self._print_size(child)
1022
1023 def _print_size(self, asset):
1024 size = self._get_size(asset)

Callers

nothing calls this directly

Calls 3

_print_sizeMethod · 0.95
ee_initMethod · 0.80
getInfoMethod · 0.45

Tested by

no test coverage detected