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,110 @@
1
+ import argparse
2
+
3
+ from blueness import module
4
+ from blueness.argparse.generic import sys_exit
5
+
6
+
7
+ from bluer_objects import NAME
8
+ from bluer_objects.metadata.get import get
9
+ from bluer_objects.metadata.post import post
10
+ from bluer_objects.metadata.enums import MetadataSourceType
11
+ from bluer_objects.logger import logger
12
+
13
+ NAME = module.name(__file__, NAME)
14
+
15
+
16
+ parser = argparse.ArgumentParser(NAME)
17
+ parser.add_argument(
18
+ "task",
19
+ type=str,
20
+ default="",
21
+ help="get|post",
22
+ )
23
+ parser.add_argument(
24
+ "--default",
25
+ type=str,
26
+ default="",
27
+ )
28
+ parser.add_argument(
29
+ "--delim",
30
+ type=str,
31
+ default="",
32
+ )
33
+ parser.add_argument(
34
+ "--dict_keys",
35
+ type=int,
36
+ default=0,
37
+ help="0|1",
38
+ )
39
+ parser.add_argument(
40
+ "--dict_values",
41
+ type=int,
42
+ default=0,
43
+ help="0|1",
44
+ )
45
+ parser.add_argument(
46
+ "--filename",
47
+ type=str,
48
+ default="metadata.yaml",
49
+ )
50
+ parser.add_argument(
51
+ "--is_base64_encoded",
52
+ type=int,
53
+ default=0,
54
+ help="0|1",
55
+ )
56
+ parser.add_argument(
57
+ "--key",
58
+ type=str,
59
+ )
60
+ parser.add_argument(
61
+ "--source",
62
+ type=str,
63
+ )
64
+ parser.add_argument(
65
+ "--source_type",
66
+ type=str,
67
+ default=MetadataSourceType.FILENAME.name.lower(),
68
+ help="|".join([source_type.name.lower() for source_type in MetadataSourceType]),
69
+ )
70
+ parser.add_argument(
71
+ "--value",
72
+ type=str,
73
+ )
74
+ parser.add_argument(
75
+ "--verbose",
76
+ type=int,
77
+ default="0",
78
+ help="0|1",
79
+ )
80
+ args = parser.parse_args()
81
+
82
+ delim = " " if args.delim == "space" else args.delim
83
+
84
+ success = False
85
+ if args.task == "get":
86
+ success = True
87
+ output = get(
88
+ key=args.key,
89
+ default=args.default,
90
+ source=args.source,
91
+ source_type=MetadataSourceType[args.source_type.upper()],
92
+ dict_keys=args.dict_keys,
93
+ dict_values=args.dict_values,
94
+ filename=args.filename,
95
+ )
96
+ print(delim.join(output) if isinstance(output, list) else output)
97
+ elif args.task == "post":
98
+ success = post(
99
+ key=args.key,
100
+ value=args.value,
101
+ filename=args.filename,
102
+ source=args.source,
103
+ source_type=MetadataSourceType[args.source_type.upper()],
104
+ is_base64_encoded=args.is_base64_encoded,
105
+ verbose=args.verbose == 1,
106
+ )
107
+ else:
108
+ success = None
109
+
110
+ sys_exit(logger, NAME, args.task, success)
@@ -0,0 +1,29 @@
1
+ import os
2
+ from enum import Enum, auto
3
+
4
+ from bluer_objects import objects
5
+ from bluer_objects.env import abcli_object_path
6
+
7
+
8
+ class MetadataSourceType(Enum):
9
+ FILENAME = auto()
10
+ OBJECT = auto()
11
+ PATH = auto()
12
+
13
+ def filename(self, source: str, filename="metadata.yaml"):
14
+ if self == MetadataSourceType.FILENAME:
15
+ return source
16
+
17
+ if self == MetadataSourceType.OBJECT:
18
+ return os.path.join(
19
+ objects.object_path(source),
20
+ filename,
21
+ )
22
+
23
+ if self == MetadataSourceType.PATH:
24
+ return os.path.join(
25
+ abcli_object_path if source == "." else source,
26
+ filename,
27
+ )
28
+
29
+ return f"unknown-source-type:{self.name.lower()}"
@@ -0,0 +1,89 @@
1
+ from typing import Any
2
+
3
+
4
+ from bluer_objects import file
5
+ from bluer_objects import objects
6
+ from bluer_objects.metadata.enums import MetadataSourceType
7
+
8
+
9
+ def get(
10
+ key,
11
+ default="",
12
+ source=".",
13
+ source_type: MetadataSourceType = MetadataSourceType.FILENAME,
14
+ filename: str = "metadata.yaml",
15
+ dict_keys: bool = False,
16
+ dict_values: bool = False,
17
+ ) -> Any:
18
+ success, metadata = file.load_yaml(
19
+ source_type.filename(source, filename),
20
+ ignore_error=True,
21
+ )
22
+ if not success:
23
+ return default
24
+
25
+ try:
26
+ output = metadata
27
+ for key_ in [key_ for key_ in key.split(".") if key_]:
28
+ output = output.get(key_, default)
29
+
30
+ if dict_keys:
31
+ output = list(output.keys())
32
+ elif dict_values:
33
+ output = list(output.values())
34
+
35
+ return output
36
+ except Exception as e:
37
+ return type(e).__name__
38
+
39
+
40
+ def get_from_file(
41
+ filename: str,
42
+ key,
43
+ default="",
44
+ **kwargs,
45
+ ) -> Any:
46
+ return get(
47
+ key=key,
48
+ default=default,
49
+ source=filename,
50
+ source_type=MetadataSourceType.FILENAME,
51
+ **kwargs,
52
+ )
53
+
54
+
55
+ def get_from_object(
56
+ object_name: str,
57
+ key,
58
+ default="",
59
+ download: bool = False,
60
+ **kwargs,
61
+ ) -> Any:
62
+ if download and not objects.download(
63
+ object_name=object_name,
64
+ filename="metadata.yaml",
65
+ ):
66
+ return default
67
+
68
+ return get(
69
+ key=key,
70
+ default=default,
71
+ source=object_name,
72
+ source_type=MetadataSourceType.OBJECT,
73
+ **kwargs,
74
+ )
75
+
76
+
77
+ def get_from_path(
78
+ path: str,
79
+ key: str,
80
+ default="",
81
+ **kwargs,
82
+ ) -> Any:
83
+ return get(
84
+ key=key,
85
+ default=default,
86
+ source=path,
87
+ source_type=MetadataSourceType.PATH,
88
+ **kwargs,
89
+ )
@@ -0,0 +1,101 @@
1
+ from typing import Any
2
+ import base64
3
+ import copy
4
+
5
+ from blueness import module
6
+
7
+ from bluer_objects.metadata.enums import MetadataSourceType
8
+ from bluer_objects import NAME, file
9
+ from bluer_objects import objects
10
+ from bluer_objects.logger import logger
11
+
12
+ NAME = module.name(__file__, NAME)
13
+
14
+
15
+ def post(
16
+ key: str,
17
+ value: Any,
18
+ filename: str = "metadata.yaml",
19
+ source=".",
20
+ source_type: MetadataSourceType = MetadataSourceType.FILENAME,
21
+ is_base64_encoded=False,
22
+ verbose: bool = False,
23
+ ) -> bool:
24
+ if is_base64_encoded:
25
+ value = str(base64.b64decode(value))
26
+
27
+ filename = source_type.filename(source, filename)
28
+
29
+ _, metadata = file.load_yaml(filename, ignore_error=True)
30
+
31
+ metadata[key] = copy.deepcopy(value)
32
+
33
+ logger.info(
34
+ "{}.post[{}]: {}{}".format(
35
+ NAME,
36
+ filename,
37
+ key,
38
+ f"={value}" if verbose else "",
39
+ )
40
+ )
41
+
42
+ return file.save_yaml(filename, metadata)
43
+
44
+
45
+ def post_to_file(
46
+ filename: str,
47
+ key: str,
48
+ value: Any,
49
+ **kwargs,
50
+ ) -> bool:
51
+ return post(
52
+ key=key,
53
+ value=value,
54
+ source=filename,
55
+ source_type=MetadataSourceType.FILENAME,
56
+ **kwargs,
57
+ )
58
+
59
+
60
+ def post_to_object(
61
+ object_name: str,
62
+ key: str,
63
+ value: Any,
64
+ download: bool = False,
65
+ upload: bool = False,
66
+ **kwargs,
67
+ ) -> bool:
68
+ if download and not objects.download(
69
+ object_name=object_name,
70
+ filename="metadata.yaml",
71
+ ):
72
+ return False
73
+
74
+ if not post(
75
+ key=key,
76
+ value=value,
77
+ source=object_name,
78
+ source_type=MetadataSourceType.OBJECT,
79
+ **kwargs,
80
+ ):
81
+ return False
82
+
83
+ return not upload or objects.upload(
84
+ object_name=object_name,
85
+ filename="metadata.yaml",
86
+ )
87
+
88
+
89
+ def post_to_path(
90
+ path: str,
91
+ key: str,
92
+ value: Any,
93
+ **kwargs,
94
+ ) -> bool:
95
+ return post(
96
+ key=key,
97
+ value=value,
98
+ source=path,
99
+ source_type=MetadataSourceType.PATH,
100
+ **kwargs,
101
+ )
@@ -0,0 +1,28 @@
1
+ from bluer_objects.mlflow.logging import (
2
+ log_artifacts,
3
+ log_run,
4
+ )
5
+ from bluer_objects.mlflow.models import (
6
+ list_registered_models,
7
+ transition,
8
+ )
9
+ from bluer_objects.mlflow.objects import (
10
+ get_id,
11
+ to_experiment_name,
12
+ to_object_name,
13
+ rm,
14
+ )
15
+ from bluer_objects.mlflow.runs import (
16
+ end_run,
17
+ get_run_id,
18
+ start_run,
19
+ )
20
+ from bluer_objects.mlflow.tags import (
21
+ create_filter_string,
22
+ get_tags,
23
+ search,
24
+ set_tags,
25
+ )
26
+ from bluer_objects.mlflow.testing import (
27
+ test,
28
+ )
@@ -0,0 +1,271 @@
1
+ import argparse
2
+ from functools import reduce
3
+ import os
4
+
5
+ from blueness.argparse.generic import sys_exit
6
+ from blueness import module
7
+
8
+ from bluer_objects import NAME
9
+ from bluer_objects.mlflow.logging import (
10
+ log_artifacts,
11
+ log_run,
12
+ )
13
+ from bluer_objects.mlflow.models import (
14
+ list_registered_models,
15
+ transition,
16
+ )
17
+ from bluer_objects.mlflow.objects import (
18
+ get_id,
19
+ rm,
20
+ )
21
+ from bluer_objects.mlflow.runs import (
22
+ end_run,
23
+ get_run_id,
24
+ start_run,
25
+ )
26
+ from bluer_objects.mlflow.tags import (
27
+ create_filter_string,
28
+ get_tags,
29
+ search,
30
+ set_tags,
31
+ )
32
+ from bluer_objects.mlflow.testing import (
33
+ test,
34
+ )
35
+ from bluer_objects.logger import logger
36
+
37
+ NAME = module.name(__file__, NAME)
38
+
39
+
40
+ parser = argparse.ArgumentParser(NAME)
41
+ parser.add_argument(
42
+ "task",
43
+ type=str,
44
+ default="",
45
+ help="clone_tags|create_filter_string|get_id|get_run_id|get_tags|list_registered_models|log_artifacts|log_run|rm|search|set_tags|start_end_run|test|transition",
46
+ )
47
+ parser.add_argument(
48
+ "--count",
49
+ type=int,
50
+ default=-1,
51
+ )
52
+ parser.add_argument(
53
+ "--offset",
54
+ type=int,
55
+ default=0,
56
+ )
57
+ parser.add_argument(
58
+ "--default",
59
+ type=str,
60
+ default="",
61
+ )
62
+ parser.add_argument(
63
+ "--delim",
64
+ type=str,
65
+ default=",",
66
+ )
67
+ parser.add_argument(
68
+ "--description",
69
+ type=str,
70
+ default="",
71
+ )
72
+ parser.add_argument(
73
+ "--destination_object",
74
+ type=str,
75
+ default="",
76
+ )
77
+ parser.add_argument(
78
+ "--object_name",
79
+ type=str,
80
+ default=os.getenv("abcli_object_name"),
81
+ )
82
+ parser.add_argument(
83
+ "--filter_string",
84
+ type=str,
85
+ help="tags.`keyword` = `value` - https://www.mlflow.org/docs/latest/search-runs.html",
86
+ )
87
+ parser.add_argument(
88
+ "--input",
89
+ type=str,
90
+ default="name",
91
+ help="id|name",
92
+ )
93
+ parser.add_argument(
94
+ "--item_name_plural",
95
+ type=str,
96
+ default="object(s)",
97
+ )
98
+ parser.add_argument(
99
+ "--model_name",
100
+ type=str,
101
+ default="",
102
+ )
103
+ parser.add_argument(
104
+ "--output",
105
+ type=str,
106
+ default="name",
107
+ help="id|name",
108
+ )
109
+ parser.add_argument(
110
+ "--regex",
111
+ type=str,
112
+ default="",
113
+ )
114
+ parser.add_argument(
115
+ "--log",
116
+ type=int,
117
+ default=1,
118
+ help="0|1",
119
+ )
120
+ parser.add_argument(
121
+ "--explicit_query",
122
+ type=int,
123
+ default=0,
124
+ help="0|1",
125
+ )
126
+ parser.add_argument(
127
+ "--start_end",
128
+ type=str,
129
+ default="",
130
+ help="start|end",
131
+ )
132
+ parser.add_argument(
133
+ "--stage_name",
134
+ type=str,
135
+ default="",
136
+ help="",
137
+ )
138
+ parser.add_argument(
139
+ "--tag",
140
+ type=str,
141
+ default="",
142
+ )
143
+ parser.add_argument(
144
+ "--source_objects",
145
+ type=str,
146
+ default="",
147
+ )
148
+ parser.add_argument(
149
+ "--tags",
150
+ type=str,
151
+ default="",
152
+ help="+this,that=which,what=12",
153
+ )
154
+ parser.add_argument(
155
+ "--value",
156
+ type=str,
157
+ default="",
158
+ )
159
+ parser.add_argument(
160
+ "--version",
161
+ type=str,
162
+ default="",
163
+ help="",
164
+ )
165
+ args = parser.parse_args()
166
+
167
+ delim = " " if args.delim == "space" else args.delim
168
+
169
+ success = False
170
+ if args.task == "clone_tags":
171
+ success, tags = get_tags(args.source_objects)
172
+ if success:
173
+ success = set_tags(args.destination_object, tags)
174
+ elif args.task == "create_filter_string":
175
+ success = True
176
+ print(create_filter_string(args.tags))
177
+ elif args.task == "rm":
178
+ success = reduce(
179
+ lambda x, y: x and y,
180
+ [
181
+ rm(
182
+ object_name,
183
+ is_id=args.input == "id",
184
+ )
185
+ for object_name in args.object_name.split(",")
186
+ if object_name
187
+ ],
188
+ True,
189
+ )
190
+ elif args.task == "get_tags":
191
+ success, tags = get_tags(args.object_name)
192
+ print(tags if not args.tag else tags.get(args.tag, args.default))
193
+ elif args.task == "get_id":
194
+ success, id = get_id(args.object_name)
195
+ print(id)
196
+ elif args.task == "get_run_id":
197
+ success, list_of_id = get_run_id(
198
+ args.object_name,
199
+ args.count,
200
+ args.offset,
201
+ )
202
+
203
+ print(delim.join(list_of_id))
204
+ elif args.task == "list_registered_models":
205
+ success, list_of_models = list_registered_models()
206
+ if args.log:
207
+ logger.info(
208
+ "{:,} model(s): {}".format(len(list_of_models), delim.join(list_of_models))
209
+ )
210
+ else:
211
+ print(delim.join(list_of_models))
212
+ elif args.task == "log_artifacts":
213
+ success = log_artifacts(
214
+ args.object_name,
215
+ args.model_name,
216
+ )
217
+ elif args.task == "log_run":
218
+ success = log_run(args.object_name)
219
+ elif args.task == "search":
220
+ success = True
221
+
222
+ filter_string = (
223
+ create_filter_string(args.tags)
224
+ if args.explicit_query == 0
225
+ else "" if args.filter_string == "-" else args.filter_string
226
+ )
227
+
228
+ list_of_objects = search(filter_string)
229
+
230
+ list_of_objects = list_of_objects[args.offset :]
231
+
232
+ if args.count != -1:
233
+ list_of_objects = list_of_objects[: args.count]
234
+
235
+ if args.log:
236
+ logger.info(
237
+ "{:,} {}.".format(
238
+ len(list_of_objects),
239
+ args.item_name_plural,
240
+ ),
241
+ )
242
+ for index, object_name in enumerate(list_of_objects):
243
+ logger.info(f"#{index+1: 4d} - {object_name}")
244
+ else:
245
+ print(delim.join(list_of_objects))
246
+ elif args.task == "set_tags":
247
+ success = set_tags(
248
+ args.object_name,
249
+ args.tags,
250
+ )
251
+ elif args.task == "transition":
252
+ success = transition(
253
+ args.model_name,
254
+ args.version,
255
+ args.stage_name,
256
+ description=args.description,
257
+ )
258
+ elif args.task == "start_end_run":
259
+ if args.start_end == "start":
260
+ success = start_run(args.object_name)
261
+ elif args.task == "end":
262
+ success = end_run(args.object_name)
263
+ else:
264
+ success = False
265
+ logger.info(f"expected start|end,received {args.start_end}.")
266
+ elif args.task == "test":
267
+ success = test()
268
+ else:
269
+ success = None
270
+
271
+ sys_exit(logger, NAME, args.task, success)
@@ -0,0 +1,13 @@
1
+ from typing import Tuple
2
+
3
+ from bluer_objects.mlflow.tags import get_tags, set_tags
4
+
5
+
6
+ def read(keyword: str) -> Tuple[bool, str]:
7
+ success, tags = get_tags(keyword)
8
+
9
+ return success, tags.get("referent", "")
10
+
11
+
12
+ def write(keyword: str, value: str) -> bool:
13
+ return set_tags(keyword, {"referent": value})