bluer-objects 6.3.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.

Files changed (149) hide show
  1. bluer_objects/.abcli/abcli.sh +9 -0
  2. bluer_objects/.abcli/actions.sh +11 -0
  3. bluer_objects/.abcli/aka.sh +3 -0
  4. bluer_objects/.abcli/alias.sh +36 -0
  5. bluer_objects/.abcli/blue_objects.sh +11 -0
  6. bluer_objects/.abcli/cache.sh +5 -0
  7. bluer_objects/.abcli/clone.sh +94 -0
  8. bluer_objects/.abcli/download.sh +53 -0
  9. bluer_objects/.abcli/file.sh +8 -0
  10. bluer_objects/.abcli/gif.sh +27 -0
  11. bluer_objects/.abcli/host.sh +29 -0
  12. bluer_objects/.abcli/ls.sh +24 -0
  13. bluer_objects/.abcli/metadata/get.sh +24 -0
  14. bluer_objects/.abcli/metadata/post.sh +22 -0
  15. bluer_objects/.abcli/metadata.sh +16 -0
  16. bluer_objects/.abcli/mlflow/browse.sh +36 -0
  17. bluer_objects/.abcli/mlflow/cache.sh +31 -0
  18. bluer_objects/.abcli/mlflow/list_registered_models.sh +9 -0
  19. bluer_objects/.abcli/mlflow/log_artifacts.sh +10 -0
  20. bluer_objects/.abcli/mlflow/log_run.sh +10 -0
  21. bluer_objects/.abcli/mlflow/run.sh +11 -0
  22. bluer_objects/.abcli/mlflow/tags/clone.sh +15 -0
  23. bluer_objects/.abcli/mlflow/tags/get.sh +10 -0
  24. bluer_objects/.abcli/mlflow/tags/search.sh +12 -0
  25. bluer_objects/.abcli/mlflow/tags/set.sh +13 -0
  26. bluer_objects/.abcli/mlflow/tags.sh +16 -0
  27. bluer_objects/.abcli/mlflow/test.sh +11 -0
  28. bluer_objects/.abcli/mlflow/transition.sh +20 -0
  29. bluer_objects/.abcli/mlflow.sh +29 -0
  30. bluer_objects/.abcli/mysql/cache.sh +65 -0
  31. bluer_objects/.abcli/mysql/relations.sh +83 -0
  32. bluer_objects/.abcli/mysql/tags.sh +85 -0
  33. bluer_objects/.abcli/mysql.sh +16 -0
  34. bluer_objects/.abcli/object.sh +54 -0
  35. bluer_objects/.abcli/publish.sh +58 -0
  36. bluer_objects/.abcli/select.sh +34 -0
  37. bluer_objects/.abcli/storage/clear.sh +45 -0
  38. bluer_objects/.abcli/storage/download_file.sh +9 -0
  39. bluer_objects/.abcli/storage/exists.sh +8 -0
  40. bluer_objects/.abcli/storage/list.sh +8 -0
  41. bluer_objects/.abcli/storage/rm.sh +11 -0
  42. bluer_objects/.abcli/storage/status.sh +11 -0
  43. bluer_objects/.abcli/storage.sh +15 -0
  44. bluer_objects/.abcli/tags.sh +5 -0
  45. bluer_objects/.abcli/tests/README.sh +8 -0
  46. bluer_objects/.abcli/tests/clone.sh +32 -0
  47. bluer_objects/.abcli/tests/help.sh +85 -0
  48. bluer_objects/.abcli/tests/host.sh +7 -0
  49. bluer_objects/.abcli/tests/ls.sh +13 -0
  50. bluer_objects/.abcli/tests/metadata.sh +53 -0
  51. bluer_objects/.abcli/tests/mlflow_cache.sh +14 -0
  52. bluer_objects/.abcli/tests/mlflow_logging.sh +12 -0
  53. bluer_objects/.abcli/tests/mlflow_tags.sh +29 -0
  54. bluer_objects/.abcli/tests/mlflow_test.sh +7 -0
  55. bluer_objects/.abcli/tests/mysql_cache.sh +15 -0
  56. bluer_objects/.abcli/tests/mysql_relations.sh +20 -0
  57. bluer_objects/.abcli/tests/mysql_tags.sh +16 -0
  58. bluer_objects/.abcli/tests/test_gif.sh +13 -0
  59. bluer_objects/.abcli/tests/version.sh +10 -0
  60. bluer_objects/.abcli/upload.sh +73 -0
  61. bluer_objects/README/__init__.py +29 -0
  62. bluer_objects/README/functions.py +285 -0
  63. bluer_objects/README/items.py +30 -0
  64. bluer_objects/__init__.py +19 -0
  65. bluer_objects/__main__.py +16 -0
  66. bluer_objects/config.env +22 -0
  67. bluer_objects/env.py +72 -0
  68. bluer_objects/file/__init__.py +41 -0
  69. bluer_objects/file/__main__.py +51 -0
  70. bluer_objects/file/classes.py +38 -0
  71. bluer_objects/file/functions.py +290 -0
  72. bluer_objects/file/load.py +219 -0
  73. bluer_objects/file/save.py +280 -0
  74. bluer_objects/graphics/__init__.py +4 -0
  75. bluer_objects/graphics/__main__.py +84 -0
  76. bluer_objects/graphics/frame.py +15 -0
  77. bluer_objects/graphics/gif.py +86 -0
  78. bluer_objects/graphics/screen.py +63 -0
  79. bluer_objects/graphics/signature.py +97 -0
  80. bluer_objects/graphics/text.py +165 -0
  81. bluer_objects/help/__init__.py +0 -0
  82. bluer_objects/help/__main__.py +10 -0
  83. bluer_objects/help/functions.py +5 -0
  84. bluer_objects/host/__init__.py +1 -0
  85. bluer_objects/host/__main__.py +84 -0
  86. bluer_objects/host/functions.py +66 -0
  87. bluer_objects/logger/__init__.py +4 -0
  88. bluer_objects/logger/matrix.py +209 -0
  89. bluer_objects/markdown.py +43 -0
  90. bluer_objects/metadata/__init__.py +8 -0
  91. bluer_objects/metadata/__main__.py +110 -0
  92. bluer_objects/metadata/enums.py +29 -0
  93. bluer_objects/metadata/get.py +89 -0
  94. bluer_objects/metadata/post.py +101 -0
  95. bluer_objects/mlflow/__init__.py +28 -0
  96. bluer_objects/mlflow/__main__.py +271 -0
  97. bluer_objects/mlflow/cache.py +13 -0
  98. bluer_objects/mlflow/logging.py +81 -0
  99. bluer_objects/mlflow/models.py +57 -0
  100. bluer_objects/mlflow/objects.py +76 -0
  101. bluer_objects/mlflow/runs.py +100 -0
  102. bluer_objects/mlflow/tags.py +90 -0
  103. bluer_objects/mlflow/testing.py +39 -0
  104. bluer_objects/mysql/cache/__init__.py +8 -0
  105. bluer_objects/mysql/cache/__main__.py +91 -0
  106. bluer_objects/mysql/cache/functions.py +181 -0
  107. bluer_objects/mysql/relations/__init__.py +9 -0
  108. bluer_objects/mysql/relations/__main__.py +138 -0
  109. bluer_objects/mysql/relations/functions.py +180 -0
  110. bluer_objects/mysql/table.py +144 -0
  111. bluer_objects/mysql/tags/__init__.py +1 -0
  112. bluer_objects/mysql/tags/__main__.py +130 -0
  113. bluer_objects/mysql/tags/functions.py +203 -0
  114. bluer_objects/objects.py +167 -0
  115. bluer_objects/path.py +194 -0
  116. bluer_objects/sample.env +16 -0
  117. bluer_objects/storage/__init__.py +3 -0
  118. bluer_objects/storage/__main__.py +114 -0
  119. bluer_objects/storage/classes.py +237 -0
  120. bluer_objects/tests/__init__.py +0 -0
  121. bluer_objects/tests/test_README.py +5 -0
  122. bluer_objects/tests/test_env.py +27 -0
  123. bluer_objects/tests/test_file_load_save.py +105 -0
  124. bluer_objects/tests/test_fullname.py +5 -0
  125. bluer_objects/tests/test_graphics.py +28 -0
  126. bluer_objects/tests/test_graphics_frame.py +11 -0
  127. bluer_objects/tests/test_graphics_gif.py +29 -0
  128. bluer_objects/tests/test_graphics_screen.py +8 -0
  129. bluer_objects/tests/test_graphics_signature.py +80 -0
  130. bluer_objects/tests/test_graphics_text.py +14 -0
  131. bluer_objects/tests/test_logger.py +5 -0
  132. bluer_objects/tests/test_logger_matrix.py +73 -0
  133. bluer_objects/tests/test_markdown.py +10 -0
  134. bluer_objects/tests/test_metadata.py +204 -0
  135. bluer_objects/tests/test_mlflow.py +60 -0
  136. bluer_objects/tests/test_mysql_cache.py +14 -0
  137. bluer_objects/tests/test_mysql_relations.py +16 -0
  138. bluer_objects/tests/test_mysql_table.py +9 -0
  139. bluer_objects/tests/test_mysql_tags.py +13 -0
  140. bluer_objects/tests/test_objects.py +180 -0
  141. bluer_objects/tests/test_path.py +7 -0
  142. bluer_objects/tests/test_storage.py +7 -0
  143. bluer_objects/tests/test_version.py +5 -0
  144. bluer_objects/urls.py +3 -0
  145. bluer_objects-6.3.1.dist-info/METADATA +57 -0
  146. bluer_objects-6.3.1.dist-info/RECORD +149 -0
  147. bluer_objects-6.3.1.dist-info/WHEEL +5 -0
  148. bluer_objects-6.3.1.dist-info/licenses/LICENSE +121 -0
  149. bluer_objects-6.3.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,53 @@
