ciocore 5.1.1__py2.py3-none-any.whl → 10.0.0b3__py2.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 (126) hide show
  1. ciocore/VERSION +1 -1
  2. ciocore/__init__.py +23 -1
  3. ciocore/api_client.py +655 -160
  4. ciocore/auth/__init__.py +5 -3
  5. ciocore/cli.py +501 -0
  6. ciocore/common.py +15 -13
  7. ciocore/conductor_submit.py +77 -60
  8. ciocore/config.py +127 -13
  9. ciocore/data.py +162 -77
  10. ciocore/docsite/404.html +746 -0
  11. ciocore/docsite/apidoc/api_client/index.html +3605 -0
  12. ciocore/docsite/apidoc/apidoc/index.html +909 -0
  13. ciocore/docsite/apidoc/config/index.html +1652 -0
  14. ciocore/docsite/apidoc/data/index.html +1553 -0
  15. ciocore/docsite/apidoc/hardware_set/index.html +2460 -0
  16. ciocore/docsite/apidoc/package_environment/index.html +1507 -0
  17. ciocore/docsite/apidoc/package_tree/index.html +2386 -0
  18. ciocore/docsite/assets/_mkdocstrings.css +16 -0
  19. ciocore/docsite/assets/images/favicon.png +0 -0
  20. ciocore/docsite/assets/javascripts/bundle.471ce7a9.min.js +29 -0
  21. ciocore/docsite/assets/javascripts/bundle.471ce7a9.min.js.map +7 -0
  22. ciocore/docsite/assets/javascripts/lunr/min/lunr.ar.min.js +1 -0
  23. ciocore/docsite/assets/javascripts/lunr/min/lunr.da.min.js +18 -0
  24. ciocore/docsite/assets/javascripts/lunr/min/lunr.de.min.js +18 -0
  25. ciocore/docsite/assets/javascripts/lunr/min/lunr.du.min.js +18 -0
  26. ciocore/docsite/assets/javascripts/lunr/min/lunr.el.min.js +1 -0
  27. ciocore/docsite/assets/javascripts/lunr/min/lunr.es.min.js +18 -0
  28. ciocore/docsite/assets/javascripts/lunr/min/lunr.fi.min.js +18 -0
  29. ciocore/docsite/assets/javascripts/lunr/min/lunr.fr.min.js +18 -0
  30. ciocore/docsite/assets/javascripts/lunr/min/lunr.he.min.js +1 -0
  31. ciocore/docsite/assets/javascripts/lunr/min/lunr.hi.min.js +1 -0
  32. ciocore/docsite/assets/javascripts/lunr/min/lunr.hu.min.js +18 -0
  33. ciocore/docsite/assets/javascripts/lunr/min/lunr.hy.min.js +1 -0
  34. ciocore/docsite/assets/javascripts/lunr/min/lunr.it.min.js +18 -0
  35. ciocore/docsite/assets/javascripts/lunr/min/lunr.ja.min.js +1 -0
  36. ciocore/docsite/assets/javascripts/lunr/min/lunr.jp.min.js +1 -0
  37. ciocore/docsite/assets/javascripts/lunr/min/lunr.kn.min.js +1 -0
  38. ciocore/docsite/assets/javascripts/lunr/min/lunr.ko.min.js +1 -0
  39. ciocore/docsite/assets/javascripts/lunr/min/lunr.multi.min.js +1 -0
  40. ciocore/docsite/assets/javascripts/lunr/min/lunr.nl.min.js +18 -0
  41. ciocore/docsite/assets/javascripts/lunr/min/lunr.no.min.js +18 -0
  42. ciocore/docsite/assets/javascripts/lunr/min/lunr.pt.min.js +18 -0
  43. ciocore/docsite/assets/javascripts/lunr/min/lunr.ro.min.js +18 -0
  44. ciocore/docsite/assets/javascripts/lunr/min/lunr.ru.min.js +18 -0
  45. ciocore/docsite/assets/javascripts/lunr/min/lunr.sa.min.js +1 -0
  46. ciocore/docsite/assets/javascripts/lunr/min/lunr.stemmer.support.min.js +1 -0
  47. ciocore/docsite/assets/javascripts/lunr/min/lunr.sv.min.js +18 -0
  48. ciocore/docsite/assets/javascripts/lunr/min/lunr.ta.min.js +1 -0
  49. ciocore/docsite/assets/javascripts/lunr/min/lunr.te.min.js +1 -0
  50. ciocore/docsite/assets/javascripts/lunr/min/lunr.th.min.js +1 -0
  51. ciocore/docsite/assets/javascripts/lunr/min/lunr.tr.min.js +18 -0
  52. ciocore/docsite/assets/javascripts/lunr/min/lunr.vi.min.js +1 -0
  53. ciocore/docsite/assets/javascripts/lunr/min/lunr.zh.min.js +1 -0
  54. ciocore/docsite/assets/javascripts/lunr/tinyseg.js +206 -0
  55. ciocore/docsite/assets/javascripts/lunr/wordcut.js +6708 -0
  56. ciocore/docsite/assets/javascripts/workers/search.b8dbb3d2.min.js +42 -0
  57. ciocore/docsite/assets/javascripts/workers/search.b8dbb3d2.min.js.map +7 -0
  58. ciocore/docsite/assets/stylesheets/main.3cba04c6.min.css +1 -0
  59. ciocore/docsite/assets/stylesheets/main.3cba04c6.min.css.map +1 -0
  60. ciocore/docsite/assets/stylesheets/palette.06af60db.min.css +1 -0
  61. ciocore/docsite/assets/stylesheets/palette.06af60db.min.css.map +1 -0
  62. ciocore/docsite/cmdline/docs/index.html +871 -0
  63. ciocore/docsite/cmdline/downloader/index.html +934 -0
  64. ciocore/docsite/cmdline/packages/index.html +878 -0
  65. ciocore/docsite/cmdline/uploader/index.html +995 -0
  66. ciocore/docsite/how-to-guides/index.html +869 -0
  67. ciocore/docsite/index.html +895 -0
  68. ciocore/docsite/logo.png +0 -0
  69. ciocore/docsite/objects.inv +0 -0
  70. ciocore/docsite/search/search_index.json +1 -0
  71. ciocore/docsite/sitemap.xml +3 -0
  72. ciocore/docsite/sitemap.xml.gz +0 -0
  73. ciocore/docsite/stylesheets/extra.css +26 -0
  74. ciocore/docsite/stylesheets/tables.css +167 -0
  75. ciocore/downloader/base_downloader.py +644 -0
  76. ciocore/downloader/download_runner_base.py +47 -0
  77. ciocore/downloader/job_downloader.py +119 -0
  78. ciocore/{downloader.py → downloader/legacy_downloader.py} +12 -9
  79. ciocore/downloader/log.py +73 -0
  80. ciocore/downloader/logging_download_runner.py +87 -0
  81. ciocore/downloader/perpetual_downloader.py +63 -0
  82. ciocore/downloader/registry.py +97 -0
  83. ciocore/downloader/reporter.py +135 -0
  84. ciocore/exceptions.py +8 -2
  85. ciocore/file_utils.py +51 -50
  86. ciocore/hardware_set.py +449 -0
  87. ciocore/loggeria.py +89 -20
  88. ciocore/package_environment.py +110 -48
  89. ciocore/package_query.py +182 -0
  90. ciocore/package_tree.py +319 -258
  91. ciocore/retry.py +0 -0
  92. ciocore/uploader/_uploader.py +547 -364
  93. ciocore/uploader/thread_queue_job.py +176 -0
  94. ciocore/uploader/upload_stats/__init__.py +3 -4
  95. ciocore/uploader/upload_stats/stats_formats.py +10 -4
  96. ciocore/validator.py +34 -2
  97. ciocore/worker.py +174 -151
  98. ciocore-10.0.0b3.dist-info/METADATA +928 -0
  99. ciocore-10.0.0b3.dist-info/RECORD +128 -0
  100. {ciocore-5.1.1.dist-info → ciocore-10.0.0b3.dist-info}/WHEEL +1 -1
  101. ciocore-10.0.0b3.dist-info/entry_points.txt +2 -0
  102. tests/instance_type_fixtures.py +175 -0
  103. tests/package_fixtures.py +205 -0
  104. tests/test_api_client.py +297 -12
  105. tests/test_base_downloader.py +104 -0
  106. tests/test_cli.py +149 -0
  107. tests/test_common.py +1 -7
  108. tests/test_config.py +40 -18
  109. tests/test_data.py +162 -173
  110. tests/test_downloader.py +118 -0
  111. tests/test_hardware_set.py +139 -0
  112. tests/test_job_downloader.py +213 -0
  113. tests/test_package_query.py +38 -0
  114. tests/test_package_tree.py +91 -291
  115. tests/test_submit.py +44 -18
  116. tests/test_uploader.py +1 -4
  117. ciocore/__about__.py +0 -10
  118. ciocore/cli/conductor.py +0 -191
  119. ciocore/compat.py +0 -15
  120. ciocore-5.1.1.data/scripts/conductor +0 -19
  121. ciocore-5.1.1.data/scripts/conductor.bat +0 -13
  122. ciocore-5.1.1.dist-info/METADATA +0 -408
  123. ciocore-5.1.1.dist-info/RECORD +0 -47
  124. tests/mocks/api_client_mock.py +0 -51
  125. /ciocore/{cli → downloader}/__init__.py +0 -0
  126. {ciocore-5.1.1.dist-info → ciocore-10.0.0b3.dist-info}/top_level.txt +0 -0
