bluer-objects 6.24.1__py3-none-any.whl → 6.26.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of bluer-objects might be problematic. Click here for more details.
- bluer_objects/.abcli/alias.sh +3 -3
- bluer_objects/.abcli/clone.sh +6 -6
- bluer_objects/.abcli/download.sh +11 -42
- bluer_objects/.abcli/gif.sh +2 -2
- bluer_objects/.abcli/mlflow.sh +1 -1
- bluer_objects/.abcli/publish.sh +3 -3
- bluer_objects/.abcli/tests/ls.sh +1 -1
- bluer_objects/.abcli/tests/storage.sh +60 -0
- bluer_objects/.abcli/upload.sh +8 -60
- bluer_objects/__init__.py +1 -1
- bluer_objects/config.env +3 -1
- bluer_objects/env.py +6 -1
- bluer_objects/file/__main__.py +15 -2
- bluer_objects/help/download.py +23 -0
- bluer_objects/help/functions.py +10 -1
- bluer_objects/help/upload.py +20 -0
- bluer_objects/host/__init__.py +12 -1
- bluer_objects/host/__main__.py +0 -1
- bluer_objects/host/functions.py +14 -1
- bluer_objects/metadata/get.py +2 -2
- bluer_objects/metadata/post.py +2 -1
- bluer_objects/sample.env +3 -16
- bluer_objects/storage/WebDAV.py +114 -0
- bluer_objects/storage/WebDAVzip.py +84 -0
- bluer_objects/storage/__init__.py +39 -0
- bluer_objects/storage/__main__.py +44 -0
- bluer_objects/storage/base.py +37 -0
- bluer_objects/tests/test_download.py +52 -0
- bluer_objects/tests/test_env.py +11 -0
- bluer_objects/tests/test_graphics.py +2 -1
- bluer_objects/tests/test_graphics_gif.py +2 -1
- bluer_objects/tests/test_objects.py +2 -116
- bluer_objects/tests/test_upload.py +76 -0
- {bluer_objects-6.24.1.dist-info → bluer_objects-6.26.1.dist-info}/METADATA +5 -4
- {bluer_objects-6.24.1.dist-info → bluer_objects-6.26.1.dist-info}/RECORD +39 -30
- bluer_objects/.abcli/tags.sh +0 -5
- /bluer_objects/.abcli/tests/{test_gif.sh → gif.sh} +0 -0
- {bluer_objects-6.24.1.dist-info → bluer_objects-6.26.1.dist-info}/WHEEL +0 -0
- {bluer_objects-6.24.1.dist-info → bluer_objects-6.26.1.dist-info}/licenses/LICENSE +0 -0
- {bluer_objects-6.24.1.dist-info → bluer_objects-6.26.1.dist-info}/top_level.txt +0 -0
bluer_objects/.abcli/alias.sh
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
alias @ai=bluer_ai
|
|
4
4
|
|
|
5
|
-
alias @download=
|
|
5
|
+
alias @download=bluer_objects_download
|
|
6
6
|
|
|
7
7
|
alias @gif=abcli_gif
|
|
8
8
|
|
|
@@ -10,7 +10,7 @@ alias @assets=abcli_assets
|
|
|
10
10
|
|
|
11
11
|
alias @cache=abcli_cache
|
|
12
12
|
alias @ref="abcli_cache read"
|
|
13
|
-
alias @tags=
|
|
13
|
+
alias @tags=abcli_mlflow_tags
|
|
14
14
|
|
|
15
15
|
alias @clone=abcli_clone
|
|
16
16
|
alias @cp=abcli_clone
|
|
@@ -33,4 +33,4 @@ alias @publish=bluer_ai_publish
|
|
|
33
33
|
|
|
34
34
|
alias @select=bluer_ai_select
|
|
35
35
|
|
|
36
|
-
alias @upload=
|
|
36
|
+
alias @upload=bluer_objects_upload
|
bluer_objects/.abcli/clone.sh
CHANGED
|
@@ -22,12 +22,12 @@ function abcli_clone() {
|
|
|
22
22
|
[[ $? -ne 0 ]] && return 1
|
|
23
23
|
|
|
24
24
|
[[ "$do_relate" == 1 ]] &&
|
|
25
|
-
|
|
25
|
+
abcli_mlflow_tags set \
|
|
26
26
|
$object_name \
|
|
27
27
|
cloned.$s3_uri
|
|
28
28
|
|
|
29
29
|
[[ "$do_upload" == 1 ]] &&
|
|
30
|
-
|
|
30
|
+
bluer_objects_upload - $object_name
|
|
31
31
|
|
|
32
32
|
return 0
|
|
33
33
|
fi
|
|
@@ -43,7 +43,7 @@ function abcli_clone() {
|
|
|
43
43
|
abcli_log "$object_1_name -clone:$transfer_mechanism-> $object_2_name"
|
|
44
44
|
|
|
45
45
|
[[ "$do_download" == 1 ]] &&
|
|
46
|
-
|
|
46
|
+
bluer_objects_download - $object_1_name
|
|
47
47
|
|
|
48
48
|
local object_1_path=$ABCLI_OBJECT_ROOT/$object_1_name
|
|
49
49
|
local object_2_path=$ABCLI_OBJECT_ROOT/$object_2_name
|
|
@@ -64,12 +64,12 @@ function abcli_clone() {
|
|
|
64
64
|
fi
|
|
65
65
|
|
|
66
66
|
[[ "$clone_tags" == 1 ]] &&
|
|
67
|
-
|
|
67
|
+
abcli_mlflow_tags clone \
|
|
68
68
|
$object_1_name \
|
|
69
69
|
$object_2_name
|
|
70
70
|
|
|
71
71
|
[[ "$do_relate" == 1 ]] &&
|
|
72
|
-
|
|
72
|
+
abcli_mlflow_tags set \
|
|
73
73
|
$object_2_name \
|
|
74
74
|
cloned.$object_1_name
|
|
75
75
|
|
|
@@ -88,7 +88,7 @@ function abcli_clone() {
|
|
|
88
88
|
$object_2_path/metadata-$object_1_name.yaml
|
|
89
89
|
|
|
90
90
|
[[ "$do_upload" == 1 ]] &&
|
|
91
|
-
|
|
91
|
+
bluer_objects_upload - $object_2_name
|
|
92
92
|
|
|
93
93
|
return 0
|
|
94
94
|
}
|
bluer_objects/.abcli/download.sh
CHANGED
|
@@ -1,53 +1,22 @@
|
|
|
1
1
|
#! /usr/bin/env bash
|
|
2
2
|
|
|
3
|
-
function
|
|
3
|
+
function bluer_objects_download() {
|
|
4
4
|
local options=$1
|
|
5
5
|
local filename=$(abcli_option "$options" filename)
|
|
6
6
|
|
|
7
7
|
local object_name=$(abcli_clarify_object $2 .)
|
|
8
|
-
local object_path=$ABCLI_OBJECT_ROOT/$object_name
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
fi
|
|
16
|
-
|
|
17
|
-
if [ ! -z "$filename" ]; then
|
|
18
|
-
abcli_log "downloading $object_name/$filename ..."
|
|
19
|
-
aws s3 cp "$ABCLI_S3_OBJECT_PREFIX/$object_name/$filename" "$object_path/$filename"
|
|
20
|
-
else
|
|
21
|
-
local exists=$(aws s3 ls $ABCLI_AWS_S3_BUCKET_NAME/$ABCLI_AWS_S3_PREFIX/$object_name.tar.gz)
|
|
22
|
-
if [ -z "$exists" ]; then
|
|
23
|
-
abcli_log "downloading $object_name ..."
|
|
24
|
-
|
|
25
|
-
aws s3 sync \
|
|
26
|
-
"$ABCLI_S3_OBJECT_PREFIX/$object_name" \
|
|
27
|
-
"$object_path" \
|
|
28
|
-
--exact-timestamps
|
|
29
|
-
else
|
|
30
|
-
abcli_log "downloading $object_name.tar.gz ..."
|
|
31
|
-
|
|
32
|
-
pushd $ABCLI_OBJECT_ROOT >/dev/null
|
|
33
|
-
|
|
34
|
-
aws s3 cp \
|
|
35
|
-
"$ABCLI_S3_OBJECT_PREFIX/$object_name.tar.gz" .
|
|
36
|
-
|
|
37
|
-
local object_size=$(bluer_objects_file size $object_name.tar.gz)
|
|
38
|
-
abcli_log "$object_name.tar.gz ($object_size) downloaded."
|
|
39
|
-
|
|
40
|
-
tar -xvf "$object_name.tar.gz"
|
|
41
|
-
|
|
42
|
-
popd >/dev/null
|
|
43
|
-
fi
|
|
44
|
-
|
|
45
|
-
fi
|
|
9
|
+
python3 -m bluer_objects.storage \
|
|
10
|
+
download \
|
|
11
|
+
--object_name $object_name \
|
|
12
|
+
--filename "$filename"
|
|
13
|
+
[[ $? -ne 0 ]] && return 1
|
|
46
14
|
|
|
15
|
+
local open_options=$3
|
|
47
16
|
local do_open=$(abcli_option_int "$open_options" open 0)
|
|
48
|
-
[[ "$do_open" ==
|
|
49
|
-
|
|
50
|
-
$object_name
|
|
17
|
+
[[ "$do_open" == 0 ]] &&
|
|
18
|
+
return 0
|
|
51
19
|
|
|
52
|
-
|
|
20
|
+
bluer_ai_open filename=$filename,$open_options \
|
|
21
|
+
$object_name
|
|
53
22
|
}
|
bluer_objects/.abcli/gif.sh
CHANGED
|
@@ -9,7 +9,7 @@ function abcli_gif() {
|
|
|
9
9
|
local object_name=$(abcli_clarify_object $2 .)
|
|
10
10
|
|
|
11
11
|
[[ "$do_download" == 1 ]] &&
|
|
12
|
-
|
|
12
|
+
bluer_objects_download - $object_name
|
|
13
13
|
|
|
14
14
|
abcli_log "generating animated gif: $object_name ..."
|
|
15
15
|
|
|
@@ -21,7 +21,7 @@ function abcli_gif() {
|
|
|
21
21
|
local status="$?"
|
|
22
22
|
|
|
23
23
|
[[ "$do_upload" == 1 ]] &&
|
|
24
|
-
|
|
24
|
+
bluer_objects_upload - $object_name
|
|
25
25
|
|
|
26
26
|
return $status
|
|
27
27
|
}
|
bluer_objects/.abcli/mlflow.sh
CHANGED
bluer_objects/.abcli/publish.sh
CHANGED
|
@@ -9,16 +9,16 @@ function bluer_ai_publish() {
|
|
|
9
9
|
|
|
10
10
|
local object_name=$(abcli_clarify_object $2 .)
|
|
11
11
|
[[ "$do_download" == 1 ]] &&
|
|
12
|
-
|
|
12
|
+
bluer_objects_download - $object_name
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
abcli_mlflow_tags set $object_name published
|
|
15
15
|
|
|
16
16
|
local public_object_name=$(abcli_option "$options" as $object_name)
|
|
17
17
|
|
|
18
18
|
if [ "$do_tar" == 1 ]; then
|
|
19
19
|
abcli_log "publishing $object_name -> $public_object_name.tar.gz"
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
bluer_objects_upload ~open,solid $object_name
|
|
22
22
|
aws s3 cp \
|
|
23
23
|
$ABCLI_S3_OBJECT_PREFIX/$object_name.tar.gz \
|
|
24
24
|
s3://$ABCLI_AWS_S3_PUBLIC_BUCKET_NAME/$public_object_name.tar.gz
|
bluer_objects/.abcli/tests/ls.sh
CHANGED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#! /usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
function test_bluer_objects_storage() {
|
|
4
|
+
local options=$1
|
|
5
|
+
|
|
6
|
+
local object_name=test_bluer_objects_storage-$(abcli_string_timestamp_short)
|
|
7
|
+
local object_path=$ABCLI_OBJECT_ROOT/$object_name
|
|
8
|
+
mkdir -pv $object_path
|
|
9
|
+
|
|
10
|
+
local suffix
|
|
11
|
+
local extension=yaml
|
|
12
|
+
for suffix in this.$extension that.$extension subfolder/this.$extension subfolder/that.$extension; do
|
|
13
|
+
python3 -m bluer_objects.file \
|
|
14
|
+
create_a_file \
|
|
15
|
+
--filename $object_path/$suffix
|
|
16
|
+
done
|
|
17
|
+
|
|
18
|
+
# testing upload
|
|
19
|
+
abcli_hr
|
|
20
|
+
|
|
21
|
+
bluer_objects_upload \
|
|
22
|
+
filename=this.$extension \
|
|
23
|
+
$object_name
|
|
24
|
+
[[ $? -ne 0 ]] && return 1
|
|
25
|
+
abcli_hr
|
|
26
|
+
|
|
27
|
+
bluer_objects_upload \
|
|
28
|
+
filename=subfolder/this.$extension \
|
|
29
|
+
$object_name
|
|
30
|
+
[[ $? -ne 0 ]] && return 1
|
|
31
|
+
abcli_hr
|
|
32
|
+
|
|
33
|
+
bluer_objects_upload \
|
|
34
|
+
- \
|
|
35
|
+
$object_name
|
|
36
|
+
[[ $? -ne 0 ]] && return 1
|
|
37
|
+
abcli_hr
|
|
38
|
+
|
|
39
|
+
# clean-up
|
|
40
|
+
rm -rfv $object_path
|
|
41
|
+
abcli_hr
|
|
42
|
+
|
|
43
|
+
# testing download
|
|
44
|
+
|
|
45
|
+
bluer_objects_download \
|
|
46
|
+
filename=this.$extension \
|
|
47
|
+
$object_name
|
|
48
|
+
[[ $? -ne 0 ]] && return 1
|
|
49
|
+
abcli_hr
|
|
50
|
+
|
|
51
|
+
bluer_objects_download \
|
|
52
|
+
filename=subfolder/this.$extension \
|
|
53
|
+
$object_name
|
|
54
|
+
[[ $? -ne 0 ]] && return 1
|
|
55
|
+
abcli_hr
|
|
56
|
+
|
|
57
|
+
bluer_objects_download \
|
|
58
|
+
- \
|
|
59
|
+
$object_name
|
|
60
|
+
}
|
bluer_objects/.abcli/upload.sh
CHANGED
|
@@ -1,73 +1,21 @@
|
|
|
1
1
|
#! /usr/bin/env bash
|
|
2
2
|
|
|
3
|
-
function
|
|
3
|
+
function bluer_objects_upload() {
|
|
4
4
|
local options=$1
|
|
5
5
|
local filename=$(abcli_option "$options" filename)
|
|
6
|
-
local do_open=$(abcli_option_int "$options" open 1)
|
|
7
|
-
local do_solid=$(abcli_option_int "$options" solid 0)
|
|
8
|
-
local warn_if_exists=$(abcli_option_int "$options" warn_if_exists 1)
|
|
9
|
-
local log_to_mlflow=$(abcli_option_int "$options" mlflow 0)
|
|
10
|
-
local no_mlflow=$(abcli_option_int "$options" no_mlflow 0)
|
|
11
6
|
|
|
12
7
|
local object_name=$(abcli_clarify_object $2 .)
|
|
13
8
|
local object_path=$ABCLI_OBJECT_ROOT/$object_name
|
|
14
9
|
|
|
15
|
-
# https://stackoverflow.com/a/45200066
|
|
16
|
-
local exists=$(aws s3 ls $ABCLI_AWS_S3_BUCKET_NAME/$ABCLI_AWS_S3_PREFIX/$object_name.tar.gz)
|
|
17
|
-
if [ ! -z "$exists" ]; then
|
|
18
|
-
if [[ "$warn_if_exists" == 1 ]]; then
|
|
19
|
-
abcli_log_warning "@abcli: upload: $object_name.tar.gz already exists on the cloud, use \"abcli object open\" to open the object."
|
|
20
|
-
else
|
|
21
|
-
abcli_log "✅ ☁️ $object_name.tar.gz."
|
|
22
|
-
fi
|
|
23
|
-
return
|
|
24
|
-
fi
|
|
25
|
-
|
|
26
10
|
rm -rf $object_path/auxiliary
|
|
27
11
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
$object_path/$filename \
|
|
34
|
-
$ABCLI_S3_OBJECT_PREFIX/$object_name/
|
|
35
|
-
|
|
36
|
-
return
|
|
37
|
-
fi
|
|
38
|
-
|
|
39
|
-
if [ "$do_open" == 1 ]; then
|
|
40
|
-
abcli_log "uploading $object_name ..."
|
|
41
|
-
|
|
42
|
-
aws s3 sync \
|
|
43
|
-
$object_path/ \
|
|
44
|
-
$ABCLI_S3_OBJECT_PREFIX/$object_name/
|
|
45
|
-
|
|
46
|
-
abcli_tags set $object_name open
|
|
47
|
-
fi
|
|
48
|
-
|
|
49
|
-
if [ "$do_solid" == 1 ]; then
|
|
50
|
-
pushd $ABCLI_OBJECT_ROOT >/dev/null
|
|
51
|
-
|
|
52
|
-
tar -czvf \
|
|
53
|
-
$object_name.tar.gz \
|
|
54
|
-
./$object_name
|
|
55
|
-
|
|
56
|
-
local object_size=$(bluer_objects_file size $object_path.tar.gz)
|
|
57
|
-
abcli_log "uploading $object_name.tar.gz ($object_size) ..."
|
|
58
|
-
|
|
59
|
-
aws s3 cp \
|
|
60
|
-
$object_name.tar.gz \
|
|
61
|
-
$ABCLI_S3_OBJECT_PREFIX/
|
|
62
|
-
|
|
63
|
-
abcli_tags set $object_name solid
|
|
64
|
-
|
|
65
|
-
popd >/dev/null
|
|
66
|
-
fi
|
|
12
|
+
python3 -m bluer_objects.storage \
|
|
13
|
+
upload \
|
|
14
|
+
--object_name $object_name \
|
|
15
|
+
--filename "$filename"
|
|
16
|
+
[[ $? -ne 0 ]] && return 1
|
|
67
17
|
|
|
68
|
-
if [[ "$
|
|
69
|
-
|
|
70
|
-
elif [[ "$no_mlflow" == 0 ]]; then
|
|
71
|
-
abcli_mlflow log_run $object_name
|
|
18
|
+
if [[ -z "$filename" ]]; then
|
|
19
|
+
abcli_mlflow_log_run $object_name
|
|
72
20
|
fi
|
|
73
21
|
}
|
bluer_objects/__init__.py
CHANGED
bluer_objects/config.env
CHANGED
bluer_objects/env.py
CHANGED
|
@@ -42,5 +42,10 @@ DATABRICKS_TOKEN = get_env("DATABRICKS_TOKEN")
|
|
|
42
42
|
|
|
43
43
|
ABCLI_MLFLOW_EXPERIMENT_PREFIX = get_env("ABCLI_MLFLOW_EXPERIMENT_PREFIX")
|
|
44
44
|
|
|
45
|
-
|
|
46
45
|
ABCLI_S3_OBJECT_PREFIX = "to-be-removed"
|
|
46
|
+
|
|
47
|
+
BLUER_OBJECTS_STORAGE_INTERFACE = get_env("BLUER_OBJECTS_STORAGE_INTERFACE")
|
|
48
|
+
|
|
49
|
+
WEBDAV_HOSTNAME = get_env("WEBDAV_HOSTNAME")
|
|
50
|
+
WEBDAV_LOGIN = get_env("WEBDAV_LOGIN")
|
|
51
|
+
WEBDAV_PASSWORD = get_env("WEBDAV_PASSWORD")
|
bluer_objects/file/__main__.py
CHANGED
|
@@ -14,7 +14,7 @@ parser = argparse.ArgumentParser(NAME)
|
|
|
14
14
|
parser.add_argument(
|
|
15
15
|
"task",
|
|
16
16
|
type=str,
|
|
17
|
-
help="replace|size",
|
|
17
|
+
help="create_a_file | replace | size",
|
|
18
18
|
)
|
|
19
19
|
parser.add_argument(
|
|
20
20
|
"--filename",
|
|
@@ -30,10 +30,23 @@ parser.add_argument(
|
|
|
30
30
|
type=str,
|
|
31
31
|
help="<that-1+that-2+that-3>",
|
|
32
32
|
)
|
|
33
|
+
parser.add_argument(
|
|
34
|
+
"--size",
|
|
35
|
+
type=int,
|
|
36
|
+
default=16,
|
|
37
|
+
)
|
|
33
38
|
args = parser.parse_args()
|
|
34
39
|
|
|
35
40
|
success = False
|
|
36
|
-
if args.task == "
|
|
41
|
+
if args.task == "create_a_file":
|
|
42
|
+
success = file.save_yaml(
|
|
43
|
+
args.filename,
|
|
44
|
+
{
|
|
45
|
+
string.random(length=args.size): string.random(length=args.size)
|
|
46
|
+
for _ in range(args.size)
|
|
47
|
+
},
|
|
48
|
+
)
|
|
49
|
+
elif args.task == "replace":
|
|
37
50
|
logger.info(f"{NAME}.{args.task}: {args.this} -> {args.that} in {args.filename}")
|
|
38
51
|
|
|
39
52
|
success, content = file.load_text(args.filename)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from typing import List
|
|
2
|
+
|
|
3
|
+
from bluer_options.terminal import show_usage, xtra
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def help_download(
|
|
7
|
+
tokens: List[str],
|
|
8
|
+
mono: bool,
|
|
9
|
+
) -> str:
|
|
10
|
+
options = "filename=<filename>"
|
|
11
|
+
|
|
12
|
+
open_options = "open,QGIS"
|
|
13
|
+
|
|
14
|
+
return show_usage(
|
|
15
|
+
[
|
|
16
|
+
"@download",
|
|
17
|
+
f"[{options}]",
|
|
18
|
+
"[.|<object-name>]",
|
|
19
|
+
f"[{open_options}]",
|
|
20
|
+
],
|
|
21
|
+
"download <object-name>.",
|
|
22
|
+
mono=mono,
|
|
23
|
+
)
|
bluer_objects/help/functions.py
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
from
|
|
1
|
+
from bluer_ai.help.generic import help_functions as generic_help_functions
|
|
2
2
|
|
|
3
3
|
from bluer_objects import ALIAS
|
|
4
|
+
from bluer_objects.help.download import help_download
|
|
5
|
+
from bluer_objects.help.upload import help_upload
|
|
4
6
|
|
|
5
7
|
help_functions = generic_help_functions(plugin_name=ALIAS)
|
|
8
|
+
|
|
9
|
+
help_functions.update(
|
|
10
|
+
{
|
|
11
|
+
"download": help_download,
|
|
12
|
+
"upload": help_upload,
|
|
13
|
+
}
|
|
14
|
+
)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from typing import List
|
|
2
|
+
|
|
3
|
+
from bluer_options.terminal import show_usage, xtra
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def help_upload(
|
|
7
|
+
tokens: List[str],
|
|
8
|
+
mono: bool,
|
|
9
|
+
) -> str:
|
|
10
|
+
options = "filename=<filename>"
|
|
11
|
+
|
|
12
|
+
return show_usage(
|
|
13
|
+
[
|
|
14
|
+
"@upload",
|
|
15
|
+
f"[{options}]",
|
|
16
|
+
"[.|<object-name>]",
|
|
17
|
+
],
|
|
18
|
+
"upload <object-name>.",
|
|
19
|
+
mono=mono,
|
|
20
|
+
)
|
bluer_objects/host/__init__.py
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
|
-
from
|
|
1
|
+
from typing import List
|
|
2
|
+
|
|
3
|
+
from bluer_ai.host import signature as bluer_ai_signature
|
|
4
|
+
|
|
5
|
+
from bluer_objects import fullname
|
|
6
|
+
from bluer_objects.host.functions import shell, unzip, zip
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def signature() -> List[str]:
|
|
10
|
+
return [
|
|
11
|
+
fullname(),
|
|
12
|
+
] + bluer_ai_signature()
|
bluer_objects/host/__main__.py
CHANGED
bluer_objects/host/functions.py
CHANGED
|
@@ -61,6 +61,19 @@ def unzip(
|
|
|
61
61
|
output_folder = file.path(zip_filename)
|
|
62
62
|
|
|
63
63
|
return shell(
|
|
64
|
-
command=f'unzip -
|
|
64
|
+
command=f'unzip -o "{zip_filename}" -d "{output_folder}"',
|
|
65
|
+
log=log,
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def zip(
|
|
70
|
+
zip_filename: str,
|
|
71
|
+
input_folder: str = "",
|
|
72
|
+
work_dir: str = ".",
|
|
73
|
+
log: bool = False,
|
|
74
|
+
) -> bool:
|
|
75
|
+
return shell(
|
|
76
|
+
command=f'zip -r "{zip_filename}" "{input_folder}"',
|
|
77
|
+
work_dir=work_dir,
|
|
65
78
|
log=log,
|
|
66
79
|
)
|
bluer_objects/metadata/get.py
CHANGED
|
@@ -2,7 +2,7 @@ from typing import Any
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
from bluer_objects import file
|
|
5
|
-
from bluer_objects import
|
|
5
|
+
from bluer_objects import storage
|
|
6
6
|
from bluer_objects.metadata.enums import MetadataSourceType
|
|
7
7
|
|
|
8
8
|
|
|
@@ -59,7 +59,7 @@ def get_from_object(
|
|
|
59
59
|
download: bool = False,
|
|
60
60
|
**kwargs,
|
|
61
61
|
) -> Any:
|
|
62
|
-
if download and not
|
|
62
|
+
if download and not storage.download(
|
|
63
63
|
object_name=object_name,
|
|
64
64
|
filename="metadata.yaml",
|
|
65
65
|
):
|
bluer_objects/metadata/post.py
CHANGED
|
@@ -7,6 +7,7 @@ from blueness import module
|
|
|
7
7
|
from bluer_objects.metadata.enums import MetadataSourceType
|
|
8
8
|
from bluer_objects import NAME, file
|
|
9
9
|
from bluer_objects import objects
|
|
10
|
+
from bluer_objects import storage
|
|
10
11
|
from bluer_objects.logger import logger
|
|
11
12
|
|
|
12
13
|
NAME = module.name(__file__, NAME)
|
|
@@ -65,7 +66,7 @@ def post_to_object(
|
|
|
65
66
|
upload: bool = False,
|
|
66
67
|
**kwargs,
|
|
67
68
|
) -> bool:
|
|
68
|
-
if download and not
|
|
69
|
+
if download and not storage.download(
|
|
69
70
|
object_name=object_name,
|
|
70
71
|
filename="metadata.yaml",
|
|
71
72
|
):
|
bluer_objects/sample.env
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
# set `DB instance identifier` to `abcli`.
|
|
5
|
-
# set `Credentials Settings` -> `Master username` and `Master Password` and update `host`, `username`, and `password` here.
|
|
6
|
-
# set `DB instance size` to `Burstable Classes` and select `db.t3.small`.
|
|
7
|
-
# set `Storage` to `20` and disable `Storage autoscaling`.
|
|
8
|
-
# in `Connectivity` set `Public Access` to `Yes`.
|
|
9
|
-
# in `Additional Configuration` set `initial database name` to `abcli`.
|
|
10
|
-
ABCLI_AWS_RDS_HOST=
|
|
11
|
-
ABCLI_AWS_RDS_PASSWORD=
|
|
12
|
-
|
|
13
|
-
# https://docs.databricks.com/en/mlflow/tracking.html
|
|
14
|
-
# https://docs.databricks.com/en/dev-tools/auth/pat.html#databricks-personal-access-tokens-for-workspace-users
|
|
15
|
-
DATABRICKS_HOST=
|
|
16
|
-
DATABRICKS_TOKEN=
|
|
1
|
+
WEBDAV_HOSTNAME=
|
|
2
|
+
WEBDAV_LOGIN=
|
|
3
|
+
WEBDAV_PASSWORD=
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
from webdav3.client import Client
|
|
2
|
+
|
|
3
|
+
from bluer_objects.storage.base import StorageInterface
|
|
4
|
+
from bluer_objects import env, file, path
|
|
5
|
+
from bluer_objects import objects
|
|
6
|
+
from bluer_objects.logger import logger
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
# https://chatgpt.com/c/67e06812-4af0-8005-b2ab-5f9a1eabbbe3
|
|
10
|
+
# https://pypi.org/project/webdavclient3/
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# ❗️ fails on .txt, .json, .yaml, ... other files with 'content-length',
|
|
14
|
+
# see WebDAV.ipynb for details (set BLUER_OBJECTS_STORAGE_INTERFACE=webdav).
|
|
15
|
+
class WebDAVInterface(StorageInterface):
|
|
16
|
+
name = "webdav"
|
|
17
|
+
|
|
18
|
+
def __init__(self):
|
|
19
|
+
super().__init__()
|
|
20
|
+
|
|
21
|
+
config = {
|
|
22
|
+
"webdav_hostname": env.WEBDAV_HOSTNAME,
|
|
23
|
+
"webdav_login": env.WEBDAV_LOGIN,
|
|
24
|
+
"webdav_password": env.WEBDAV_PASSWORD,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
self.client = Client(config)
|
|
28
|
+
|
|
29
|
+
def mkdir(
|
|
30
|
+
self,
|
|
31
|
+
path: str,
|
|
32
|
+
log: bool = True,
|
|
33
|
+
) -> bool:
|
|
34
|
+
try:
|
|
35
|
+
if self.client.check(path):
|
|
36
|
+
return True
|
|
37
|
+
|
|
38
|
+
self.client.mkdir(path)
|
|
39
|
+
except Exception as e:
|
|
40
|
+
logger.error(e)
|
|
41
|
+
return False
|
|
42
|
+
|
|
43
|
+
if log:
|
|
44
|
+
logger.info(
|
|
45
|
+
"{}.mkdir: {}".format(
|
|
46
|
+
self.__class__.__name__,
|
|
47
|
+
path,
|
|
48
|
+
)
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
return True
|
|
52
|
+
|
|
53
|
+
def download(
|
|
54
|
+
self,
|
|
55
|
+
object_name: str,
|
|
56
|
+
filename: str = "",
|
|
57
|
+
log: bool = True,
|
|
58
|
+
) -> bool:
|
|
59
|
+
local_path = objects.path_of(
|
|
60
|
+
object_name=object_name,
|
|
61
|
+
filename=filename,
|
|
62
|
+
create=True,
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
if filename:
|
|
66
|
+
if not path.create(file.path(local_path)):
|
|
67
|
+
return False
|
|
68
|
+
|
|
69
|
+
try:
|
|
70
|
+
self.client.download_sync(
|
|
71
|
+
remote_path=f"{object_name}/{filename}",
|
|
72
|
+
local_path=local_path,
|
|
73
|
+
)
|
|
74
|
+
except Exception as e:
|
|
75
|
+
logger.error(e)
|
|
76
|
+
return False
|
|
77
|
+
|
|
78
|
+
return super().download(
|
|
79
|
+
object_name=object_name,
|
|
80
|
+
filename=filename,
|
|
81
|
+
log=log,
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
def upload(
|
|
85
|
+
self,
|
|
86
|
+
object_name: str,
|
|
87
|
+
filename: str = "",
|
|
88
|
+
log: bool = True,
|
|
89
|
+
) -> bool:
|
|
90
|
+
if filename:
|
|
91
|
+
remote_dir = "/".join([object_name] + filename.split("/")[:-1])
|
|
92
|
+
if not self.mkdir(
|
|
93
|
+
path=remote_dir,
|
|
94
|
+
log=log,
|
|
95
|
+
):
|
|
96
|
+
return False
|
|
97
|
+
|
|
98
|
+
try:
|
|
99
|
+
self.client.upload_sync(
|
|
100
|
+
remote_path=f"{object_name}/{filename}",
|
|
101
|
+
local_path=objects.path_of(
|
|
102
|
+
object_name=object_name,
|
|
103
|
+
filename=filename,
|
|
104
|
+
),
|
|
105
|
+
)
|
|
106
|
+
except Exception as e:
|
|
107
|
+
logger.error(e)
|
|
108
|
+
return False
|
|
109
|
+
|
|
110
|
+
return super().upload(
|
|
111
|
+
object_name=object_name,
|
|
112
|
+
filename=filename,
|
|
113
|
+
log=log,
|
|
114
|
+
)
|