ciocore 7.0.2b5__py2.py3-none-any.whl → 8.0.0__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.
Potentially problematic release.
This version of ciocore might be problematic. Click here for more details.
- ciocore/VERSION +1 -1
- ciocore/__init__.py +23 -1
- ciocore/api_client.py +422 -156
- ciocore/cli.py +503 -0
- ciocore/common.py +10 -1
- ciocore/config.py +86 -53
- ciocore/data.py +20 -73
- ciocore/docsite/404.html +723 -0
- ciocore/docsite/apidoc/api_client/index.html +3203 -0
- ciocore/docsite/apidoc/apidoc/index.html +868 -0
- ciocore/docsite/apidoc/config/index.html +1591 -0
- ciocore/docsite/apidoc/data/index.html +1480 -0
- ciocore/docsite/apidoc/hardware_set/index.html +2367 -0
- ciocore/docsite/apidoc/package_environment/index.html +1450 -0
- ciocore/docsite/apidoc/package_tree/index.html +2310 -0
- ciocore/docsite/assets/_mkdocstrings.css +16 -0
- ciocore/docsite/assets/images/favicon.png +0 -0
- ciocore/docsite/assets/javascripts/bundle.4e31edb1.min.js +29 -0
- ciocore/docsite/assets/javascripts/bundle.4e31edb1.min.js.map +8 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.ar.min.js +1 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.da.min.js +18 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.de.min.js +18 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.du.min.js +18 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.es.min.js +18 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.fi.min.js +18 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.fr.min.js +18 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.hi.min.js +1 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.hu.min.js +18 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.hy.min.js +1 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.it.min.js +18 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.ja.min.js +1 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.jp.min.js +1 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.kn.min.js +1 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.ko.min.js +1 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.multi.min.js +1 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.nl.min.js +18 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.no.min.js +18 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.pt.min.js +18 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.ro.min.js +18 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.ru.min.js +18 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.sa.min.js +1 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.stemmer.support.min.js +1 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.sv.min.js +18 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.ta.min.js +1 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.te.min.js +1 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.th.min.js +1 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.tr.min.js +18 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.vi.min.js +1 -0
- ciocore/docsite/assets/javascripts/lunr/min/lunr.zh.min.js +1 -0
- ciocore/docsite/assets/javascripts/lunr/tinyseg.js +206 -0
- ciocore/docsite/assets/javascripts/lunr/wordcut.js +6708 -0
- ciocore/docsite/assets/javascripts/workers/search.dfff1995.min.js +42 -0
- ciocore/docsite/assets/javascripts/workers/search.dfff1995.min.js.map +8 -0
- ciocore/docsite/assets/stylesheets/main.83068744.min.css +1 -0
- ciocore/docsite/assets/stylesheets/main.83068744.min.css.map +1 -0
- ciocore/docsite/assets/stylesheets/palette.ecc896b0.min.css +1 -0
- ciocore/docsite/assets/stylesheets/palette.ecc896b0.min.css.map +1 -0
- ciocore/docsite/cmdline/docs/index.html +834 -0
- ciocore/docsite/cmdline/downloader/index.html +897 -0
- ciocore/docsite/cmdline/packages/index.html +841 -0
- ciocore/docsite/cmdline/uploader/index.html +950 -0
- ciocore/docsite/how-to-guides/index.html +831 -0
- ciocore/docsite/index.html +853 -0
- ciocore/docsite/logo.png +0 -0
- ciocore/docsite/objects.inv +0 -0
- ciocore/docsite/search/search_index.json +1 -0
- ciocore/docsite/sitemap.xml +3 -0
- ciocore/docsite/sitemap.xml.gz +0 -0
- ciocore/docsite/stylesheets/extra.css +26 -0
- ciocore/docsite/stylesheets/tables.css +167 -0
- ciocore/downloader/__init__.py +0 -0
- ciocore/downloader/base_downloader.py +644 -0
- ciocore/downloader/download_runner_base.py +47 -0
- ciocore/downloader/job_downloader.py +119 -0
- ciocore/{downloader.py → downloader/legacy_downloader.py} +0 -1
- ciocore/downloader/log.py +73 -0
- ciocore/downloader/logging_download_runner.py +87 -0
- ciocore/downloader/perpetual_downloader.py +63 -0
- ciocore/downloader/registry.py +97 -0
- ciocore/downloader/reporter.py +135 -0
- ciocore/file_utils.py +3 -3
- ciocore/hardware_set.py +0 -4
- ciocore/package_environment.py +67 -75
- ciocore/package_query.py +171 -0
- ciocore/package_tree.py +300 -377
- ciocore/retry.py +0 -0
- ciocore/uploader/_uploader.py +205 -152
- {ciocore-7.0.2b5.dist-info → ciocore-8.0.0.dist-info}/METADATA +34 -16
- ciocore-8.0.0.dist-info/RECORD +127 -0
- {ciocore-7.0.2b5.dist-info → ciocore-8.0.0.dist-info}/WHEEL +1 -1
- ciocore-8.0.0.dist-info/entry_points.txt +2 -0
- tests/extra_env_fixtures.py +57 -0
- tests/instance_type_fixtures.py +42 -8
- tests/project_fixtures.py +8 -0
- tests/test_api_client.py +121 -2
- tests/test_base_downloader.py +104 -0
- tests/test_cli.py +163 -0
- tests/test_common.py +8 -8
- tests/test_config.py +23 -9
- tests/test_data.py +144 -160
- tests/test_downloader.py +118 -0
- tests/test_hardware_set.py +69 -20
- tests/test_job_downloader.py +213 -0
- ciocore/__about__.py +0 -10
- ciocore/cli/__init__.py +0 -3
- ciocore/cli/conductor.py +0 -210
- ciocore-7.0.2b5.data/scripts/conductor +0 -19
- ciocore-7.0.2b5.data/scripts/conductor.bat +0 -13
- ciocore-7.0.2b5.dist-info/RECORD +0 -51
- tests/mocks/api_client_mock.py +0 -31
- {ciocore-7.0.2b5.dist-info → ciocore-8.0.0.dist-info}/top_level.txt +0 -0
ciocore/config.py
CHANGED
|
@@ -1,39 +1,51 @@
|
|
|
1
1
|
"""
|
|
2
|
-
|
|
2
|
+
Config is a configuration object implemented as a module-level singleton.
|
|
3
3
|
|
|
4
|
-
Configuration variables can be shared by importing the module. If there are changes in environment variables or other sources, the config can be refreshed.
|
|
4
|
+
Configuration variables can be shared by importing the module. If there are changes in environment variables or other sources, the config can be refreshed.
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
7
|
import logging
|
|
8
8
|
import os
|
|
9
|
-
import multiprocessing
|
|
9
|
+
# import multiprocessing
|
|
10
10
|
import base64
|
|
11
11
|
import json
|
|
12
12
|
import re
|
|
13
|
+
import platform
|
|
13
14
|
|
|
14
15
|
from ciocore.common import CONDUCTOR_LOGGER_NAME
|
|
15
16
|
|
|
16
17
|
logger = logging.getLogger(CONDUCTOR_LOGGER_NAME)
|
|
17
18
|
|
|
18
|
-
#https://stackoverflow.com/a/3809435/179412
|
|
19
|
+
# https://stackoverflow.com/a/3809435/179412
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
|
|
22
|
+
USER_DIRS = {
|
|
23
|
+
"Linux": os.path.expanduser(os.path.join("~", ".conductor")),
|
|
24
|
+
"Darwin": os.path.expanduser(os.path.join("~",".conductor")),
|
|
25
|
+
"Windows": os.path.expanduser(os.path.join("~", "AppData", "Local", "Conductor")),
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
DEFAULT_USER_DIR = USER_DIRS.get(platform.system(), USER_DIRS["Linux"])
|
|
29
|
+
|
|
30
|
+
URL_REGEX = re.compile(
|
|
31
|
+
r"https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)"
|
|
32
|
+
)
|
|
21
33
|
|
|
22
34
|
__config__ = None
|
|
23
35
|
|
|
36
|
+
|
|
24
37
|
def config(force=False):
|
|
25
38
|
"""
|
|
26
|
-
DEPRECATED! Use [get()](#get) instead.
|
|
27
|
-
|
|
28
39
|
Instantiate a config object if necessary.
|
|
29
40
|
|
|
30
|
-
|
|
41
|
+
Deprecated:
|
|
42
|
+
Use [get()](#get) instead.
|
|
31
43
|
|
|
32
|
-
|
|
44
|
+
Args:
|
|
45
|
+
force (bool): Discards any existing config object and instantiate a new one -- Defaults to `False`.
|
|
33
46
|
|
|
34
47
|
Returns:
|
|
35
|
-
|
|
36
|
-
* [Config()](#Config) object containing a dictionary of configuration variables.
|
|
48
|
+
dict: A dictionary containing configuration values.
|
|
37
49
|
"""
|
|
38
50
|
|
|
39
51
|
global __config__
|
|
@@ -41,67 +53,83 @@ def config(force=False):
|
|
|
41
53
|
__config__ = Config()
|
|
42
54
|
return __config__
|
|
43
55
|
|
|
56
|
+
|
|
44
57
|
def get(force=False):
|
|
45
58
|
"""
|
|
46
59
|
Instantiate a config object if necessary and return the dictionary.
|
|
47
60
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
* **`force`** -- Discards any existing config object and instantiate a new one -- Defaults to `False`.
|
|
61
|
+
Args:
|
|
62
|
+
force (bool): Discards any existing config object and instantiate a new one -- Defaults to `False`.
|
|
51
63
|
|
|
52
64
|
Returns:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
# 'auth_url': 'https://dashboard.conductortech.com',
|
|
70
|
-
# 'api_url': 'https://api.conductortech.com',
|
|
71
|
-
# 'api_key': None
|
|
72
|
-
# }
|
|
73
|
-
```
|
|
65
|
+
dict: A dictionary containing configuration values.
|
|
66
|
+
|
|
67
|
+
Example:
|
|
68
|
+
>>> from ciocore import config
|
|
69
|
+
>>> config.get()
|
|
70
|
+
{
|
|
71
|
+
'thread_count': 16,
|
|
72
|
+
'priority': 5,
|
|
73
|
+
'md5_caching': True,
|
|
74
|
+
'log_level': 'INFO',
|
|
75
|
+
'url': 'https://dashboard.conductortech.com',
|
|
76
|
+
'auth_url': 'https://dashboard.conductortech.com',
|
|
77
|
+
'api_url': 'https://api.conductortech.com',
|
|
78
|
+
'api_key': None,
|
|
79
|
+
'downloader_page_size': 50,
|
|
80
|
+
}
|
|
74
81
|
"""
|
|
75
82
|
global __config__
|
|
76
83
|
if force or not __config__:
|
|
77
84
|
__config__ = Config()
|
|
78
85
|
return __config__.config
|
|
79
86
|
|
|
87
|
+
|
|
80
88
|
class Config(object):
|
|
81
89
|
def __init__(self):
|
|
82
90
|
"""
|
|
83
|
-
|
|
91
|
+
Initialize the config object.
|
|
84
92
|
|
|
93
|
+
A config object is a dictionary containing configuration values. It is a singleton, so there is only one instance of it. It is instantiated the first time it is needed. It can be refreshed by calling get() with the `force` keyword argument set to `True`.
|
|
85
94
|
|
|
86
|
-
|
|
95
|
+
A Config object has the following properties:
|
|
96
|
+
|
|
97
|
+
* `thread_count` The number of threads to use for downloading files. Defaults to the number of CPUs on the system times 2. It can be overridden by the `CONDUCTOR_THREAD_COUNT` environment variable.
|
|
98
|
+
* `priority` Set the priority for submissions. Defaults to 5. It can be overridden by the `CONDUCTOR_PRIORITY` environment variable.
|
|
99
|
+
* `md5_caching` Whether to cache MD5s. Defaults to `True`. It can be overridden by the `CONDUCTOR_MD5_CACHING` environment variable. Cachine MD5s significantly improves submission performance, but on rare occasions it can cause submissions to fail. If you experience this, set `md5_caching` to `False`.
|
|
100
|
+
* `log_level` The logging level. Defaults to `INFO`. It can be overridden by the `CONDUCTOR_LOG_LEVEL` environment variable.
|
|
101
|
+
* `url` The URL of the Conductor dashboard. Defaults to `https://dashboard.conductortech.com`. It can be overridden by the `CONDUCTOR_URL` environment variable.
|
|
102
|
+
* `auth_url` The URL of the Conductor dashboard. Defaults to `https://dashboard.conductortech.com`. It can be overridden by the `CONDUCTOR_AUTH_URL` environment variable. This is deprecated. Use `url` instead.
|
|
103
|
+
* `api_url` The URL of the Conductor API. Defaults to `https://api.conductortech.com`. It can be overridden by the `CONDUCTOR_API_URL` environment variable.
|
|
104
|
+
* `api_key` The API key. The API key can be acquired from the Conductor dashboard, and can be stored in an environment variable or a file. In both cases the API KEY can be a JSON object or a base64 encoded JSON object. If it is base64 encoded, it can be a string or bytes. If it is a string, it will be decoded as ASCII. If it is bytes, it will be decoded as UTF-8.
|
|
105
|
+
* Environment variable: The `CONDUCTOR_API_KEY` variable can hold the API KEY directly.
|
|
106
|
+
* File: The `CONDUCTOR_API_KEY_PATH` variable can hold the path to a file containing the API KEY.
|
|
107
|
+
* `downloader_page_size` The number of files to request from the Conductor API at a time. Defaults to 50. It can be overridden by the `CONDUCTOR_DOWNLOADER_PAGE_SIZE` environment variable.
|
|
87
108
|
|
|
88
|
-
|
|
109
|
+
Returns:
|
|
110
|
+
Config: A config object.
|
|
111
|
+
|
|
112
|
+
Raises:
|
|
113
|
+
ValueError -- Invalid inputs, such as badly formed URLs.
|
|
89
114
|
"""
|
|
115
|
+
default_downloader_page_size = 50
|
|
116
|
+
|
|
117
|
+
|
|
90
118
|
|
|
91
119
|
try:
|
|
92
|
-
default_thread_count = min(
|
|
120
|
+
default_thread_count = min( os.cpu_count() - 1, 15)
|
|
93
121
|
except NotImplementedError:
|
|
94
|
-
default_thread_count =
|
|
122
|
+
default_thread_count = 15
|
|
95
123
|
|
|
96
124
|
url = os.environ.get("CONDUCTOR_URL", "https://dashboard.conductortech.com")
|
|
97
125
|
|
|
98
126
|
if not URL_REGEX.match(url):
|
|
99
127
|
raise ValueError("CONDUCTOR_URL is not valid '{}'".format(url))
|
|
100
|
-
|
|
128
|
+
|
|
101
129
|
api_url = os.environ.get("CONDUCTOR_API_URL", url.replace("dashboard", "api"))
|
|
102
130
|
if not URL_REGEX.match(api_url):
|
|
103
131
|
raise ValueError("CONDUCTOR_API_URL is not valid '{}'".format(api_url))
|
|
104
|
-
|
|
132
|
+
|
|
105
133
|
falsy = ["false", "no", "off", "0"]
|
|
106
134
|
|
|
107
135
|
log_level = os.environ.get("CONDUCTOR_LOG_LEVEL", "INFO")
|
|
@@ -109,34 +137,40 @@ class Config(object):
|
|
|
109
137
|
log_level = "INFO"
|
|
110
138
|
|
|
111
139
|
self.config = {
|
|
112
|
-
"thread_count": int(
|
|
140
|
+
"thread_count": int(
|
|
141
|
+
os.environ.get("CONDUCTOR_THREAD_COUNT", default_thread_count)
|
|
142
|
+
),
|
|
143
|
+
"downloader_page_size": int(
|
|
144
|
+
os.environ.get(
|
|
145
|
+
"CONDUCTOR_DOWNLOADER_PAGE_SIZE", default_downloader_page_size
|
|
146
|
+
)
|
|
147
|
+
),
|
|
113
148
|
"priority": int(os.environ.get("CONDUCTOR_PRIORITY", 5)),
|
|
114
149
|
"md5_caching": False
|
|
115
150
|
if os.environ.get("CONDUCTOR_MD5_CACHING", "True").lower() in falsy
|
|
116
151
|
else True,
|
|
117
152
|
"log_level": log_level,
|
|
118
153
|
"url": url,
|
|
119
|
-
# Keep "auth_url" for backwwards compatibillity only.
|
|
120
|
-
# Clients should use "url" moving forward.
|
|
154
|
+
# Keep "auth_url" for backwwards compatibillity only.
|
|
155
|
+
# Clients should use "url" moving forward.
|
|
121
156
|
# Remove "auth_url" on the next major version bump.
|
|
122
157
|
"auth_url": url,
|
|
123
158
|
"api_url": api_url,
|
|
124
159
|
"api_key": self.get_api_key_from_variable() or self.get_api_key_from_file(),
|
|
125
|
-
"user_dir": os.environ.get('CONDUCTOR_USER_DIR',
|
|
160
|
+
"user_dir": os.environ.get('CONDUCTOR_USER_DIR', DEFAULT_USER_DIR)
|
|
126
161
|
}
|
|
127
162
|
|
|
128
163
|
@staticmethod
|
|
129
164
|
def get_api_key_from_variable():
|
|
130
165
|
"""
|
|
131
|
-
Attempt to get an API key from the CONDUCTOR_API_KEY environment variable.
|
|
166
|
+
Attempt to get an API key from the `CONDUCTOR_API_KEY` environment variable.
|
|
132
167
|
|
|
133
168
|
Raises:
|
|
134
|
-
|
|
135
|
-
* **`ValueError`** -- An error occurred while loading the key into JSON.
|
|
169
|
+
ValueError: An error occurred while reading or loading the key into JSON.
|
|
136
170
|
|
|
137
171
|
Returns:
|
|
172
|
+
str: JSON object containing the key - base 64 decoded if necessary.
|
|
138
173
|
|
|
139
|
-
* JSON object containing the key - base 64 decoded if necessary.
|
|
140
174
|
"""
|
|
141
175
|
api_key = os.environ.get("CONDUCTOR_API_KEY")
|
|
142
176
|
if not api_key:
|
|
@@ -162,12 +196,11 @@ class Config(object):
|
|
|
162
196
|
Attempt to get an API key from the file in the CONDUCTOR_API_KEY_PATH environment variable.
|
|
163
197
|
|
|
164
198
|
Raises:
|
|
165
|
-
|
|
166
|
-
* **`ValueError`** -- An error occurred while reading or loading the key into JSON.
|
|
199
|
+
ValueError: An error occurred while reading or loading the key into JSON.
|
|
167
200
|
|
|
168
201
|
Returns:
|
|
202
|
+
str: JSON object containing the key - base 64 decoded if necessary.
|
|
169
203
|
|
|
170
|
-
* JSON object containing the key - base 64 decoded if necessary.
|
|
171
204
|
"""
|
|
172
205
|
api_key_path = os.environ.get("CONDUCTOR_API_KEY_PATH")
|
|
173
206
|
if not api_key_path:
|
ciocore/data.py
CHANGED
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
"""
|
|
2
|
-
This module is a singleton that provides the data from Conductor endpoints. Specifically, it provides projects, instance types, and software package data.
|
|
2
|
+
This module is a singleton that provides the data from Conductor endpoints. Specifically, it provides projects, instance types, and software package data.
|
|
3
3
|
|
|
4
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.
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
|
-
import json
|
|
8
|
-
import os
|
|
9
7
|
from ciocore.package_tree import PackageTree
|
|
10
8
|
from ciocore import api_client
|
|
11
9
|
from ciocore.hardware_set import HardwareSet
|
|
12
10
|
import copy
|
|
13
11
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
12
|
__data__ = {}
|
|
18
13
|
__products__ = None
|
|
19
|
-
__fixtures_dir__ = None
|
|
20
14
|
__platforms__ = None
|
|
21
15
|
|
|
22
16
|
def init(*products, **kwargs):
|
|
@@ -62,7 +56,7 @@ def data(force=False):
|
|
|
62
56
|
Provide projects, instance types, and software package data.
|
|
63
57
|
|
|
64
58
|
Keyword Args:
|
|
65
|
-
force: (bool) If `True`, then fetch fresh data -- Defaults to `False`.
|
|
59
|
+
force: (bool) If `True`, then force the system to fetch fresh data -- Defaults to `False`.
|
|
66
60
|
|
|
67
61
|
Raises:
|
|
68
62
|
ValueError: Module was not initialized with [init()](/data/#ciocore.data.init).
|
|
@@ -115,36 +109,30 @@ def data(force=False):
|
|
|
115
109
|
'Data must be initialized before use, e.g. data.init("maya-io") or data.init().'
|
|
116
110
|
)
|
|
117
111
|
products_copy = copy.copy(__products__)
|
|
118
|
-
|
|
112
|
+
|
|
119
113
|
if force:
|
|
120
114
|
clear()
|
|
121
115
|
init(*products_copy)
|
|
122
116
|
|
|
123
117
|
if __data__ == {}:
|
|
124
118
|
# PROJECTS
|
|
125
|
-
|
|
126
|
-
if projects_json:
|
|
127
|
-
__data__["projects"] = projects_json
|
|
128
|
-
else:
|
|
129
|
-
__data__["projects"] = sorted(api_client.request_projects())
|
|
130
|
-
|
|
119
|
+
__data__["projects"] = sorted(api_client.request_projects())
|
|
131
120
|
# INST_TYPES
|
|
132
|
-
instance_types =
|
|
133
|
-
if not instance_types:
|
|
134
|
-
instance_types = api_client.request_instance_types()
|
|
135
|
-
|
|
136
|
-
it_platforms = set([it["operating_system"] for it in instance_types])
|
|
137
|
-
valid_platforms = it_platforms.intersection(__platforms__)
|
|
138
|
-
|
|
121
|
+
instance_types = api_client.request_instance_types()
|
|
139
122
|
# SOFTWARE
|
|
140
|
-
software =
|
|
141
|
-
if not software:
|
|
142
|
-
software = api_client.request_software_packages()
|
|
123
|
+
software = api_client.request_software_packages()
|
|
143
124
|
|
|
144
|
-
#
|
|
145
|
-
|
|
146
|
-
|
|
125
|
+
# EXTRA ENV VARS
|
|
126
|
+
extra_env_vars = []
|
|
127
|
+
try:
|
|
128
|
+
extra_env_vars = api_client.request_extra_environment()
|
|
129
|
+
except Exception:
|
|
130
|
+
pass
|
|
131
|
+
__data__["extra_environment"] = extra_env_vars
|
|
147
132
|
|
|
133
|
+
# PLATFORMS
|
|
134
|
+
it_platforms = set([it["operating_system"] for it in instance_types])
|
|
135
|
+
valid_platforms = it_platforms.intersection(__platforms__)
|
|
148
136
|
kwargs = {"platforms": valid_platforms}
|
|
149
137
|
|
|
150
138
|
# If there's only one product, it's possible to initialize the software tree with a plugin.
|
|
@@ -164,14 +152,13 @@ def data(force=False):
|
|
|
164
152
|
instance_types = [
|
|
165
153
|
it for it in instance_types if it["operating_system"] in sw_platforms
|
|
166
154
|
]
|
|
167
|
-
|
|
155
|
+
# Then adjust __platforms__ to match the instance types that are represented.
|
|
168
156
|
__platforms__ = set([it["operating_system"] for it in instance_types])
|
|
169
157
|
|
|
170
158
|
__data__["instance_types"] = HardwareSet(instance_types)
|
|
171
159
|
|
|
172
160
|
return __data__
|
|
173
161
|
|
|
174
|
-
|
|
175
162
|
def valid():
|
|
176
163
|
"""
|
|
177
164
|
Check validity.
|
|
@@ -216,49 +203,9 @@ def products():
|
|
|
216
203
|
"""
|
|
217
204
|
return __products__
|
|
218
205
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
Specify a directory in which to find JSON files representing the three sets of data to provide.
|
|
223
|
-
The individual filenames are:
|
|
224
|
-
|
|
225
|
-
* `projects.json`
|
|
226
|
-
* `instance_types.json`
|
|
227
|
-
* `software.json`
|
|
228
|
-
|
|
229
|
-
These files could be used in an environment where machines can't access the internet. They are
|
|
230
|
-
also useful as a cache for developers who need to reload often as it avoids waiting for the
|
|
231
|
-
network.
|
|
232
|
-
|
|
233
|
-
In order to get the content for the fixtures files, use the following Example
|
|
234
|
-
|
|
235
|
-
Examples:
|
|
236
|
-
>>> from ciocore import api_client
|
|
237
|
-
>>> projects = api_client.request_projects()
|
|
238
|
-
>>> instance_types = api_client.request_instance_types()
|
|
239
|
-
>>> software = api_client.request_software_packages()
|
|
240
|
-
|
|
241
|
-
Write that data as JSON to the filenames listed above.
|
|
242
|
-
|
|
243
|
-
Arguments:
|
|
244
|
-
path (str): Directory in which to find the above files.
|
|
245
|
-
|
|
246
|
-
"""
|
|
247
|
-
|
|
248
|
-
global __fixtures_dir__
|
|
249
|
-
__fixtures_dir__ = path or ""
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
def _get_json_fixture(resource):
|
|
253
|
-
if __fixtures_dir__:
|
|
254
|
-
cache_path = os.path.join(__fixtures_dir__, "{}.json".format(resource))
|
|
255
|
-
if os.path.isfile(cache_path):
|
|
256
|
-
try:
|
|
257
|
-
with open(cache_path) as f:
|
|
258
|
-
return json.load(f)
|
|
259
|
-
except BaseException:
|
|
260
|
-
pass
|
|
261
|
-
|
|
206
|
+
def set_fixtures_dir(_):
|
|
207
|
+
"""Deprecated. """
|
|
208
|
+
pass
|
|
262
209
|
|
|
263
210
|
def platforms():
|
|
264
211
|
"""
|