ciocore/data.py CHANGED
@@ -1,88 +1,179 @@
1
- # Everything from the endpoints.
2
-
3
-
4
1
  """
5
- Data from Conductor endpoints as a singleton.
2
+ This module is a singleton that provides the data from Conductor endpoints. Specifically, it provides projects, instance types, and software package data.
6
3
 
7
- Also has the ability to use fixtures for dev purposes.
8
-
9
- TODO: Develop fixture functionality to serve as a local cache, possibly for air_gapped studio
10
- workstations.
4
+ Since the data is stored at the module level, you can access it from anywhere in your code without the need to pass it around.
11
5
  """
12
- import json
13
- import os
6
+
14
7
  from ciocore.package_tree import PackageTree
15
8
  from ciocore import api_client
9
+ from ciocore.hardware_set import HardwareSet
10
+ import copy
16
11
 
17
12
  __data__ = {}
18
- __product__ = None
19
- __fixtures_dir__ = None
13
+ __products__ = None
20
14
  __platforms__ = None
21
15
 
22
- def data(force=False):
16
+ def init(*products, **kwargs):
23
17
  """
24
- Get projects , instance_types, and software from fixtures or api.
18
+ Initialize the module and let it know what host products to provide.
19
+
20
+ Args:
21
+ products (str): Provide a list of products for which to get software packages. If no products are given, the software data contains all products from the packages endpoint. If you provide more than one product, they must all be host level products.
22
+
23
+ Keyword Args:
24
+ product (str): `DEPRECATED` Provide one product for which to get software packages.
25
+
26
+ Examples:
27
+ >>> from ciocore import data as coredata
28
+ >>> coredata.init()
29
+ # OR
30
+ >>> coredata.init("maya-io")
31
+ # OR LEGACY
32
+ >>> coredata.init(product="all")
33
+ # OR
34
+ >>> coredata.init(product="maya-io")
35
+ """
36
+ global __products__
37
+ global __platforms__
38
+ if products:
39
+ if kwargs.get("product"):
40
+ raise ValueError(
41
+ "Arguments: `products` and `product` specified. Please don't use both together. The `product` arg is deprecated."
42
+ )
43
+ __products__ = list(products)
44
+ elif kwargs.get("product"):
45
+ if kwargs.get("product") == "all":
46
+ __products__ = []
47
+ else:
48
+ __products__ = [kwargs.get("product")]
49
+ else:
50
+ __products__ = []
51
+
52
+ __platforms__ = set(kwargs.get("platforms", ["windows", "linux"]))
53
+
54
+ def data(force=False, instances_filter=""):
55
+ """
56
+ Provide projects, instance types, and software package data.
57
+
58
+ Keyword Args:
59
+ force: (bool) If `True`, then force the system to fetch fresh data -- Defaults to `False`.
60
+ instances_filter: (str) complex RHS string query ex:
61
+ "cpu=gte:8:int,operating_system=ne:windows,gpu.gpu_count=eq:1:int"
62
+
63
+ Raises:
64
+ ValueError: Module was not initialized with [init()](/data/#ciocore.data.init).
65
+
66
+ Returns:
67
+ dict: Keys are `projects`, `instance_types`, `software`.
25
68
 
26
- Data will be valid.
69
+ When you access the data, if it has already been fetched, it will be returned. Otherwise,
70
+ requests will be made to fetch the data. You may need to authenticate in order to access the
71
+ data.
27
72
 
28
- args: force
73
+ The set of instance types and software can be pruned to match the available platforms
74
+ represented by each other. For example, if the instance types come from an orchestrator that
75
+ provides both Windows and Linux machines, and the software product(s) are available on both
76
+ platforms, no pruning occurs. However, if there are no Windows machines available, any Windows
77
+ software will be removed from the package tree. Similarly, if a product is chosen that only runs
78
+ on Windows, Linux instance types will not appearin the list of available hardware.
29
79
 
80
+ Here is a breakdown of each key in the dictionary:
81
+
82
+ * **projects** is a list of project names for your authenticated account.
83
+
84
+ * **instance_types** is an instance of HardwareSet, providing you with access to the list of
85
+ available machines configurations.
86
+
87
+ * **software** is a PackageTree object containing either all
88
+ the software available at Conductor, or a subset based on specified products.
89
+
90
+
91
+ Examples:
92
+ >>> from ciocore import data as coredata
93
+ >>> coredata.init(product="maya-io")
94
+
95
+ >>> coredata.data()["software"]
96
+ <ciocore.package_tree.PackageTree object at 0x10e9a4040>
97
+
98
+ >>> coredata.data()["projects"][0]
99
+ ATestForScott
100
+
101
+ >>> coredata.data()["instance_types"]
102
+ <ciocore.hardware_set.HardwareSet object at 0x0000028941CD9DC0>
30
103
  """
