From e1af81a7e3b28d0687dcc3ab2936139901f346b3 Mon Sep 17 00:00:00 2001 From: kamangir Date: Thu, 16 Jan 2025 22:05:53 -0800 Subject: [PATCH] help refactor - kamangir/bolt#746 --- README.md | 2 +- blue_geo/__init__.py | 2 +- blue_geo/help/catalog.py | 2 +- blue_geo/help/datacube.py | 138 ----------------------------- blue_geo/help/datacube/__init__.py | 13 +++ blue_geo/help/datacube/crop.py | 20 +++++ blue_geo/help/datacube/generate.py | 28 ++++++ blue_geo/help/datacube/get.py | 20 +++++ blue_geo/help/datacube/ingest.py | 46 ++++++++++ blue_geo/help/datacube/list.py | 29 ++++++ blue_geo/watch/README.md | 26 +++--- setup.py | 1 + 12 files changed, 173 insertions(+), 154 deletions(-) delete mode 100644 blue_geo/help/datacube.py create mode 100644 blue_geo/help/datacube/__init__.py create mode 100644 blue_geo/help/datacube/crop.py create mode 100644 blue_geo/help/datacube/generate.py create mode 100644 blue_geo/help/datacube/get.py create mode 100644 blue_geo/help/datacube/ingest.py create mode 100644 blue_geo/help/datacube/list.py diff --git a/README.md b/README.md index 16f1e89e..e30d037b 100644 --- a/README.md +++ b/README.md @@ -82,4 +82,4 @@ graph LR [![pylint](https://github.com/kamangir/blue-geo/actions/workflows/pylint.yml/badge.svg)](https://github.com/kamangir/blue-geo/actions/workflows/pylint.yml) [![pytest](https://github.com/kamangir/blue-geo/actions/workflows/pytest.yml/badge.svg)](https://github.com/kamangir/blue-geo/actions/workflows/pytest.yml) [![bashtest](https://github.com/kamangir/blue-geo/actions/workflows/bashtest.yml/badge.svg)](https://github.com/kamangir/blue-geo/actions/workflows/bashtest.yml) [![PyPI version](https://img.shields.io/pypi/v/blue-geo.svg)](https://pypi.org/project/blue-geo/) [![PyPI - Downloads](https://img.shields.io/pypi/dd/blue-geo)](https://pypistats.org/packages/blue-geo) -built by 🌀 [`blue_options-4.190.1`](https://github.com/kamangir/awesome-bash-cli), based on 🌐 [`blue_geo-4.943.1`](https://github.com/kamangir/blue-geo). +built by 🌀 [`blue_options-4.190.1`](https://github.com/kamangir/awesome-bash-cli), based on 🌐 [`blue_geo-4.944.1`](https://github.com/kamangir/blue-geo). diff --git a/blue_geo/__init__.py b/blue_geo/__init__.py index affd4ddf..d164c248 100644 --- a/blue_geo/__init__.py +++ b/blue_geo/__init__.py @@ -9,7 +9,7 @@ DESCRIPTION = f"{ICON} AI for a Blue Planet." -VERSION = "4.943.1" +VERSION = "4.944.1" REPO_NAME = "blue-geo" diff --git a/blue_geo/help/catalog.py b/blue_geo/help/catalog.py index a90b137e..23133dcf 100644 --- a/blue_geo/help/catalog.py +++ b/blue_geo/help/catalog.py @@ -3,7 +3,7 @@ from blue_options.terminal import show_usage from blue_geo.catalog import get_catalog -from blue_geo.help.datacube import ingest_options +from blue_geo.help.datacube.ingest import ingest_options from blue_geo.catalog.functions import get_datacube_class_in_catalog from blue_geo.catalog.default import as_list_of_args from blue_geo.catalog.classes import list_of_catalogs diff --git a/blue_geo/help/datacube.py b/blue_geo/help/datacube.py deleted file mode 100644 index af059e64..00000000 --- a/blue_geo/help/datacube.py +++ /dev/null @@ -1,138 +0,0 @@ -from typing import List - -from blue_options.terminal import show_usage, xtra -from blue_options import env - -from blue_geo.catalog.generic.generic.scope import DatacubeScope -from blue_geo.datacube.modalities import options as modality_options - - -def ingest_options(mono: bool) -> str: - return "".join( - [ - xtra("~copy_template,dryrun,overwrite,", mono), - "scope=", - xtra(",upload", mono), - ] - ) - - -scope_details = { - f"scope: {DatacubeScope.help}": [ - "all: ALL files.", - "metadata (default): any < 1 MB.", - "raster: all raster.", - "rgb: rgb.", - "rgbx: rgb and what is needed to build rgb.", - ": any *.", - ] -} - - -def help_crop( - tokens: List[str], - mono: bool, -) -> str: - options = "download,dryrun,suffix=" - return show_usage( - [ - "@datacube crop", - f"[{options}]", - "[..|]", - "[.|]", - ], - "crop by /target/shape.geojson -> -DERIVED-crop-.", - mono=mono, - ) - - -def help_generate( - tokens: List[str], - mono: bool, -) -> str: - options = xtra("dryrun", mono) - - args = [ - "[--modality <{}>]".format("|".join(modality_options)), - "[--overwrite <1>]", - ] - - return show_usage( - [ - "@datacube generate", - f"[{options}]", - "[.|]", - ] - + args, - "generate datacube/.", - mono=mono, - ) - - -def help_get( - tokens: List[str], - mono: bool, -) -> str: - options = "catalog|raw|template" - - return show_usage( - [ - "@datacube get", - f"[{options}]", - "[.|]", - ], - "get datacube properties.", - mono=mono, - ) - - -def help_ingest( - tokens: List[str], - mono: bool, -) -> str: - options = ingest_options(mono) - - return show_usage( - [ - "@datacube ingest", - f"[{options}]", - "[.|]", - "[]", - ], - "ingest /.", - scope_details, - mono=mono, - ) - - -def help_list( - tokens: List[str], - mono: bool, -) -> str: - args = [ - "[--count 1]", - "[--delim +]", - "[--exists 1]", - "[--log 0]", - "[--scope ]", - ] - - return show_usage( - [ - "@datacube list", - "[.|]", - ] - + args, - "list datacube files.", - scope_details, - mono=mono, - ) - - -help_functions = { - "crop": help_crop, - "generate": help_generate, - "get": help_get, - "ingest": help_ingest, - "list": help_list, -} diff --git a/blue_geo/help/datacube/__init__.py b/blue_geo/help/datacube/__init__.py new file mode 100644 index 00000000..6acc96b9 --- /dev/null +++ b/blue_geo/help/datacube/__init__.py @@ -0,0 +1,13 @@ +from blue_geo.help.datacube.crop import help_crop +from blue_geo.help.datacube.generate import help_generate +from blue_geo.help.datacube.get import help_get +from blue_geo.help.datacube.ingest import help_ingest, ingest_options, scope_details +from blue_geo.help.datacube.list import help_list + +help_functions = { + "crop": help_crop, + "generate": help_generate, + "get": help_get, + "ingest": help_ingest, + "list": help_list, +} diff --git a/blue_geo/help/datacube/crop.py b/blue_geo/help/datacube/crop.py new file mode 100644 index 00000000..3aba601e --- /dev/null +++ b/blue_geo/help/datacube/crop.py @@ -0,0 +1,20 @@ +from typing import List + +from blue_options.terminal import show_usage + + +def help_crop( + tokens: List[str], + mono: bool, +) -> str: + options = "download,dryrun,suffix=" + return show_usage( + [ + "@datacube crop", + f"[{options}]", + "[..|]", + "[.|]", + ], + "crop by /target/shape.geojson -> -DERIVED-crop-.", + mono=mono, + ) diff --git a/blue_geo/help/datacube/generate.py b/blue_geo/help/datacube/generate.py new file mode 100644 index 00000000..38de9462 --- /dev/null +++ b/blue_geo/help/datacube/generate.py @@ -0,0 +1,28 @@ +from typing import List + +from blue_options.terminal import show_usage, xtra + +from blue_geo.datacube.modalities import options as modality_options + + +def help_generate( + tokens: List[str], + mono: bool, +) -> str: + options = xtra("dryrun", mono) + + args = [ + "[--modality <{}>]".format("|".join(modality_options)), + "[--overwrite <1>]", + ] + + return show_usage( + [ + "@datacube generate", + f"[{options}]", + "[.|]", + ] + + args, + "generate datacube/.", + mono=mono, + ) diff --git a/blue_geo/help/datacube/get.py b/blue_geo/help/datacube/get.py new file mode 100644 index 00000000..202328aa --- /dev/null +++ b/blue_geo/help/datacube/get.py @@ -0,0 +1,20 @@ +from typing import List + +from blue_options.terminal import show_usage + + +def help_get( + tokens: List[str], + mono: bool, +) -> str: + options = "catalog | raw | template" + + return show_usage( + [ + "@datacube get", + f"[{options}]", + "[.|]", + ], + "get datacube properties.", + mono=mono, + ) diff --git a/blue_geo/help/datacube/ingest.py b/blue_geo/help/datacube/ingest.py new file mode 100644 index 00000000..6ddae295 --- /dev/null +++ b/blue_geo/help/datacube/ingest.py @@ -0,0 +1,46 @@ +from typing import List + +from blue_options.terminal import show_usage, xtra + +from blue_geo.catalog.generic.generic.scope import DatacubeScope + + +def ingest_options(mono: bool) -> str: + return "".join( + [ + xtra("~copy_template,dryrun,overwrite,", mono), + "scope=", + xtra(",upload", mono), + ] + ) + + +scope_details = { + f"scope: {DatacubeScope.help}": [ + "all: ALL files.", + "metadata (default): any < 1 MB.", + "raster: all raster.", + "rgb: rgb.", + "rgbx: rgb and what is needed to build rgb.", + ": any *.", + ] +} + + +def help_ingest( + tokens: List[str], + mono: bool, +) -> str: + options = ingest_options(mono) + + return show_usage( + [ + "@datacube ingest", + f"[{options}]", + "[.|]", + "[]", + ], + "ingest /.", + scope_details, + mono=mono, + ) diff --git a/blue_geo/help/datacube/list.py b/blue_geo/help/datacube/list.py new file mode 100644 index 00000000..d1c5ce9d --- /dev/null +++ b/blue_geo/help/datacube/list.py @@ -0,0 +1,29 @@ +from typing import List + +from blue_options.terminal import show_usage + +from blue_geo.help.datacube.ingest import scope_details + + +def help_list( + tokens: List[str], + mono: bool, +) -> str: + args = [ + "[--count 1]", + "[--delim +]", + "[--exists 1]", + "[--log 0]", + "[--scope ]", + ] + + return show_usage( + [ + "@datacube list", + "[.|]", + ] + + args, + "list datacube files.", + scope_details, + mono=mono, + ) diff --git a/blue_geo/watch/README.md b/blue_geo/watch/README.md index e1499775..b7f0a2ff 100644 --- a/blue_geo/watch/README.md +++ b/blue_geo/watch/README.md @@ -143,7 +143,7 @@ watch the planet's story unfold.
🌐 -[![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-Cache-Creek-2x-wider-2024-11-05/geo-watch-Cache-Creek-2x-wider-2024-11-05-4X.gif?raw=true&random=5ct05sw1brsfkzpn)](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-Cache-Creek-2x-wider-2024-11-05/geo-watch-Cache-Creek-2x-wider-2024-11-05.gif) +[![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-Cache-Creek-2x-wider-2024-11-05/geo-watch-Cache-Creek-2x-wider-2024-11-05-4X.gif?raw=true&random=p5zmhl4unsfgkkw5)](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-Cache-Creek-2x-wider-2024-11-05/geo-watch-Cache-Creek-2x-wider-2024-11-05.gif)
@@ -159,7 +159,7 @@ watch the planet's story unfold.
🌐 -[![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/DrugSuperLab-2024-12-09-ZnmC5L/DrugSuperLab-2024-12-09-ZnmC5L-4X.gif?raw=true&random=nygrh906m5n2xnzx)](https://kamangir-public.s3.ca-central-1.amazonaws.com/DrugSuperLab-2024-12-09-ZnmC5L/DrugSuperLab-2024-12-09-ZnmC5L.gif) +[![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/DrugSuperLab-2024-12-09-ZnmC5L/DrugSuperLab-2024-12-09-ZnmC5L-4X.gif?raw=true&random=3pamfnkgy3ik98tw)](https://kamangir-public.s3.ca-central-1.amazonaws.com/DrugSuperLab-2024-12-09-ZnmC5L/DrugSuperLab-2024-12-09-ZnmC5L.gif)
@@ -176,7 +176,7 @@ watch the planet's story unfold.
🌐 -[![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-2024-09-04-Fagradalsfjall-a/geo-watch-2024-09-04-Fagradalsfjall-a-2X.gif?raw=true&random=juqx14m52j02l6vj)](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-2024-09-04-Fagradalsfjall-a/geo-watch-2024-09-04-Fagradalsfjall-a.gif) +[![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-2024-09-04-Fagradalsfjall-a/geo-watch-2024-09-04-Fagradalsfjall-a-2X.gif?raw=true&random=a12q57xeuql3hdlg)](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-2024-09-04-Fagradalsfjall-a/geo-watch-2024-09-04-Fagradalsfjall-a.gif)
@@ -189,7 +189,7 @@ watch the planet's story unfold.
🌐 -[![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-Jasper-2024-11-03/geo-watch-Jasper-2024-11-03-2X.gif?raw=true&random=3mha5wjqxreivwyf)](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-Jasper-2024-11-03/geo-watch-Jasper-2024-11-03.gif) +[![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-Jasper-2024-11-03/geo-watch-Jasper-2024-11-03-2X.gif?raw=true&random=auu0rmw5xgop5pu1)](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-Jasper-2024-11-03/geo-watch-Jasper-2024-11-03.gif)
@@ -204,7 +204,7 @@ watch the planet's story unfold.
🌐 -[![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-2024-10-27-16-17-36-12059/geo-watch-2024-10-27-16-17-36-12059-4X.gif?raw=true&random=3dzry7v77dk1gmz5)](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-2024-10-27-16-17-36-12059/geo-watch-2024-10-27-16-17-36-12059.gif) +[![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-2024-10-27-16-17-36-12059/geo-watch-2024-10-27-16-17-36-12059-4X.gif?raw=true&random=reudqe6r1zabxvnw)](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-2024-10-27-16-17-36-12059/geo-watch-2024-10-27-16-17-36-12059.gif)
@@ -222,7 +222,7 @@ watch the planet's story unfold.
🌐 -[![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-2024-09-04-Mount-Etna-a/geo-watch-2024-09-04-Mount-Etna-a-2X.gif?raw=true&random=0tk0c3qhks5epm91)](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-2024-09-04-Mount-Etna-a/geo-watch-2024-09-04-Mount-Etna-a.gif) +[![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-2024-09-04-Mount-Etna-a/geo-watch-2024-09-04-Mount-Etna-a-2X.gif?raw=true&random=bf6sqwexcih6ybwi)](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-2024-09-04-Mount-Etna-a/geo-watch-2024-09-04-Mount-Etna-a.gif)
@@ -235,7 +235,7 @@ watch the planet's story unfold.
🌐 -[![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/Palisades-Sentinel-2-2025-01-15-16-50-38-vyjxu8/Palisades-Sentinel-2-2025-01-15-16-50-38-vyjxu8-2X.gif?raw=true&random=vvijb09dq1mdht55)](https://kamangir-public.s3.ca-central-1.amazonaws.com/Palisades-Sentinel-2-2025-01-15-16-50-38-vyjxu8/Palisades-Sentinel-2-2025-01-15-16-50-38-vyjxu8.gif) +[![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/Palisades-Sentinel-2-2025-01-15-16-50-38-vyjxu8/Palisades-Sentinel-2-2025-01-15-16-50-38-vyjxu8-2X.gif?raw=true&random=h57evtu18lvswx1b)](https://kamangir-public.s3.ca-central-1.amazonaws.com/Palisades-Sentinel-2-2025-01-15-16-50-38-vyjxu8/Palisades-Sentinel-2-2025-01-15-16-50-38-vyjxu8.gif)
@@ -249,7 +249,7 @@ watch the planet's story unfold.
🌐 -[![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/Sheerness-20x-2024-12-14-EDkXl0/Sheerness-20x-2024-12-14-EDkXl0-4X.gif?raw=true&random=l7f8mb7jr0i98jj5)](https://kamangir-public.s3.ca-central-1.amazonaws.com/Sheerness-20x-2024-12-14-EDkXl0/Sheerness-20x-2024-12-14-EDkXl0.gif) +[![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/Sheerness-20x-2024-12-14-EDkXl0/Sheerness-20x-2024-12-14-EDkXl0-4X.gif?raw=true&random=o0tdn27mqmgefx2c)](https://kamangir-public.s3.ca-central-1.amazonaws.com/Sheerness-20x-2024-12-14-EDkXl0/Sheerness-20x-2024-12-14-EDkXl0.gif)
@@ -262,7 +262,7 @@ watch the planet's story unfold.
🌐 -[![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-Silver-Peak-2024-10-12-a/geo-watch-Silver-Peak-2024-10-12-a-4X.gif?raw=true&random=aeqvlk56nrsobg8k)](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-Silver-Peak-2024-10-12-a/geo-watch-Silver-Peak-2024-10-12-a.gif) +[![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-Silver-Peak-2024-10-12-a/geo-watch-Silver-Peak-2024-10-12-a-4X.gif?raw=true&random=mgbwyckd59o5tj0q)](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-Silver-Peak-2024-10-12-a/geo-watch-Silver-Peak-2024-10-12-a.gif)
@@ -276,7 +276,7 @@ watch the planet's story unfold.
🌐 -[![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/bellingcat-2024-09-27-nagorno-karabakh-6X-2024-12-14-EUUpS1/bellingcat-2024-09-27-nagorno-karabakh-6X-2024-12-14-EUUpS1-4X.gif?raw=true&random=mcvsfvi0u31qwqvm)](https://kamangir-public.s3.ca-central-1.amazonaws.com/bellingcat-2024-09-27-nagorno-karabakh-6X-2024-12-14-EUUpS1/bellingcat-2024-09-27-nagorno-karabakh-6X-2024-12-14-EUUpS1.gif) +[![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/bellingcat-2024-09-27-nagorno-karabakh-6X-2024-12-14-EUUpS1/bellingcat-2024-09-27-nagorno-karabakh-6X-2024-12-14-EUUpS1-4X.gif?raw=true&random=a8w8mm6g6s7d1472)](https://kamangir-public.s3.ca-central-1.amazonaws.com/bellingcat-2024-09-27-nagorno-karabakh-6X-2024-12-14-EUUpS1/bellingcat-2024-09-27-nagorno-karabakh-6X-2024-12-14-EUUpS1.gif)
@@ -293,7 +293,7 @@ watch the planet's story unfold.
🌐 -[![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-2024-09-04-burning-man-2024-a/geo-watch-2024-09-04-burning-man-2024-a-2X.gif?raw=true&random=myusihzy9iofqz0x)](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-2024-09-04-burning-man-2024-a/geo-watch-2024-09-04-burning-man-2024-a.gif) +[![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-2024-09-04-burning-man-2024-a/geo-watch-2024-09-04-burning-man-2024-a-2X.gif?raw=true&random=0y1xt69fcgdo84zj)](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-2024-09-04-burning-man-2024-a/geo-watch-2024-09-04-burning-man-2024-a.gif)
@@ -305,7 +305,7 @@ watch the planet's story unfold.
🌐 -[![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-Chilcotin-2024-11-03/geo-watch-Chilcotin-2024-11-03-4X.gif?raw=true&random=iuh8bvbty4shwbxr)](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-Chilcotin-2024-11-03/geo-watch-Chilcotin-2024-11-03.gif) +[![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-Chilcotin-2024-11-03/geo-watch-Chilcotin-2024-11-03-4X.gif?raw=true&random=3j0g4qj8hvpqrvos)](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-Chilcotin-2024-11-03/geo-watch-Chilcotin-2024-11-03.gif)
@@ -325,7 +325,7 @@ watch the planet's story unfold.
🌐 -[![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/elkhema-2024-12-15-8EqPXl/elkhema-2024-12-15-8EqPXl-4X.gif?raw=true&random=7dgt5i4hp45n6lkz)](https://kamangir-public.s3.ca-central-1.amazonaws.com/elkhema-2024-12-15-8EqPXl/elkhema-2024-12-15-8EqPXl.gif) +[![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/elkhema-2024-12-15-8EqPXl/elkhema-2024-12-15-8EqPXl-4X.gif?raw=true&random=syzblq6aj3w0rnp8)](https://kamangir-public.s3.ca-central-1.amazonaws.com/elkhema-2024-12-15-8EqPXl/elkhema-2024-12-15-8EqPXl.gif)
diff --git a/setup.py b/setup.py index b7eca9d7..c83c7f08 100644 --- a/setup.py +++ b/setup.py @@ -31,6 +31,7 @@ f"{NAME}.datacube", # f"{NAME}.help", + f"{NAME}.help.datacube", f"{NAME}.help.watch", f"{NAME}.help.QGIS", #