generated from kamangir/blue-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
190 additions
and
95 deletions.
There are no files selected for viewing
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
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
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
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
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,28 @@ | ||
#! /usr/bin/env bash | ||
|
||
function blue_geo_catalog_query_firms_area() { | ||
local options=$1 | ||
|
||
local catalog="firms" | ||
local collection="area" | ||
|
||
if [ $(abcli_option_int "$options" help 0) == 1 ]; then | ||
options="$collection,dryrun" | ||
local args=$(python3 -m blue_geo.catalog.$catalog.$collection get --what list_of_args) | ||
abcli_show_usage "@catalog query $catalog$ABCUL[$blue_geo_catalog_query_options]$ABCUL[-|<object-name>]$ABCUL[$options]$ABCUL$args" \ | ||
"$catalog -query-> <object-name>." | ||
return | ||
fi | ||
|
||
local do_dryrun=$(abcli_option_int "$options" dryrun 0) | ||
|
||
local object_name=$(abcli_clarify_object $2 -) | ||
|
||
abcli_eval dryrun=$do_dryrun \ | ||
python3 -m blue_geo.catalog.$catalog.$collection \ | ||
query \ | ||
--object_name $object_name \ | ||
"${@:3}" | ||
|
||
return 0 | ||
} |
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
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
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,29 @@ | ||
from argparse import ArgumentParser | ||
from typing import Dict | ||
|
||
|
||
def add_default_arguments( | ||
default_args: Dict[str, Dict], | ||
parser: ArgumentParser, | ||
): | ||
for arg, values in default_args.items(): | ||
parser.add_argument( | ||
f"--{arg}", | ||
type=values.get("type", str), | ||
default=values["default"], | ||
help=values["help"], | ||
) | ||
|
||
|
||
def as_list_of_args(default_args: Dict[str, Dict]) -> str: | ||
return "$ABCUL".join( | ||
sorted( | ||
[ | ||
"--{} {}".format( | ||
arg, | ||
values["help"], | ||
) | ||
for arg, values in default_args.items() | ||
] | ||
) | ||
) |
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,30 @@ | ||
import argparse | ||
from blueness import module | ||
from blue_geo import NAME, VERSION | ||
from blue_geo.catalog import get_datacube | ||
from blue_geo.logger import logger | ||
from blueness.argparse.generic import sys_exit | ||
|
||
NAME = module.name(__file__, NAME) | ||
|
||
parser = argparse.ArgumentParser(NAME, description=f"{NAME}-{VERSION}") | ||
parser.add_argument( | ||
"task", | ||
type=str, | ||
help="ingest", | ||
) | ||
parser.add_argument( | ||
"--object_name", | ||
type=str, | ||
) | ||
args = parser.parse_args() | ||
|
||
|
||
success = False | ||
if args.task == "ingest": | ||
datacube = get_datacube(datacube_id=args.object_name) | ||
success, _ = datacube.ingest(object_name=args.object_name) | ||
else: | ||
success = None | ||
|
||
sys_exit(logger, NAME, args.task, success) |
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
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
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,23 @@ | ||
from typing import Dict | ||
from blue_geo.catalog.firms.area.enums import Area, Source | ||
from datetime import datetime, timedelta | ||
|
||
args: Dict[str, Dict] = { | ||
"area": { | ||
"default": Area.default().name, | ||
"help": "|".join(Area.values()), | ||
}, | ||
"date": { | ||
"default": (datetime.now() - timedelta(days=5)).strftime("%Y-%m-%d"), | ||
"help": "yyyy-mm-dd", | ||
}, | ||
"depth": { | ||
"type": int, | ||
"default": 1, | ||
"help": "1..10", | ||
}, | ||
"source": { | ||
"default": Source.default().name, | ||
"help": "|".join(Source.values()), | ||
}, | ||
} |
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 |
---|---|---|
@@ -1,5 +1,11 @@ | ||
from blueness import module | ||
from blue_geo import NAME | ||
from blue_geo.catalog.generic import GenericCatalog | ||
from blue_geo.logger import logger | ||
|
||
NAME = module.name(__file__, NAME) | ||
|
||
|
||
class FirmsCatalog(GenericCatalog): | ||
name = "firms" | ||
collections = ["area"] |
Oops, something went wrong.