31
104
 
32
105
  global __data__
33
- global __product__
34
- global __fixtures_dir__
106
+ global __products__
35
107
  global __platforms__
36
108
 
37
-
38
- if not __product__:
109
+ if __products__ is None:
39
110
  raise ValueError(
40
- 'Data must be initialized before use, e.g. data.init("maya-io") or data.init("all").'
111
+ 'Data must be initialized before use, e.g. data.init("maya-io") or data.init().'
41
112
  )
113
+ products_copy = copy.copy(__products__)
42
114
 
43
115
  if force:
44
116
  clear()
117
+ init(*products_copy)
45
118
 
46
119
  if __data__ == {}:
47
120
  # PROJECTS
48
- projects_json = _get_json_fixture("projects")
49
- if projects_json:
50
- __data__["projects"] = projects_json
51
- else:
52
- __data__["projects"] = sorted(api_client.request_projects())
53
-
121
+ __data__["projects"] = sorted(api_client.request_projects())
54
122
  # INST_TYPES
55
- instance_types = _get_json_fixture("instance_types")
56
- if not instance_types:
57
- instance_types = api_client.request_instance_types()
123
+ instance_types = api_client.request_instance_types(filter_param=instances_filter)
124
+ # SOFTWARE
125
+ software = api_client.request_software_packages()
58
126
 
59
- it_platforms = set([it["operating_system"] for it in instance_types])
127
+ # EXTRA ENV VARS
128
+ extra_env_vars = []
129
+ try:
130
+ extra_env_vars = api_client.request_extra_environment()
131
+ except Exception:
132
+ pass
133
+ __data__["extra_environment"] = extra_env_vars
60
134
 
61
- # SOFTWARE
62
- software = _get_json_fixture("software")
63
- if not software:
64
- software = api_client.request_software_packages()
135
+ # PLATFORMS
136
+ it_platforms = set([it["operating_system"] for it in instance_types])
137
+ valid_platforms = it_platforms.intersection(__platforms__)
138
+ kwargs = {"platforms": valid_platforms}
65
139
 
66
- kwargs = {"platforms":it_platforms}
67
- if not __product__ == "all":
68
- kwargs["product"] = __product__
140
+ # If there's only one product, it's possible to initialize the software tree with a plugin.
141
+ # So we set the product kwarg. Otherwise, we set the host_products kwarg
142
+ host_products = __products__
143
+ if len(__products__) == 1:
144
+ host_products = []
145
+ kwargs["product"] = __products__[0]
69
146
 
70
- software_tree = PackageTree(software, **kwargs)
147
+ software_tree = PackageTree(software, *host_products, **kwargs)
71
148
 
72
- if software_tree.tree:
149
+ if software_tree:
73
150
  __data__["software"] = software_tree
74
151
  # Revisit instance types to filter out any that are not needed for any software package.
75
152
  sw_platforms = software_tree.platforms()
76
- instance_types = [it for it in instance_types if it["operating_system"] in sw_platforms]
77
-
78
- __data__["instance_types"] = sorted(instance_types, key=lambda k: (k["cores"], k["memory"]))
79
- __platforms__ = set([it["operating_system"] for it in __data__["instance_types"]])
80
-
81
- return __data__
82
153
 
154
+ instance_types = [
155
+ it for it in instance_types if it["operating_system"] in sw_platforms
156
+ ]
157
+ # Then adjust __platforms__ to match the instance types that are represented.
158
+ __platforms__ = set([it["operating_system"] for it in instance_types])
159
+
160
+ __data__["instance_types"] = HardwareSet(instance_types)
161
+
162
+ return __data__
83
163
 
84
164
  def valid():
85
- global __data__
165
+ """
166
+ Check validity.
167
+
168
+ Returns:
169
+ bool: True if `projects`, `instance_types`, and `software` are valid.
170
+
171
+ Examples:
172
+ >>> from ciocore import data as coredata
173
+ >>> coredata.valid()
174
+ True
175
+ """
176
+
86
177
  if not __data__.get("projects"):
87
178
  return False
88
179
  if not __data__.get("instance_types"):
@@ -93,43 +184,37 @@ def valid():
93
184
 
94
185
 
95
186
  def clear():
187
+ """
188
+ Clear out data.
189
+
190
+ [valid()](/data/#ciocore.data.valid) returns False after clear().
191
+ """
96
192
  global __data__
193
+ global __products__
194
+ global __platforms__
97
195
  __data__ = {}
196
+ __products__ = None
197
+ __platforms__ = None
98
198
 
99
199
 
100
- def init(product=None):
101
- global __product__
102
- if not product:
103
- raise ValueError("You must specify a product or 'all'")
104
- __product__ = product
105
-
106
-
107
- def product():
108
- global __product__
109
- return __product__
110
-
111
-
112
- def set_fixtures_dir(rhs):
113
- global __fixtures_dir__
114
- __fixtures_dir__ = rhs or ""
200
+ def products():
201
+ """
115
202
 
203
+ Returns:
204
+ list(str): The product names. An empty list signifies all products.
205
+ """
206
+ return __products__
116
207
 
117
- def _get_json_fixture(resource):
118
- global __fixtures_dir__
119
- if __fixtures_dir__:
120
- cache_path = os.path.join(__fixtures_dir__, "{}.json".format(resource))
121
- if os.path.isfile(cache_path):
122
- try:
123
- with open(cache_path) as f:
124
- return json.load(f)
125
- except BaseException:
126
- pass
208
+ def set_fixtures_dir(_):
209
+ """Deprecated. """
210
+ pass
127
211
 
128
212
  def platforms():
129
213
  """
130
- The set of platforms that satisfy both software and instance types.
131
-
132
- It's updated whenever data() is updated.
214
+ The set of platforms that both software and instance types are valid on.
215
+
216
+ Returns:
217
+ set: A set containing platforms: windows and/or linux.
133
218
  """
134
- global __platforms__
135
- return __platforms__
219
+ return __platforms__
220
+