1
+ #! /usr/bin/env bash
2
+
3
+ function test_bluer_objects_metadata() {
4
+ local returned_value
5
+ for post_func in {1..3}; do
6
+ local object_name=$(abcli_string_timestamp)
7
+ local object_path=$ABCLI_OBJECT_ROOT/$object_name
8
+ local filename=$object_path/metadata.yaml
9
+
10
+ local key=$(abcli_string_random)
11
+ local value=$(abcli_string_random)
12
+
13
+ [[ "$post_func" == 1 ]] &&
14
+ abcli metadata post \
15
+ $key $value \
16
+ filename \
17
+ $filename \
18
+ --verbose 1
19
+
20
+ [[ "$post_func" == 2 ]] &&
21
+ abcli metadata post \
22
+ $key $value \
23
+ object,filename=metadata.yaml \
24
+ $object_name \
25
+ --verbose 1
26
+
27
+ [[ "$post_func" == 3 ]] &&
28
+ abcli metadata post \
29
+ $key $value \
30
+ path,filename=metadata.yaml \
31
+ $object_path \
32
+ --verbose 1
33
+
34
+ for get_func in {1..3}; do
35
+ [[ "$get_func" == 1 ]] &&
36
+ returned_value=$(abcli metadata get \
37
+ key=$key,filename \
38
+ $filename)
39
+
40
+ [[ "$get_func" == 2 ]] &&
41
+ returned_value=$(abcli metadata get \
42
+ key=$key,filename=metadata.yaml,object \
43
+ $object_name)
44
+
45
+ [[ "$get_func" == 3 ]] &&
46
+ returned_value=$(abcli metadata get \
47
+ key=$key,filename=metadata.yaml,path \
48
+ $object_path)
49
+
50
+ abcli_assert "$value" "$returned_value"
51
+ done
52
+ done
53
+ }
@@ -0,0 +1,14 @@
1
+ #! /usr/bin/env bash
2
+
3
+ function test_bluer_objects_mlflow_cache() {
4
+ local keyword="test-keyword-$(abcli_string_timestamp_short)"
5
+ local value="test-value-$(abcli_string_timestamp_short)"
6
+
7
+ abcli mlflow cache write \
8
+ $keyword $value
9
+ [[ $? -ne 0 ]] && return 1
10
+
11
+ abcli_assert \
12
+ $(abcli mlflow cache read $keyword) \
13
+ $value
14
+ }
@@ -0,0 +1,12 @@
1
+ #! /usr/bin/env bash
2
+
3
+ function test_bluer_objects_mlflow_logging() {
4
+ local object_name="test-object-$(abcli_string_timestamp_short)"
5
+
6
+ abcli clone \
7
+ upload \
8
+ vanwatch-mlflow-validation-2024-09-23-10673 \
9
+ "$object_name"
10
+
11
+ abcli_mlflow rm $object_name
12
+ }
@@ -0,0 +1,29 @@
1
+ #! /usr/bin/env bash
2
+
3
+ function test_bluer_objects_mlflow_tags_validation() {
4
+ local object_name="test-object-$(abcli_string_timestamp_short)"
5
+ local tag="test-tag-$(abcli_string_timestamp_short)"
6
+ local value="test-value-$(abcli_string_timestamp_short)"
7
+
8
+ abcli mlflow tags set \
9
+ $object_name \
10
+ $tag=$value
11
+ [[ $? -ne 0 ]] && return 1
12
+
13
+ abcli_assert \
14
+ "$(abcli mlflow tags get $object_name --tag $tag)" \
15
+ $value
16
+ [[ $? -ne 0 ]] && return 1
17
+
18
+ abcli_assert \
19
+ "$(abcli mlflow tags get $object_name --tag some-tag)" \
20
+ - empty
21
+ }
22
+
23
+ function test_bluer_objects_mlflow_tags_search() {
24
+ local options=$1
25
+
26
+ abcli_mlflow_tags search \
27
+ cloned.firms_area-template-v1=True \
28
+ --log 0
29
+ }
@@ -0,0 +1,7 @@
1
+ #! /usr/bin/env bash
2
+
3
+ function test_bluer_objects_mlflow_test() {
4
+ local options=$1
5
+
6
+ abcli_mlflow_test "$@"
7
+ }
@@ -0,0 +1,15 @@
1
+ #! /usr/bin/env bash
2
+
3
+ function test_bluer_objects_mysql_cache() {
4
+ local keyword="test-keyword-$(abcli_string_timestamp_short)"
5
+ local value="test-value-$(abcli_string_timestamp_short)"
6
+
7
+ abcli mysql cache write \
8
+ $keyword $value \
9
+ validate
10
+ [[ $? -ne 0 ]] && return 1
11
+
12
+ abcli_assert \
13
+ $(abcli mysql cache read $keyword) \
14
+ $value
15
+ }
@@ -0,0 +1,20 @@
1
+ #! /usr/bin/env bash
2
+
3
+ function test_bluer_objects_mysql_relations() {
4
+ local object_name_1="test-object-$(abcli_string_timestamp_short)"
5
+ local object_name_2="test-object-$(abcli_string_timestamp_short)"
6
+
7
+ local relation=$(abcli mysql relations list --return_list 1 --count 1 --log 0)
8
+ [[ -z "$relation" ]] && return 1
9
+
10
+ abcli mysql relations set \
11
+ $object_name_1 \
12
+ $object_name_2 \
13
+ $relation \
14
+ validate
15
+ [[ $? -ne 0 ]] && return 1
16
+
17
+ abcli_assert \
18
+ $(abcli mysql relations get $object_name_1 $object_name_2 --log 0) \
19
+ $relation
20
+ }
@@ -0,0 +1,16 @@
1
+ #! /usr/bin/env bash
2
+
3
+ function test_bluer_objects_mysql_tags() {
4
+ local object_name="test-object-$(abcli_string_timestamp_short)"
5
+ local tag="test-tag-$(abcli_string_timestamp_short)"
6
+
7
+ abcli mysql tags set \
8
+ $object_name \
9
+ $tag \
10
+ validate
11
+ [[ $? -ne 0 ]] && return 1
12
+
13
+ abcli_assert \
14
+ $(abcli mysql tags get $object_name --log 0) \
15
+ $tag
16
+ }
@@ -0,0 +1,13 @@
1
+ #! /usr/bin/env bash
2
+
3
+ function test_bluer_objects_gif() {
4
+ local options=$1
5
+
6
+ abcli_gif \
7
+ ~upload,$options \
8
+ $VANWATCH_TEST_OBJECT \
9
+ --frame_duration 200 \
10
+ --output_filename test.gif \
11
+ --scale 2 \
12
+ --suffix .jpg
13
+ }
@@ -0,0 +1,10 @@
1
+ #! /usr/bin/env bash
2
+
3
+ function test_bluer_objects_version() {
4
+ local options=$1
5
+
6
+ abcli_eval ,$options \
7
+ "bluer_objects version ${@:2}"
8
+
9
+ return 0
10
+ }
@@ -0,0 +1,73 @@
1
+ #! /usr/bin/env bash
2
+
3
+ function abcli_upload() {
4
+ local options=$1
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
+
12
+ local object_name=$(abcli_clarify_object $2 .)
13
+ local object_path=$ABCLI_OBJECT_ROOT/$object_name
14
+
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
+ rm -rf $object_path/auxiliary
27
+
28
+ if [ ! -z "$filename" ]; then
29
+ local file_size=$(bluer_objects_file size $filename)
30
+ abcli_log "uploading $object_name/$filename ($file_size) ..."
31
+
32
+ aws s3 cp \
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
67
+
68
+ if [[ "$log_to_mlflow" == 1 ]]; then
69
+ abcli_mlflow log_artifacts $object_name
70
+ elif [[ "$no_mlflow" == 0 ]]; then
71
+ abcli_mlflow log_run $object_name
72
+ fi
73
+ }
@@ -0,0 +1,29 @@
1
+ import os
2
+
3
+ from blueness import module
4
+
5
+ from bluer_objects import NAME as MY_NAME
6
+ from bluer_objects import file
7
+ from bluer_objects.README.functions import build
8
+ from bluer_objects.README.items import Items
9
+ from bluer_objects.logger import logger
10
+
11
+ MY_NAME = module.name(__file__, MY_NAME)
12
+
13
+
14
+ def build_me() -> bool:
15
+ from bluer_objects import NAME, VERSION, REPO_NAME, ICON
16
+
17
+ return all(
18
+ build(
19
+ path=os.path.join(file.path(__file__), readme["path"]),
20
+ ICON=ICON,
21
+ NAME=NAME,
22
+ VERSION=VERSION,
23
+ REPO_NAME=REPO_NAME,
24
+ )
25
+ for readme in [
26
+ {"path": "../.."},
27
+ {"path": "."},
28
+ ]
29
+ )
@@ -0,0 +1,285 @@
1
+ from typing import List, Dict, Union, Callable
2
+ import os
3
+ import yaml
4
+
5
+ from blueness import module
6
+ from blue_options import fullname
7
+
8
+ from bluer_objects import NAME as MY_NAME, ICON as MY_ICON
9
+ from bluer_objects.env import ABCLI_PUBLIC_PREFIX
10
+ from bluer_objects.metadata import get_from_object
11
+ from bluer_objects import file
12
+ from bluer_objects import markdown
13
+ from bluer_objects.logger import logger
14
+
15
+ MY_NAME = module.name(__file__, MY_NAME)
16
+
17
+
18
+ def build(
19
+ NAME: str,
20
+ VERSION: str,
21
+ REPO_NAME: str,
22
+ items: List[str] = [],
23
+ template_filename: str = "",
24
+ filename: str = "",
25
+ path: str = "",
26
+ cols: int = 3,
27
+ ICON: str = "",
28
+ MODULE_NAME: str = "",
29
+ macros: Dict[str, str] = {},
30
+ help_function: Union[Callable[[List[str]], str], None] = None,
31
+ legacy_mode: bool = True,
32
+ assets_repo: str = "kamangir/assets",
33
+ ) -> bool:
34
+ if path:
35
+ if path.endswith(".md"):
36
+ filename = path
37
+ template_filename = file.add_suffix(path, "template")
38
+ else:
39
+ filename = os.path.join(path, "README.md")
40
+ template_filename = os.path.join(path, "template.md")
41
+
42
+ if not MODULE_NAME:
43
+ MODULE_NAME = REPO_NAME
44
+
45
+ logger.info(
46
+ "{}.build: {}-{}: {}[{}]: {} -{}> {}".format(
47
+ MY_NAME,
48
+ NAME,
49
+ VERSION,
50
+ REPO_NAME,
51
+ MODULE_NAME,
52
+ template_filename,
53
+ "+legacy-" if legacy_mode else "",
54
+ filename,
55
+ )
56
+ )
57
+
58
+ table_of_items = markdown.generate_table(items, cols=cols) if cols > 0 else items
59
+
60
+ signature = [
61
+ # f'to use on [AWS SageMaker](https://aws.amazon.com/sagemaker/) replace `<plugin-name>` with "{NAME}" and follow [these instructions](https://github.com/kamangir/notebooks-and-scripts/blob/main/SageMaker.md).',
62
+ "",
63
+ " ".join(
64
+ [
65
+ f"[![pylint](https://github.com/kamangir/{REPO_NAME}/actions/workflows/pylint.yml/badge.svg)](https://github.com/kamangir/{REPO_NAME}/actions/workflows/pylint.yml)",
66
+ f"[![pytest](https://github.com/kamangir/{REPO_NAME}/actions/workflows/pytest.yml/badge.svg)](https://github.com/kamangir/{REPO_NAME}/actions/workflows/pytest.yml)",
67
+ f"[![bashtest](https://github.com/kamangir/{REPO_NAME}/actions/workflows/bashtest.yml/badge.svg)](https://github.com/kamangir/{REPO_NAME}/actions/workflows/bashtest.yml)",
68
+ f"[![PyPI version](https://img.shields.io/pypi/v/{MODULE_NAME}.svg)](https://pypi.org/project/{MODULE_NAME}/)",
69
+ f"[![PyPI - Downloads](https://img.shields.io/pypi/dd/{MODULE_NAME})](https://pypistats.org/packages/{MODULE_NAME})",
70
+ ]
71
+ ),
72
+ "",
73
+ "built by {} [`{}`]({}), based on {}[`{}-{}`]({}).".format(
74
+ MY_ICON,
75
+ fullname(),
76
+ "https://github.com/kamangir/awesome-bash-cli",
77
+ f"{ICON} " if ICON else "",
78
+ NAME,
79
+ VERSION,
80
+ f"https://github.com/kamangir/{REPO_NAME}",
81
+ ),
82
+ ]
83
+
84
+ success, template = file.load_text(template_filename)
85
+ if not success:
86
+ return success
87
+
88
+ def apply_legacy(line: str) -> str:
89
+ for before, after in {
90
+ "yaml:::": "metadata:::",
91
+ "--help--": "help:::",
92
+ "--include": "include:::",
93
+ "--table--": "items:::",
94
+ "--signature--": "signature:::",
95
+ }.items():
96
+ line = line.replace(before, after)
97
+ return line
98
+
99
+ if legacy_mode:
100
+ logger.info("applying legacy conversions...")
101
+ template = [apply_legacy(line) for line in template]
102
+
103
+ content: List[str] = []
104
+ mermaid_started: bool = False
105
+ variables: Dict[str, str] = {}
106
+ for template_line in template:
107
+ if template_line.startswith("ignore:::"):
108
+ content_section = [template_line.split(":::", 1)[1].strip()]
109
+ else:
110
+ if template_line.startswith("set:::"):
111
+ key, value = template_line.split("set:::", 1)[1].split(" ", 1)
112
+ variables[key] = value
113
+ logger.info(f":::{key} = {value}")
114
+ continue
115
+
116
+ for key, value in variables.items():
117
+ template_line = template_line.replace(
118
+ f"get:::{key}",
119
+ value,
120
+ )
121
+
122
+ if "assets:::" in template_line:
123
+ template_line = " ".join(
124
+ [
125
+ (
126
+ (
127
+ "![image](https://github.com/{}/blob/main/{}?raw=true)".format(
128
+ assets_repo,
129
+ token.split(":::")[1].strip(),
130
+ )
131
+ if any(
132
+ token.endswith(extension)
133
+ for extension in ["png", "jpg", "jpeg", "gif"]
134
+ )
135
+ else "[{}](https://github.com/{}/blob/main/{})".format(
136
+ file.name_and_extension(
137
+ token.split(":::")[1].strip()
138
+ ),
139
+ assets_repo,
140
+ token.split(":::")[1].strip(),
141
+ )
142
+ )
143
+ if token.startswith("assets:::")
144
+ else token
145
+ )
146
+ for token in template_line.split(" ")
147
+ ]
148
+ )
149
+
150
+ if "object:::" in template_line:
151
+ template_line = " ".join(
152
+ [
153
+ (
154
+ "[{}]({}/{}.tar.gz)".format(
155
+ token.split(":::")[1].strip(),
156
+ ABCLI_PUBLIC_PREFIX,
157
+ token.split(":::")[1].strip(),
158
+ )
159
+ if token.startswith("object:::")
160
+ else token
161
+ )
162
+ for token in template_line.split(" ")
163
+ ]
164
+ )
165
+
166
+ content_section: List[str] = [template_line]
167
+
168
+ if template_line.startswith("details:::"):
169
+ suffix = template_line.split(":::", 1)[1]
170
+ if suffix:
171
+ content_section = [
172
+ "",
173
+ "<details>",
174
+ f"<summary>{suffix}</summary>",
175
+ "",
176
+ ]
177
+ else:
178
+ content_section = [
179
+ "",
180
+ "</details>",
181
+ "",
182
+ ]
183
+ elif template_line.startswith("metadata:::"):
184
+ object_name_and_key = template_line.split(":::", 1)[1]
185
+ if ":::" not in object_name_and_key:
186
+ object_name_and_key += ":::"
187
+ object_name, key = object_name_and_key.split(":::", 1)
188
+
189
+ value = get_from_object(
190
+ object_name,
191
+ key,
192
+ {},
193
+ download=True,
194
+ )
195
+
196
+ content_section = (
197
+ ["```yaml"]
198
+ + yaml.dump(
199
+ value,
200
+ default_flow_style=False,
201
+ ).split("\n")
202
+ + ["```"]
203
+ )
204
+ elif template_line.startswith("```mermaid"):
205
+ mermaid_started = True
206
+ logger.info("🧜🏽‍♀️ detected ...")
207
+ elif mermaid_started and template_line.startswith("```"):
208
+ mermaid_started = False
209
+ elif mermaid_started:
210
+ if '"' in template_line and ":::folder" not in template_line:
211
+ template_line_pieces = template_line.split('"')
212
+ if len(template_line_pieces) != 3:
213
+ logger.error(
214
+ f"🧜🏽‍♀️ mermaid line not in expected format: {template_line}."
215
+ )
216
+ return False
217
+
218
+ template_line_pieces[1] = (
219
+ template_line_pieces[1]
220
+ .replace("<", "&lt;")
221
+ .replace(">", "&gt;")
222
+ .replace(" ", "<br>")
223
+ .replace("~~", " ")
224
+ )
225
+
226
+ content_section = ['"'.join(template_line_pieces)]
227
+ elif "items:::" in template_line:
228
+ content_section = table_of_items
229
+ elif "signature:::" in template_line:
230
+ content_section = signature
231
+ elif "include:::" in template_line:
232
+ include_filename_relative = template_line.split(" ")[1].strip()
233
+ include_filename = file.absolute(
234
+ include_filename_relative,
235
+ file.path(template_filename),
236
+ )
237
+
238
+ success, content_section = file.load_text(include_filename)
239
+ if not success:
240
+ return success
241
+
242
+ content_section = [
243
+ line for line in content_section if not line.startswith("used by:")
244
+ ]
245
+
246
+ include_title = (template_line.split(" ", 2) + ["", "", ""])[2]
247
+ if include_title:
248
+ content_section = [f"## {include_title}"] + content_section[1:]
249
+
250
+ if "include:::noref" not in template_line:
251
+ content_section += [
252
+ "using [{}]({}).".format(
253
+ file.name(include_filename),
254
+ include_filename_relative,
255
+ )
256
+ ]
257
+
258
+ logger.info(f"{MY_NAME}.build: including {include_filename} ...")
259
+ elif "help:::" in template_line:
260
+ if help_function is not None:
261
+ help_command = template_line.split("help:::")[1].strip()
262
+
263
+ tokens = help_command.strip().split(" ")[1:]
264
+
265
+ help_content = help_function(tokens)
266
+ if not help_content:
267
+ logger.warning(f"help not found: {help_command}: {tokens}")
268
+ return False
269
+
270
+ logger.info(f"+= help: {help_command}")
271
+ print(help_content)
272
+ content_section = [
273
+ "```bash",
274
+ help_content,
275
+ "```",
276
+ ]
277
+ else:
278
+ for macro, macro_value in macros.items():
279
+ if macro in template_line:
280
+ content_section = macro_value
281
+ break
282
+
283
+ content += content_section
284
+
285
+ return file.save_text(filename, content)
@@ -0,0 +1,30 @@
1
+ from typing import List, Dict
2
+
3
+
4
+ # name, url, marquee, description
5
+ def Items(
6
+ items: List[Dict[str, str]],
7
+ ) -> List[str]:
8
+ return [
9
+ (
10
+ "[`{}`]({}) [![image]({})]({}) {}".format(
11
+ item["name"],
12
+ item.get(
13
+ "url",
14
+ "#",
15
+ ),
16
+ item.get(
17
+ "marquee",
18
+ "https://github.com/kamangir/assets/raw/main/blue-plugin/marquee.png?raw=true",
19
+ ),
20
+ item.get(
21
+ "url",
22
+ "#",
23
+ ),
24
+ item.get("description", ""),
25
+ )
26
+ if "name" in item
27
+ else ""
28
+ )
29
+ for item in items
30
+ ]
@@ -0,0 +1,19 @@
1
+ NAME = "bluer_objects"
2
+
3
+ ICON = "🌀"
4
+
5
+ DESCRIPTION = f"{ICON} data objects for Bash."
6
+
7
+ VERSION = "6.3.1"
8
+
9
+ REPO_NAME = "bluer-objects"
10
+
11
+ MARQUEE = (
12
+ "https://github.com/kamangir/assets/raw/main/blue-objects/marquee.png?raw=true"
13
+ )
14
+
15
+ ALIAS = "@objects"
16
+
17
+
18
+ def fullname() -> str:
19
+ return f"{NAME}-{VERSION}"
@@ -0,0 +1,16 @@
1
+ from blueness.argparse.generic import main
2
+
3
+ from bluer_objects import NAME, VERSION, DESCRIPTION, ICON, README
4
+ from bluer_objects.logger import logger
5
+
6
+ main(
7
+ ICON=ICON,
8
+ NAME=NAME,
9
+ DESCRIPTION=DESCRIPTION,
10
+ VERSION=VERSION,
11
+ main_filename=__file__,
12
+ tasks={
13
+ "build_README": lambda _: README.build_me(),
14
+ },
15
+ logger=logger,
16
+ )
@@ -0,0 +1,22 @@
1
+ ABCLI_AWS_REGION=ca-central-1
2
+
3
+ ABCLI_AWS_S3_BUCKET_NAME=kamangir
4
+
5
+ ABCLI_AWS_S3_PREFIX=bolt
6
+
7
+ ABCLI_AWS_S3_PUBLIC_BUCKET_NAME=kamangir-public
8
+
9
+ ABCLI_PUBLIC_PREFIX=https://kamangir-public.s3.ca-central-1.amazonaws.com
10
+
11
+ VANWATCH_TEST_OBJECT=vanwatch-test-object-v2
12
+
13
+ # refer to ABCLI_AWS_* in sample.env for details
14
+ ABCLI_AWS_RDS_DB=abcli
15
+ ABCLI_AWS_RDS_PORT=3306
16
+ ABCLI_AWS_RDS_USER=admin
17
+
18
+ DATABRICKS_WORKSPACE=abcli-v4
19
+
20
+ ABCLI_MLFLOW_URL_SUBDOMAIN=ml
21
+
22
+ ABCLI_MLFLOW_EXPERIMENT_PREFIX=/Users/kamangirblog@gmail.com/