bluer-objects 6.104.1__py3-none-any.whl → 6.464.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.
Files changed (170) hide show
  1. bluer_objects/.abcli/abcli.sh +6 -0
  2. bluer_objects/.abcli/alias.sh +13 -6
  3. bluer_objects/.abcli/assets/cd.sh +20 -0
  4. bluer_objects/.abcli/assets/mv.sh +34 -0
  5. bluer_objects/.abcli/assets/publish.sh +40 -0
  6. bluer_objects/.abcli/assets.sh +15 -0
  7. bluer_objects/.abcli/create_test_asset.sh +10 -0
  8. bluer_objects/.abcli/download.sh +3 -1
  9. bluer_objects/.abcli/file.sh +15 -4
  10. bluer_objects/.abcli/gif.sh +18 -0
  11. bluer_objects/.abcli/host.sh +23 -7
  12. bluer_objects/.abcli/ls.sh +19 -8
  13. bluer_objects/.abcli/metadata/download.sh +9 -0
  14. bluer_objects/.abcli/metadata/edit.sh +15 -0
  15. bluer_objects/.abcli/metadata/upload.sh +9 -0
  16. bluer_objects/.abcli/mlflow/browse.sh +2 -0
  17. bluer_objects/.abcli/mlflow/deploy.sh +21 -5
  18. bluer_objects/.abcli/mlflow/lock/lock.sh +11 -0
  19. bluer_objects/.abcli/mlflow/lock/unlock.sh +12 -0
  20. bluer_objects/.abcli/mlflow/lock.sh +15 -0
  21. bluer_objects/.abcli/mlflow/tags/search.sh +1 -5
  22. bluer_objects/.abcli/mlflow.sh +0 -2
  23. bluer_objects/.abcli/pdf/convert.sh +92 -0
  24. bluer_objects/.abcli/pdf.sh +15 -0
  25. bluer_objects/.abcli/storage/clear.sh +2 -0
  26. bluer_objects/.abcli/tests/clone.sh +2 -3
  27. bluer_objects/.abcli/tests/create_test_asset.sh +16 -0
  28. bluer_objects/.abcli/tests/file.sh +64 -0
  29. bluer_objects/.abcli/tests/gif.sh +3 -3
  30. bluer_objects/.abcli/tests/help.sh +23 -7
  31. bluer_objects/.abcli/tests/ls.sh +11 -4
  32. bluer_objects/.abcli/tests/metadata.sh +35 -0
  33. bluer_objects/.abcli/tests/mlflow_lock.sh +30 -0
  34. bluer_objects/.abcli/tests/mlflow_tags.sh +1 -1
  35. bluer_objects/.abcli/tests/open.sh +11 -0
  36. bluer_objects/.abcli/tests/open_gif_open.sh +14 -0
  37. bluer_objects/.abcli/tests/pdf.sh +39 -0
  38. bluer_objects/.abcli/tests/storage_clear.sh +11 -0
  39. bluer_objects/.abcli/tests/storage_public_upload.sh +25 -0
  40. bluer_objects/.abcli/tests/storage_status.sh +12 -0
  41. bluer_objects/.abcli/tests/{storage.sh → storage_upload_download.sh} +26 -8
  42. bluer_objects/.abcli/upload.sh +26 -2
  43. bluer_objects/README/__init__.py +7 -22
  44. bluer_objects/README/alias.py +67 -0
  45. bluer_objects/README/build/__init__.py +0 -0
  46. bluer_objects/README/build/aliases.py +23 -0
  47. bluer_objects/README/build/docs.py +23 -0
  48. bluer_objects/README/build/modules.py +9 -0
  49. bluer_objects/README/consts.py +44 -0
  50. bluer_objects/README/functions.py +154 -204
  51. bluer_objects/README/items.py +78 -6
  52. bluer_objects/README/process/__init__.py +0 -0
  53. bluer_objects/README/process/assets.py +36 -0
  54. bluer_objects/README/process/details.py +20 -0
  55. bluer_objects/README/process/envs.py +23 -0
  56. bluer_objects/README/process/help.py +27 -0
  57. bluer_objects/README/process/include.py +40 -0
  58. bluer_objects/README/process/legacy.py +21 -0
  59. bluer_objects/README/process/mermaid.py +20 -0
  60. bluer_objects/README/process/national_internet.py +55 -0
  61. bluer_objects/README/process/objects.py +32 -0
  62. bluer_objects/README/process/signature.py +35 -0
  63. bluer_objects/README/process/title.py +44 -0
  64. bluer_objects/README/process/variables.py +12 -0
  65. bluer_objects/__init__.py +1 -1
  66. bluer_objects/assets/__init__.py +0 -0
  67. bluer_objects/assets/__main__.py +57 -0
  68. bluer_objects/assets/functions.py +62 -0
  69. bluer_objects/config.env +13 -1
  70. bluer_objects/env.py +27 -1
  71. bluer_objects/file/__main__.py +52 -7
  72. bluer_objects/file/functions.py +21 -4
  73. bluer_objects/file/load.py +2 -9
  74. bluer_objects/file/save.py +17 -24
  75. bluer_objects/graphics/__main__.py +7 -0
  76. bluer_objects/graphics/gif.py +11 -7
  77. bluer_objects/graphics/screen.py +9 -8
  78. bluer_objects/help/assets.py +93 -0
  79. bluer_objects/help/create_test_asset.py +22 -0
  80. bluer_objects/help/download.py +17 -3
  81. bluer_objects/help/file.py +59 -0
  82. bluer_objects/help/functions.py +9 -1
  83. bluer_objects/help/gif.py +25 -0
  84. bluer_objects/help/host.py +6 -4
  85. bluer_objects/help/ls.py +26 -3
  86. bluer_objects/help/metadata.py +51 -0
  87. bluer_objects/help/mlflow/__init__.py +23 -2
  88. bluer_objects/help/mlflow/cache.py +2 -4
  89. bluer_objects/help/mlflow/lock.py +52 -0
  90. bluer_objects/help/mlflow/tags.py +34 -23
  91. bluer_objects/help/pdf.py +67 -0
  92. bluer_objects/help/upload.py +10 -3
  93. bluer_objects/host/functions.py +4 -1
  94. bluer_objects/logger/confusion_matrix.py +76 -0
  95. bluer_objects/logger/image.py +110 -0
  96. bluer_objects/logger/stitch.py +107 -0
  97. bluer_objects/markdown.py +8 -6
  98. bluer_objects/metadata/__init__.py +1 -0
  99. bluer_objects/metadata/flatten.py +27 -0
  100. bluer_objects/mlflow/__init__.py +1 -1
  101. bluer_objects/mlflow/__main__.py +49 -31
  102. bluer_objects/mlflow/lock/__init__.py +1 -0
  103. bluer_objects/mlflow/lock/__main__.py +58 -0
  104. bluer_objects/mlflow/lock/functions.py +121 -0
  105. bluer_objects/mlflow/logging.py +53 -41
  106. bluer_objects/mlflow/models.py +7 -0
  107. bluer_objects/mlflow/objects.py +7 -0
  108. bluer_objects/mlflow/runs.py +10 -1
  109. bluer_objects/mlflow/serverless/__init__.py +3 -0
  110. bluer_objects/mlflow/serverless/api.py +88 -0
  111. bluer_objects/mlflow/serverless/read.py +19 -0
  112. bluer_objects/mlflow/serverless/search.py +35 -0
  113. bluer_objects/mlflow/serverless/write.py +42 -0
  114. bluer_objects/mlflow/tags.py +59 -9
  115. bluer_objects/objects.py +3 -1
  116. bluer_objects/pdf/__init__.py +1 -0
  117. bluer_objects/pdf/__main__.py +78 -0
  118. bluer_objects/pdf/convert/__init__.py +0 -0
  119. bluer_objects/pdf/convert/batch.py +54 -0
  120. bluer_objects/pdf/convert/combination.py +32 -0
  121. bluer_objects/pdf/convert/convert.py +110 -0
  122. bluer_objects/pdf/convert/image.py +53 -0
  123. bluer_objects/pdf/convert/md.py +97 -0
  124. bluer_objects/pdf/convert/missing.py +96 -0
  125. bluer_objects/pdf/convert/pdf.py +37 -0
  126. bluer_objects/sample.env +6 -0
  127. bluer_objects/storage/WebDAV.py +11 -7
  128. bluer_objects/storage/WebDAVrequest.py +360 -0
  129. bluer_objects/storage/WebDAVzip.py +26 -29
  130. bluer_objects/storage/__init__.py +28 -1
  131. bluer_objects/storage/__main__.py +40 -6
  132. bluer_objects/storage/base.py +84 -5
  133. bluer_objects/storage/policies.py +7 -0
  134. bluer_objects/storage/s3.py +367 -0
  135. bluer_objects/testing/__main__.py +6 -0
  136. bluer_objects/tests/test_README_consts.py +71 -0
  137. bluer_objects/tests/test_README_items.py +128 -0
  138. bluer_objects/tests/test_alias.py +33 -0
  139. bluer_objects/tests/test_env.py +42 -7
  140. bluer_objects/tests/test_file_download.py +30 -0
  141. bluer_objects/tests/test_file_load_save.py +1 -2
  142. bluer_objects/tests/test_file_load_save_text.py +46 -0
  143. bluer_objects/tests/test_graphics_gif.py +2 -0
  144. bluer_objects/tests/test_log_image_grid.py +29 -0
  145. bluer_objects/tests/test_logger_confusion_matrix.py +18 -0
  146. bluer_objects/tests/test_logger_matrix.py +2 -2
  147. bluer_objects/tests/test_logger_stitch_images.py +47 -0
  148. bluer_objects/tests/test_metadata.py +12 -6
  149. bluer_objects/tests/test_metadata_flatten.py +109 -0
  150. bluer_objects/tests/test_mlflow.py +114 -5
  151. bluer_objects/tests/test_mlflow_lock.py +26 -0
  152. bluer_objects/tests/test_objects.py +2 -0
  153. bluer_objects/tests/test_shell.py +34 -0
  154. bluer_objects/tests/test_storage.py +8 -21
  155. bluer_objects/tests/test_storage_base.py +39 -0
  156. bluer_objects/tests/test_storage_s3.py +67 -0
  157. bluer_objects/tests/test_storage_webdav_request.py +75 -0
  158. bluer_objects/tests/test_storage_webdav_zip.py +42 -0
  159. bluer_objects/tests/test_web_is_accessible.py +11 -0
  160. {bluer_objects-6.104.1.dist-info → bluer_objects-6.464.1.dist-info}/METADATA +20 -11
  161. bluer_objects-6.464.1.dist-info/RECORD +228 -0
  162. {bluer_objects-6.104.1.dist-info → bluer_objects-6.464.1.dist-info}/WHEEL +1 -1
  163. bluer_objects/.abcli/storage/download_file.sh +0 -9
  164. bluer_objects/.abcli/storage/exists.sh +0 -8
  165. bluer_objects/.abcli/storage/list.sh +0 -8
  166. bluer_objects/.abcli/storage/rm.sh +0 -11
  167. bluer_objects/.abcli/tests/mlflow_test.sh +0 -7
  168. bluer_objects-6.104.1.dist-info/RECORD +0 -143
  169. {bluer_objects-6.104.1.dist-info → bluer_objects-6.464.1.dist-info}/licenses/LICENSE +0 -0
  170. {bluer_objects-6.104.1.dist-info → bluer_objects-6.464.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,40 @@
1
+ from typing import List
2
+
3
+ from bluer_objects import file
4
+ from bluer_objects import NAME as MY_NAME
5
+ from bluer_objects.logger import logger
6
+
7
+
8
+ def process_include(
9
+ template_line: str,
10
+ template_path: str,
11
+ ) -> List[str]:
12
+ include_filename_relative = template_line.split(" ")[1].strip()
13
+ include_filename = file.absolute(
14
+ include_filename_relative,
15
+ template_path,
16
+ )
17
+
18
+ success, content_section = file.load_text(include_filename)
19
+ if not success:
20
+ return success
21
+
22
+ content_section = [
23
+ line for line in content_section if not line.startswith("used by:")
24
+ ]
25
+
26
+ include_title = (template_line.split(" ", 2) + ["", "", ""])[2]
27
+ if include_title:
28
+ content_section = [f"## {include_title}"] + content_section[1:]
29
+
30
+ if "include:::noref" not in template_line:
31
+ content_section += [
32
+ "using [{}]({}).".format(
33
+ file.name(include_filename),
34
+ include_filename_relative,
35
+ )
36
+ ]
37
+
38
+ logger.info(f"{MY_NAME}.build: including {include_filename} ...")
39
+
40
+ return content_section
@@ -0,0 +1,21 @@
1
+ from typing import List
2
+
3
+ from bluer_objects.logger import logger
4
+
5
+
6
+ def apply_legacy_on_line(line: str) -> str:
7
+ for before, after in {
8
+ "yaml:::": "metadata:::",
9
+ "--help--": "help:::",
10
+ "--include": "include:::",
11
+ "--table--": "items:::",
12
+ "--signature--": "signature:::",
13
+ }.items():
14
+ line = line.replace(before, after)
15
+ return line
16
+
17
+
18
+ def apply_legacy(template: List[str]) -> List[str]:
19
+ logger.info("applying legacy conversions...")
20
+ template = [apply_legacy_on_line(line) for line in template]
21
+ return template
@@ -0,0 +1,20 @@
1
+ from typing import List
2
+
3
+ from bluer_objects.logger import logger
4
+
5
+
6
+ def process_mermaid(template_line: str) -> List[str]:
7
+ template_line_pieces = template_line.split('"')
8
+ if len(template_line_pieces) != 3:
9
+ logger.error(f"🧜🏽‍♀️ mermaid line not in expected format: {template_line}.")
10
+ return False
11
+
12
+ template_line_pieces[1] = (
13
+ template_line_pieces[1]
14
+ .replace("<", "&lt;")
15
+ .replace(">", "&gt;")
16
+ .replace(" ", "<br>")
17
+ .replace("~~", " ")
18
+ )
19
+
20
+ return ['"'.join(template_line_pieces)]
@@ -0,0 +1,55 @@
1
+ from typing import List
2
+
3
+ from bluer_options import env
4
+ from bluer_options.help.parsing import list_of_modules
5
+
6
+ from bluer_objects import file
7
+ from bluer_objects import path
8
+ from bluer_objects.env import abcli_path_git
9
+ from bluer_objects.README.consts import github_kamangir
10
+ from bluer_objects.logger import logger
11
+
12
+
13
+ def process_national_internet(
14
+ filename: str,
15
+ content: List[str],
16
+ ) -> List[str]:
17
+ if env.BLUER_AI_WEB_STATUS == "online":
18
+ return content
19
+
20
+ logger.info("🇮🇷 national internet adjustments...")
21
+
22
+ for this, that in {
23
+ "{}/{}/{}/main".format(
24
+ github_kamangir,
25
+ repo_name,
26
+ where,
27
+ ): "{}/{}".format(
28
+ abcli_path_git,
29
+ repo_name,
30
+ )
31
+ for repo_name in (
32
+ [
33
+ "assets",
34
+ "assets2",
35
+ ]
36
+ + [module.replace("_", "-") for module in list_of_modules]
37
+ )
38
+ for where in [
39
+ "blob",
40
+ "raw",
41
+ "tree",
42
+ ]
43
+ }.items():
44
+ content = [
45
+ line.replace(
46
+ this,
47
+ path.relative(
48
+ that,
49
+ file.path(filename),
50
+ ),
51
+ )
52
+ for line in content
53
+ ]
54
+
55
+ return content
@@ -0,0 +1,32 @@
1
+ from bluer_objects import env
2
+
3
+
4
+ def process_objects(template_line: str) -> str:
5
+ def suffix(token: str):
6
+ words = token.split(":::")
7
+ object_name = token.split(":::")[1].strip()
8
+
9
+ if len(words) <= 2:
10
+ return f"{object_name}.tar.gz"
11
+
12
+ filename = words[2].strip()
13
+ return f"{object_name}/{filename}"
14
+
15
+ if "object:::" in template_line:
16
+ template_line = " ".join(
17
+ [
18
+ (
19
+ "[{}](https://{}.{}/{})".format(
20
+ suffix(token),
21
+ env.S3_PUBLIC_STORAGE_BUCKET,
22
+ env.S3_STORAGE_ENDPOINT_URL.split("https://", 1)[1],
23
+ suffix(token),
24
+ )
25
+ if token.startswith("object:::")
26
+ else token
27
+ )
28
+ for token in template_line.split(" ")
29
+ ]
30
+ )
31
+
32
+ return template_line
@@ -0,0 +1,35 @@
1
+ from typing import List
2
+
3
+ from bluer_objects import ICON as MY_ICON
4
+ from bluer_objects.logger import logger
5
+
6
+
7
+ def signature(
8
+ REPO_NAME: str,
9
+ NAME: str,
10
+ ICON: str,
11
+ MODULE_NAME: str,
12
+ VERSION: str,
13
+ ) -> List[str]:
14
+ return [
15
+ "",
16
+ " ".join(
17
+ [
18
+ f"[![pylint](https://github.com/kamangir/{REPO_NAME}/actions/workflows/pylint.yml/badge.svg)](https://github.com/kamangir/{REPO_NAME}/actions/workflows/pylint.yml)",
19
+ f"[![pytest](https://github.com/kamangir/{REPO_NAME}/actions/workflows/pytest.yml/badge.svg)](https://github.com/kamangir/{REPO_NAME}/actions/workflows/pytest.yml)",
20
+ f"[![bashtest](https://github.com/kamangir/{REPO_NAME}/actions/workflows/bashtest.yml/badge.svg)](https://github.com/kamangir/{REPO_NAME}/actions/workflows/bashtest.yml)",
21
+ f"[![PyPI version](https://img.shields.io/pypi/v/{MODULE_NAME}.svg)](https://pypi.org/project/{MODULE_NAME}/)",
22
+ f"[![PyPI - Downloads](https://img.shields.io/pypi/dd/{MODULE_NAME})](https://pypistats.org/packages/{MODULE_NAME})",
23
+ ]
24
+ ),
25
+ "",
26
+ "built by {} [`{}`]({}), based on {}[`{}-{}`]({}).".format(
27
+ MY_ICON,
28
+ "bluer README",
29
+ "https://github.com/kamangir/bluer-objects/tree/main/bluer_objects/README",
30
+ f"{ICON} " if ICON else "",
31
+ NAME,
32
+ VERSION,
33
+ f"https://github.com/kamangir/{REPO_NAME}",
34
+ ),
35
+ ]
@@ -0,0 +1,44 @@
1
+ import os
2
+ from typing import List, Tuple
3
+
4
+ from bluer_objects import file
5
+ from bluer_objects.logger import logger
6
+
7
+
8
+ def process_title(
9
+ template_line: str,
10
+ filename: str,
11
+ ) -> Tuple[bool, List[str]]:
12
+ template_line_pieces = [
13
+ piece for piece in template_line.strip().split(":::") if piece
14
+ ]
15
+ reference = template_line_pieces[1] if len(template_line_pieces) >= 2 else "docs"
16
+
17
+ filename_path_pieces = file.path(filename).split(os.sep)
18
+ if reference not in filename_path_pieces:
19
+ logger.error(
20
+ "reference: {} not found in {}.".format(
21
+ reference,
22
+ template_line,
23
+ )
24
+ )
25
+ return False, []
26
+
27
+ title_pieces = filename_path_pieces[filename_path_pieces.index(reference) + 1 :]
28
+ filename_name = file.name(filename)
29
+ if filename_name != "README":
30
+ title_pieces.append(filename_name)
31
+
32
+ return True, [
33
+ "# {}".format(
34
+ ": ".join(
35
+ [
36
+ piece.replace(
37
+ "_",
38
+ "-",
39
+ )
40
+ for piece in title_pieces
41
+ ]
42
+ )
43
+ )
44
+ ]
@@ -0,0 +1,12 @@
1
+ from typing import Dict
2
+
3
+ from bluer_objects.logger import logger
4
+
5
+
6
+ variables: Dict[str, str] = {}
7
+
8
+
9
+ def process_variable(template_line: str):
10
+ key, value = template_line.split("set:::", 1)[1].split(" ", 1)
11
+ variables[key] = value
12
+ logger.info(f"{key} = {value}")
bluer_objects/__init__.py CHANGED
@@ -4,7 +4,7 @@ ICON = "🌀"
4
4
 
5
5
  DESCRIPTION = f"{ICON} Object management in Bash."
6
6
 
7
- VERSION = "6.104.1"
7
+ VERSION = "6.464.1"
8
8
 
9
9
  REPO_NAME = "bluer-objects"
10
10
 
File without changes
@@ -0,0 +1,57 @@
1
+ import argparse
2
+
3
+ from blueness import module
4
+ from blueness.argparse.generic import sys_exit
5
+
6
+ from bluer_objects import NAME
7
+ from bluer_objects.assets.functions import publish
8
+ from bluer_objects.logger import logger
9
+
10
+ NAME = module.name(__file__, NAME)
11
+
12
+ parser = argparse.ArgumentParser(NAME)
13
+ parser.add_argument(
14
+ "task",
15
+ type=str,
16
+ help="publish",
17
+ )
18
+ parser.add_argument(
19
+ "--arg",
20
+ type=bool,
21
+ default=0,
22
+ help="0|1",
23
+ )
24
+ parser.add_argument(
25
+ "--object_name",
26
+ type=str,
27
+ )
28
+ parser.add_argument(
29
+ "--extensions",
30
+ type=str,
31
+ default="png",
32
+ help="png+txt",
33
+ )
34
+ parser.add_argument(
35
+ "--prefix",
36
+ type=str,
37
+ default="",
38
+ )
39
+ parser.add_argument(
40
+ "--asset_name",
41
+ type=str,
42
+ default="",
43
+ )
44
+ args = parser.parse_args()
45
+
46
+ success = False
47
+ if args.task == "publish":
48
+ success = publish(
49
+ object_name=args.object_name,
50
+ list_of_extensions=args.extensions.split("+"),
51
+ prefix=args.prefix,
52
+ asset_name=args.asset_name,
53
+ )
54
+ else:
55
+ success = None
56
+
57
+ sys_exit(logger, NAME, args.task, success)
@@ -0,0 +1,62 @@
1
+ import os
2
+ from typing import List
3
+ import glob
4
+ from tqdm import tqdm
5
+
6
+ from blueness import module
7
+
8
+ from bluer_objects import objects, file
9
+ from bluer_objects.env import abcli_path_git
10
+ from bluer_objects import NAME
11
+ from bluer_objects.logger import logger
12
+
13
+
14
+ NAME = module.name(__file__, NAME)
15
+
16
+
17
+ def publish(
18
+ object_name: str,
19
+ list_of_extensions: List[str],
20
+ prefix: str = "",
21
+ asset_name: str = "",
22
+ log: bool = True,
23
+ ) -> bool:
24
+ if not asset_name:
25
+ asset_name = object_name
26
+ logger.info(
27
+ "{}.publish: {}/{}.* for {} -> {}".format(
28
+ NAME,
29
+ object_name,
30
+ prefix,
31
+ ", ".join(list_of_extensions),
32
+ asset_name,
33
+ )
34
+ )
35
+
36
+ for extension in tqdm(list_of_extensions):
37
+ for filename in glob.glob(
38
+ objects.path_of(
39
+ filename=f"{prefix}*.{extension}",
40
+ object_name=object_name,
41
+ )
42
+ ):
43
+ published_filename = os.path.join(
44
+ abcli_path_git,
45
+ "assets",
46
+ asset_name,
47
+ file.name_and_extension(filename).replace(
48
+ object_name,
49
+ asset_name,
50
+ ),
51
+ )
52
+
53
+ if not file.copy(
54
+ filename,
55
+ published_filename,
56
+ log=log,
57
+ ):
58
+ return False
59
+
60
+ logger.info(f"🔗 https://github.com/kamangir/assets/tree/main/{asset_name}")
61
+
62
+ return True
bluer_objects/config.env CHANGED
@@ -1,3 +1,15 @@
1
1
  ABCLI_MLFLOW_EXPERIMENT_PREFIX=experiment/
2
2
 
3
- BLUER_OBJECTS_STORAGE_INTERFACE=webdavzip
3
+ BLUER_OBJECTS_STORAGE_INTERFACE=s3
4
+
5
+ BLUER_OBJECTS_TEST_OBJECT=2025-09-22-13-11-08-cjbb3q
6
+
7
+ MLFLOW_IS_SERVERLESS=1
8
+
9
+ MLFLOW_LOCK_WAIT_FOR_CLEARANCE=3
10
+ MLFLOW_LOCK_WAIT_FOR_EXCLUSIVITY=1
11
+
12
+ S3_PUBLIC_STORAGE_BUCKET=kamangir-public
13
+ S3_STORAGE_BUCKET=kamangir
14
+
15
+ BLUER_OBJECTS_DEFAULT_ASSETS_VOL=2
bluer_objects/env.py CHANGED
@@ -1,4 +1,3 @@
1
- from typing import Union
2
1
  import os
3
2
 
4
3
  from bluer_options.env import load_config, load_env, get_env
@@ -35,8 +34,35 @@ DUMMY_TEXT = "This is some dummy text. This is some dummy text. This is some dum
35
34
 
36
35
  ABCLI_MLFLOW_EXPERIMENT_PREFIX = get_env("ABCLI_MLFLOW_EXPERIMENT_PREFIX")
37
36
 
37
+ S3_STORAGE_BUCKET = get_env("S3_STORAGE_BUCKET")
38
+ S3_PUBLIC_STORAGE_BUCKET = get_env("S3_PUBLIC_STORAGE_BUCKET")
39
+
40
+ S3_STORAGE_ENDPOINT_URL = get_env("S3_STORAGE_ENDPOINT_URL")
41
+ S3_STORAGE_AWS_ACCESS_KEY_ID = get_env("S3_STORAGE_AWS_ACCESS_KEY_ID")
42
+ S3_STORAGE_AWS_SECRET_ACCESS_KEY = get_env("S3_STORAGE_AWS_SECRET_ACCESS_KEY")
43
+
38
44
  BLUER_OBJECTS_STORAGE_INTERFACE = get_env("BLUER_OBJECTS_STORAGE_INTERFACE")
39
45
 
46
+ MLFLOW_DEPLOYMENT = get_env("MLFLOW_DEPLOYMENT", "local")
47
+ if MLFLOW_DEPLOYMENT == "local":
48
+ MLFLOW_TRACKING_URI = os.path.join(
49
+ os.environ.get("HOME"),
50
+ "mlflow",
51
+ )
52
+ else:
53
+ MLFLOW_TRACKING_URI = MLFLOW_DEPLOYMENT
54
+ os.environ["MLFLOW_TRACKING_URI"] = MLFLOW_TRACKING_URI
55
+ MLFLOW_LOG_ARTIFACTS = "arvan" not in MLFLOW_DEPLOYMENT
56
+
57
+ MLFLOW_LOCK_WAIT_FOR_CLEARANCE = get_env("MLFLOW_LOCK_WAIT_FOR_CLEARANCE", 3)
58
+ MLFLOW_LOCK_WAIT_FOR_EXCLUSIVITY = get_env("MLFLOW_LOCK_WAIT_FOR_EXCLUSIVITY", 1)
59
+
40
60
  WEBDAV_HOSTNAME = get_env("WEBDAV_HOSTNAME")
41
61
  WEBDAV_LOGIN = get_env("WEBDAV_LOGIN")
42
62
  WEBDAV_PASSWORD = get_env("WEBDAV_PASSWORD")
63
+
64
+ BLUER_OBJECTS_TEST_OBJECT = get_env("BLUER_OBJECTS_TEST_OBJECT")
65
+
66
+ MLFLOW_IS_SERVERLESS = get_env("MLFLOW_IS_SERVERLESS", 1)
67
+
68
+ BLUER_OBJECTS_DEFAULT_ASSETS_VOL = get_env("BLUER_OBJECTS_DEFAULT_ASSETS_VOL")
@@ -31,24 +31,69 @@ parser.add_argument(
31
31
  help="<that-1+that-2+that-3>",
32
32
  )
33
33
  parser.add_argument(
34
- "--size",
34
+ "--pretty",
35
35
  type=int,
36
- default=16,
36
+ default=1,
37
+ help="0 | 1",
38
+ )
39
+ parser.add_argument(
40
+ "--save",
41
+ type=int,
42
+ default=1,
43
+ help="0 | 1",
44
+ )
45
+ parser.add_argument(
46
+ "--whole_line",
47
+ type=int,
48
+ default=0,
49
+ help="0 | 1",
50
+ )
51
+ parser.add_argument(
52
+ "--log",
53
+ type=int,
54
+ default=0,
55
+ help="0 | 1",
56
+ )
57
+ parser.add_argument(
58
+ "--cat",
59
+ type=int,
60
+ default=0,
61
+ help="0 | 1",
37
62
  )
38
63
  args = parser.parse_args()
39
64
 
40
65
  success = False
41
66
  if args.task == "replace":
42
- logger.info(f"{NAME}.{args.task}: {args.this} -> {args.that} in {args.filename}")
67
+ logger.info(
68
+ f'{NAME}.{args.task}: "{args.this}" -> "{args.that}" in {args.filename}'
69
+ )
43
70
 
44
- success, content = file.load_text(args.filename)
71
+ success, content = file.load_text(
72
+ args.filename,
73
+ log=args.log == 1,
74
+ )
45
75
  if success:
46
76
  for this, that in tqdm(zip(args.this.split("+"), args.that.split("+"))):
47
- content = [line.replace(this, that) for line in content]
77
+ if args.whole_line:
78
+ content = [that if line == this else line for line in content]
79
+ else:
80
+ content = [line.replace(this, that) for line in content]
81
+
82
+ if args.save == 1:
83
+ success = file.save_text(
84
+ args.filename,
85
+ content,
86
+ log=args.log == 1,
87
+ )
88
+
89
+ if success and args.cat:
90
+ for line in content:
91
+ if any(this in line for this in args.this.split("+")):
92
+ logger.info(line)
48
93
 
49
- success = file.save_text(args.filename, content)
50
94
  elif args.task == "size":
51
- print(string.pretty_bytes(file.size(args.filename)))
95
+ size = file.size(args.filename)
96
+ print(string.pretty_bytes(size) if args.pretty == 1 else size)
52
97
  success = True
53
98
  else:
54
99
  success = None
@@ -117,25 +117,29 @@ def copy(
117
117
  return False
118
118
 
119
119
  if log:
120
- logger.info(f"{NAME}: {source} -> {destination}")
120
+ logger.info(f"{source} -copy-> {destination}")
121
121
 
122
122
  return True
123
123
 
124
124
 
125
125
  def delete(
126
126
  filename: str,
127
+ log: bool = False,
127
128
  ) -> bool:
128
129
  if not os.path.isfile(filename):
129
130
  return True
130
131
 
131
132
  try:
132
133
  os.remove(filename)
133
-
134
- return True
135
134
  except:
136
135
  crash_report(f"{NAME}: delete({filename}): failed.")
137
136
  return False
138
137
 
138
+ if log:
139
+ logger.info(f"deleted {filename}.")
140
+
141
+ return True
142
+
139
143
 
140
144
  def download(
141
145
  url: str,
@@ -150,6 +154,8 @@ def download(
150
154
  return True
151
155
 
152
156
  try:
157
+ os.makedirs(path(filename), exist_ok=True)
158
+
153
159
  # https://stackoverflow.com/a/27406501
154
160
  with urllib3.PoolManager().request(
155
161
  "GET", url, preload_content=False
@@ -163,7 +169,14 @@ def download(
163
169
  return False
164
170
 
165
171
  if log:
166
- logger.info(f"{NAME}: {url} -> {filename}")
172
+ logger.info(
173
+ "{}: {} -{}-> {}".format(
174
+ NAME,
175
+ url,
176
+ string.pretty_bytes(size(filename)),
177
+ filename,
178
+ )
179
+ )
167
180
 
168
181
  return True
169
182
 
@@ -236,6 +249,7 @@ def list_of(
236
249
  def move(
237
250
  source: str,
238
251
  destination: str,
252
+ log: bool = True,
239
253
  ) -> bool:
240
254
  try:
241
255
  os.makedirs(path(destination), exist_ok=True)
@@ -246,6 +260,9 @@ def move(
246
260
  crash_report(f"{NAME}: move({source},{destination}): failed.")
247
261
  return False
248
262
 
263
+ if log:
264
+ logger.info(f"{source} -move-> {destination}")
265
+
249
266
  return True
250
267
 
251
268
 
@@ -149,21 +149,14 @@ def load_matrix(
149
149
  def load_text(
150
150
  filename,
151
151
  ignore_error=False,
152
- count=-1,
153
152
  log=False,
154
153
  ) -> Tuple[bool, List[str]]:
155
154
  success = True
156
155
  text = []
157
156
 
158
157
  try:
159
- if count == -1:
160
- with open(filename, "r") as fp:
161
- text = fp.read()
162
- text = text.split("\n")
163
- else:
164
- # https://stackoverflow.com/a/1767589/10917551
165
- with open(filename) as fp:
166
- text = [next(fp) for _ in range(count)]
158
+ with open(filename, "r") as fp:
159
+ text = fp.read().splitlines()
167
160
  except:
168
161
  success = False
169
162
  if not ignore_error: