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.
+= ukraine timemap - kamangir/bolt#746
- Loading branch information
Showing
13 changed files
with
346 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
#! /usr/bin/env bash | ||
|
||
function ukraine() { | ||
ukraine_timemap "$@" | ||
} |
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,25 @@ | ||
#! /usr/bin/env bash | ||
|
||
function test_blue_geo_ukraine_timemap() { | ||
local options=$1 | ||
local do_dryrun=$(abcli_option_int "$options" dryrun 0) | ||
local do_upload=$(abcli_option_int "$options" upload 0) | ||
|
||
local object_name=ukraine-timemap-$(abcli_string_timestamp_short) | ||
|
||
abcli_eval dryrun=$do_dryrun \ | ||
ukraine_timemap ingest \ | ||
upload=$do_upload,$2 \ | ||
$object_name \ | ||
"${@:3}" | ||
|
||
abcli_publish \ | ||
as=ukraine_timemap,tar \ | ||
$object_name | ||
|
||
abcli_publish \ | ||
as=ukraine_timemap,suffix=.png \ | ||
$object_name | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#! /usr/bin/env bash | ||
|
||
function ukraine_timemap() { | ||
local task=$(abcli_unpack_keyword $1 help) | ||
|
||
if [ "$task" == "help" ]; then | ||
ukraine_timemap_browse "$@" | ||
ukraine_timemap_ingest "$@" | ||
return | ||
fi | ||
|
||
if [[ "$task" == "init" ]]; then | ||
notebooks_and_scripts "$@" | ||
return | ||
fi | ||
|
||
local function_name=ukraine_timemap_$task | ||
if [[ $(type -t $function_name) == "function" ]]; then | ||
$function_name "${@:2}" | ||
return | ||
fi | ||
|
||
abcli_log_error "-ukraine_timemap: $task: command not found." | ||
return 1 | ||
} | ||
|
||
abcli_source_path - caller,suffix=/ukraine-timemap |
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,24 @@ | ||
#! /usr/bin/env bash | ||
|
||
function ukraine_timemap_browse() { | ||
local options=$1 | ||
|
||
if [ $(abcli_option_int "$options" help 0) == 1 ]; then | ||
options="dataset|github" | ||
abcli_show_usage "ukraine_timemap browse$ABCUL[$options]" \ | ||
"browse ukraine-timemap." | ||
return | ||
fi | ||
|
||
local do_dataset=$(abcli_option_int "$options" dataset 0) | ||
local do_github=$(abcli_option_int "$options" github 0) | ||
|
||
local url="https://ukraine.bellingcat.com/" | ||
[[ "$do_github" == 1 ]] && | ||
url="https://github.com/bellingcat/ukraine-timemap" | ||
[[ "$do_dataset" == 1 ]] && | ||
url="https://bellingcat-embeds.ams3.cdn.digitaloceanspaces.com/production/ukr/timemap/api.json" | ||
|
||
abcli_browse $url | ||
|
||
} |
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,49 @@ | ||
#! /usr/bin/env bash | ||
|
||
function ukraine_timemap_ingest() { | ||
local options=$1 | ||
|
||
if [ $(abcli_option_int "$options" help 0) == 1 ]; then | ||
options="${EOP}~copy_template,dryrun,~upload$EOPE" | ||
local open_options="open$EOP,~QGIS$EOPE" | ||
abcli_show_usage "ukraine_timemap ingest$ABCUL$options$ABCUL-$EOP|<object-name>$EOPE$ABCUL$open_options" \ | ||
"ingest the latest dataset from https://github.com/bellingcat/ukraine-timemap." | ||
return | ||
fi | ||
|
||
local do_dryrun=$(abcli_option_int "$options" dryrun 0) | ||
local do_copy_template=$(abcli_option_int "$options" copy_template 1) | ||
local do_upload=$(abcli_option_int "$options" upload $(abcli_not $do_dryrun)) | ||
|
||
local object_name=$(abcli_clarify_object $2 ukraine-timemap-$(abcli_string_timestamp_short)) | ||
|
||
if [[ "$do_copy_template" == 1 ]]; then | ||
abcli_clone \ | ||
$UKRAINE_TIMEMAP_TEMPLATE \ | ||
$object_name \ | ||
~meta | ||
rm -v \ | ||
$abcli_object_root/$object_name/ukraine_timemap.* | ||
fi | ||
|
||
abcli_eval dryrun=$do_dryrun \ | ||
python3 -m blue_geo.ukraine_timemap \ | ||
ingest \ | ||
--object_name $object_name \ | ||
"${@:4}" | ||
|
||
abcli_tag set \ | ||
$object_name \ | ||
ukraine_timemap_ingest | ||
|
||
[[ "$do_upload" == 1 ]] && | ||
abcli_upload - $object_name | ||
|
||
local open_options=$3 | ||
local do_open=$(abcli_option_int "$open_options" open 0) | ||
[[ "$do_open" == 1 ]] && | ||
abcli_open $object_name \ | ||
QGIS,$open_options | ||
|
||
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,11 @@ | ||
from abcli.modules import objects | ||
from blue_geo.ukraine_timemap.functions import ingest | ||
|
||
|
||
def test_ukraine_timemap_ingest(): | ||
object_name = objects.unique_object() | ||
|
||
success, gdf = ingest(object_name) | ||
assert success | ||
|
||
assert not gdf.empty |
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,3 @@ | ||
from blue_geo import NAME | ||
|
||
NAME = f"{NAME}.ukraine_timemap" |
18 changes: 7 additions & 11 deletions
18
blue_geo/node/__main__.py → blue_geo/ukraine_timemap/__main__.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 |
---|---|---|
@@ -1,30 +1,26 @@ | ||
import argparse | ||
from blue_geo import VERSION | ||
from blue_geo.node import NAME | ||
from blue_geo.node.functions import func | ||
from blue_geo.ukraine_timemap import NAME | ||
from blue_geo.ukraine_timemap.functions import ingest | ||
from blue_geo.logger import logger | ||
from blueness.argparse.generic import sys_exit | ||
|
||
parser = argparse.ArgumentParser(NAME, description=f"{NAME}-{VERSION}") | ||
parser.add_argument( | ||
"task", | ||
type=str, | ||
help="task", | ||
help="ingest", | ||
) | ||
parser.add_argument( | ||
"--arg", | ||
type=bool, | ||
default=0, | ||
help="0|1", | ||
"--object_name", | ||
type=str, | ||
) | ||
args = parser.parse_args() | ||
|
||
success = False | ||
if args.task == "task": | ||
success = func(args.arg) | ||
if args.task == "ingest": | ||
success, _ = ingest(object_name=args.object_name) | ||
else: | ||
success = None | ||
|
||
sys_exit(logger, NAME, args.task, success) | ||
|
||
|
Oops, something went wrong.