Skip to content

Commit

Permalink
Refactor - kamangir/bolt#746
Browse files Browse the repository at this point in the history
  • Loading branch information
kamangir committed May 26, 2024
1 parent 195cc34 commit 9b3a023
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 31 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ __pycache__
.DS_Store
*.egg-info
*.log
, .json
, .json
dist
6 changes: 1 addition & 5 deletions hubblescope/.abcli/aka.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#! /usr/bin/env bash

function hubble() {
abcli_hubble "$@"
}

function hubblescope() {
abcli_hubble "$@"
hubble "$@"
}
8 changes: 4 additions & 4 deletions hubblescope/.abcli/download.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /usr/bin/env bash

function abcli_hubble_download() {
function hubble_download() {
local options=$1

if [ $(abcli_option_int "$options" help 0) == 1 ]; then
Expand All @@ -21,8 +21,8 @@ function abcli_hubble_download() {
local hubble_object_name=$(abcli_clarify_object "$2" . hubble_object)
local object_name=$(abcli_clarify_object "$3" .)

local auth=$(abcli_hubble_get auth $dataset_name)
local s3_uri=$(abcli_hubble_get s3_uri $dataset_name $hubble_object_name)
local auth=$(hubble_get auth $dataset_name)
local s3_uri=$(hubble_get s3_uri $dataset_name $hubble_object_name)

local command_line
if [ "$filename" == all ]; then
Expand Down Expand Up @@ -53,7 +53,7 @@ function abcli_hubble_download() {

[[ "$do_ingest" == 1 ]] &&
abcli_eval dryrun=$do_dryrun \
python3 -m hubble ingest \
python3 -m hubblescope ingest \
--dataset_name $dataset_name \
--hubble_object_name $hubble_object_name \
--object_name $object_name
Expand Down
4 changes: 2 additions & 2 deletions hubblescope/.abcli/get.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env bash

function abcli_hubble_get() {
python3 -m hubble get \
function hubble_get() {
python3 -m hubblescope get \
--what "$1" \
--dataset_name "$2" \
--object_name "$3" \
Expand Down
6 changes: 3 additions & 3 deletions hubblescope/.abcli/hubble.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ function abcli_hubble() {
local task=$(abcli_unpack_keyword $1 help)

if [ $task == "help" ]; then
abcli_hubble_download "$@"
abcli_hubble_list "$@"
abcli_hubble_select "$@"
hubble_download "$@"
hubble_list "$@"
hubble_select "$@"
return
fi

Expand Down
12 changes: 6 additions & 6 deletions hubblescope/.abcli/list.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#! /usr/bin/env bash
function abcli_hubble_ls() {
abcli_hubble_list "$@"
function hubble_ls() {
hubble_list "$@"
}

function abcli_hubble_list() {
function hubble_list() {
local task=$1

if [ "$task" == help ]; then
Expand Down Expand Up @@ -40,7 +40,7 @@ function abcli_hubble_list() {
thing_type=object
thing_name=$abcli_hubble_object_name
suffix="${@:2}"
elif [[ $(abcli_hubble_is_dataset $thing_type) == 1 ]]; then
elif [[ $(hubble_is_dataset $thing_type) == 1 ]]; then
thing_type=dataset
thing_name=${1:-.}
suffix="${@:2}"
Expand All @@ -60,13 +60,13 @@ function abcli_hubble_list() {

abcli_log "🔭 $dataset_name :: $object_name"

local s3_uri=$(abcli_hubble_get s3_uri $dataset_name $object_name)
local s3_uri=$(hubble_get s3_uri $dataset_name $object_name)
[[ ! -z "$suffix" ]] && s3_uri=$s3_uri$suffix
abcli_log "🔗 $s3_uri"

# https://registry.opendata.aws/hst/
abcli_eval - \
"aws s3 ls \
$(abcli_hubble_get auth $dataset_name) \
$(hubble_get auth $dataset_name) \
$s3_uri"
}
12 changes: 6 additions & 6 deletions hubblescope/.abcli/select.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[[ -z "$abcli_hubble_dataset_name" ]] && export abcli_hubble_dataset_name=hst

function abcli_hubble_select() {
function hubble_select() {
if [ "$1" == help ]; then
abcli_show_usage "hubble select [dataset] <hubble-dataset-name>" \
"select <hubble-dataset-name>, example: hst."
Expand All @@ -18,7 +18,7 @@ function abcli_hubble_select() {
if [[ -z "$thing_type" ]]; then
abcli_log_error "-hubble: select: <object-name> not found."
return 1
elif [[ $(abcli_hubble_is_dataset $thing_type) == 1 ]]; then
elif [[ $(hubble_is_dataset $thing_type) == 1 ]]; then
local thing_type=dataset
local thing_name=$1
local args="${@:2}"
Expand All @@ -36,7 +36,7 @@ function abcli_hubble_select() {

abcli_log "🔗 https://registry.opendata.aws/$thing_name/"
abcli_log "🔗 https://github.com/awslabs/open-data-registry/blob/main/datasets/$thing_name.yaml"
abcli_log_file $(abcli_hubble_dataset_metadata $thing_name)
abcli_log_file $(hubble_dataset_metadata $thing_name)
else
abcli_log "🔭 $abcli_hubble_dataset_name :: $thing_name"

Expand All @@ -48,12 +48,12 @@ function abcli_hubble_select() {
"$args"
}

function abcli_hubble_dataset_metadata() {
function hubble_dataset_metadata() {
echo $abcli_path_git/open-data-registry/datasets/$1.yaml
}

function abcli_hubble_is_dataset() {
if [[ -f $(abcli_hubble_dataset_metadata $1) ]]; then
function hubble_is_dataset() {
if [[ -f $(hubble_dataset_metadata $1) ]]; then
echo 1
return
fi
Expand Down
6 changes: 3 additions & 3 deletions hubblescope/.abcli/tests/is_dataset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ function test_hubble_is_dataset() {
local do_dryrun=$(abcli_option_int "$options" dryrun 0)

abcli_assert \
$(abcli_hubble_is_dataset hst) \
$(hubble_is_dataset hst) \
1

abcli_assert \
$(abcli_hubble_is_dataset nst) \
$(hubble_is_dataset nst) \
0

abcli_assert \
$(abcli_hubble_is_dataset shopping-humor-generation) \
$(hubble_is_dataset shopping-humor-generation) \
1
}
2 changes: 1 addition & 1 deletion hubblescope/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

DESCRIPTION = f"{ICON} tools to access and process Hubble Space Telescope imagery and other datasets on AWS Open Data Registry."

VERSION = "4.11.1"
VERSION = "4.15.1"

0 comments on commit 9b3a023

Please sign in to comment.