ciocore 7.0.2b4__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 -54
- ciocore/data.py +23 -70
- 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.2b4.dist-info → ciocore-8.0.0.dist-info}/METADATA +33 -12
- ciocore-8.0.0.dist-info/RECORD +127 -0
- {ciocore-7.0.2b4.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 +125 -4
- 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 +148 -160
- tests/test_downloader.py +118 -0
- tests/test_hardware_set.py +70 -20
- tests/test_job_downloader.py +213 -0
- tests/test_submit.py +9 -2
- ciocore/__about__.py +0 -10
- ciocore/cli/__init__.py +0 -3
- ciocore/cli/conductor.py +0 -210
- ciocore-7.0.2b4.data/scripts/conductor +0 -19
- ciocore-7.0.2b4.data/scripts/conductor.bat +0 -13
- ciocore-7.0.2b4.dist-info/RECORD +0 -51
- tests/mocks/api_client_mock.py +0 -31
- {ciocore-7.0.2b4.dist-info → ciocore-8.0.0.dist-info}/top_level.txt +0 -0
ciocore/config.py
CHANGED
|
@@ -1,40 +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
|
-
|
|
13
|
+
import platform
|
|
14
14
|
|
|
15
15
|
from ciocore.common import CONDUCTOR_LOGGER_NAME
|
|
16
16
|
|
|
17
17
|
logger = logging.getLogger(CONDUCTOR_LOGGER_NAME)
|
|
18
18
|
|
|
19
|
-
#https://stackoverflow.com/a/3809435/179412
|
|
19
|
+
# https://stackoverflow.com/a/3809435/179412
|
|
20
20
|
|
|
21
|
-
|
|
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
|
+
)
|
|
22
33
|
|
|
23
34
|
__config__ = None
|
|
24
35
|
|
|
36
|
+
|
|
25
37
|
def config(force=False):
|
|
26
38
|
"""
|
|
27
|
-
DEPRECATED! Use [get()](#get) instead.
|
|
28
|
-
|
|
29
39
|
Instantiate a config object if necessary.
|
|
30
40
|
|
|
31
|
-
|
|
41
|
+
Deprecated:
|
|
42
|
+
Use [get()](#get) instead.
|
|
32
43
|
|
|
33
|
-
|
|
44
|
+
Args:
|
|
45
|
+
force (bool): Discards any existing config object and instantiate a new one -- Defaults to `False`.
|
|
34
46
|
|
|
35
47
|
Returns:
|
|
36
|
-
|
|
37
|
-
* [Config()](#Config) object containing a dictionary of configuration variables.
|
|
48
|
+
dict: A dictionary containing configuration values.
|
|
38
49
|
"""
|
|
39
50
|
|
|
40
51
|
global __config__
|
|
@@ -42,67 +53,83 @@ def config(force=False):
|
|
|
42
53
|
__config__ = Config()
|
|
43
54
|
return __config__
|
|
44
55
|
|
|
56
|
+
|
|
45
57
|
def get(force=False):
|
|
46
58
|
"""
|
|
47
59
|
Instantiate a config object if necessary and return the dictionary.
|
|
48
60
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
* **`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`.
|
|
52
63
|
|
|
53
64
|
Returns:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
# 'auth_url': 'https://dashboard.conductortech.com',
|
|
71
|
-
# 'api_url': 'https://api.conductortech.com',
|
|
72
|
-
# 'api_key': None
|
|
73
|
-
# }
|
|
74
|
-
```
|
|
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
|
+
}
|
|
75
81
|
"""
|
|
76
82
|
global __config__
|
|
77
83
|
if force or not __config__:
|
|
78
84
|
__config__ = Config()
|
|
79
85
|
return __config__.config
|
|
80
86
|
|
|
87
|
+
|
|
81
88
|
class Config(object):
|
|
82
89
|
def __init__(self):
|
|
83
90
|
"""
|
|
84
|
-
|
|
91
|
+
Initialize the config object.
|
|
85
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`.
|
|
86
94
|
|
|
87
|
-
|
|
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.
|
|
88
108
|
|
|
89
|
-
|
|
109
|
+
Returns:
|
|
110
|
+
Config: A config object.
|
|
111
|
+
|
|
112
|
+
Raises:
|
|
113
|
+
ValueError -- Invalid inputs, such as badly formed URLs.
|
|
90
114
|
"""
|
|
115
|
+
default_downloader_page_size = 50
|
|
116
|
+
|
|
117
|
+
|
|
91
118
|
|
|
92
119
|
try:
|
|
93
|
-
default_thread_count = min(
|
|
120
|
+
default_thread_count = min( os.cpu_count() - 1, 15)
|
|
94
121
|
except NotImplementedError:
|
|
95
|
-
default_thread_count =
|
|
122
|
+
default_thread_count = 15
|
|
96
123
|
|
|
97
124
|
url = os.environ.get("CONDUCTOR_URL", "https://dashboard.conductortech.com")
|
|
98
125
|
|
|
99
126
|
if not URL_REGEX.match(url):
|
|
100
127
|
raise ValueError("CONDUCTOR_URL is not valid '{}'".format(url))
|
|
101
|
-
|
|
128
|
+
|
|
102
129
|
api_url = os.environ.get("CONDUCTOR_API_URL", url.replace("dashboard", "api"))
|
|
103
130
|
if not URL_REGEX.match(api_url):
|
|
104
131
|
raise ValueError("CONDUCTOR_API_URL is not valid '{}'".format(api_url))
|
|
105
|
-
|
|
132
|
+
|
|
106
133
|
falsy = ["false", "no", "off", "0"]
|
|
107
134
|
|
|
108
135
|
log_level = os.environ.get("CONDUCTOR_LOG_LEVEL", "INFO")
|
|
@@ -110,34 +137,40 @@ class Config(object):
|
|
|
110
137
|
log_level = "INFO"
|
|
111
138
|
|
|
112
139
|
self.config = {
|
|
113
|
-
"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
|
+
),
|
|
114
148
|
"priority": int(os.environ.get("CONDUCTOR_PRIORITY", 5)),
|
|
115
149
|
"md5_caching": False
|
|
116
150
|
if os.environ.get("CONDUCTOR_MD5_CACHING", "True").lower() in falsy
|
|
117
151
|
else True,
|
|
118
152
|
"log_level": log_level,
|
|
119
153
|
"url": url,
|
|
120
|
-
# Keep "auth_url" for backwwards compatibillity only.
|
|
121
|
-
# Clients should use "url" moving forward.
|
|
154
|
+
# Keep "auth_url" for backwwards compatibillity only.
|
|
155
|
+
# Clients should use "url" moving forward.
|
|
122
156
|
# Remove "auth_url" on the next major version bump.
|
|
123
157
|
"auth_url": url,
|
|
124
158
|
"api_url": api_url,
|
|
125
159
|
"api_key": self.get_api_key_from_variable() or self.get_api_key_from_file(),
|
|
126
|
-
"user_dir": os.environ.get('CONDUCTOR_USER_DIR',
|
|
160
|
+
"user_dir": os.environ.get('CONDUCTOR_USER_DIR', DEFAULT_USER_DIR)
|
|
127
161
|
}
|
|
128
162
|
|
|
129
163
|
@staticmethod
|
|
130
164
|
def get_api_key_from_variable():
|
|
131
165
|
"""
|
|
132
|
-
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.
|
|
133
167
|
|
|
134
168
|
Raises:
|
|
135
|
-
|
|
136
|
-
* **`ValueError`** -- An error occurred while loading the key into JSON.
|
|
169
|
+
ValueError: An error occurred while reading or loading the key into JSON.
|
|
137
170
|
|
|
138
171
|
Returns:
|
|
172
|
+
str: JSON object containing the key - base 64 decoded if necessary.
|
|
139
173
|
|
|
140
|
-
* JSON object containing the key - base 64 decoded if necessary.
|
|
141
174
|
"""
|
|
142
175
|
api_key = os.environ.get("CONDUCTOR_API_KEY")
|
|
143
176
|
if not api_key:
|
|
@@ -163,12 +196,11 @@ class Config(object):
|
|
|
163
196
|
Attempt to get an API key from the file in the CONDUCTOR_API_KEY_PATH environment variable.
|
|
164
197
|
|
|
165
198
|
Raises:
|
|
166
|
-
|
|
167
|
-
* **`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.
|
|
168
200
|
|
|
169
201
|
Returns:
|
|
202
|
+
str: JSON object containing the key - base 64 decoded if necessary.
|
|
170
203
|
|
|
171
|
-
* JSON object containing the key - base 64 decoded if necessary.
|
|
172
204
|
"""
|
|
173
205
|
api_key_path = os.environ.get("CONDUCTOR_API_KEY_PATH")
|
|
174
206
|
if not api_key_path:
|
ciocore/data.py
CHANGED
|
@@ -1,17 +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
|
|
10
|
+
import copy
|
|
11
|
+
|
|
12
12
|
__data__ = {}
|
|
13
13
|
__products__ = None
|
|
14
|
-
__fixtures_dir__ = None
|
|
15
14
|
__platforms__ = None
|
|
16
15
|
|
|
17
16
|
def init(*products, **kwargs):
|
|
@@ -57,7 +56,7 @@ def data(force=False):
|
|
|
57
56
|
Provide projects, instance types, and software package data.
|
|
58
57
|
|
|
59
58
|
Keyword Args:
|
|
60
|
-
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`.
|
|
61
60
|
|
|
62
61
|
Raises:
|
|
63
62
|
ValueError: Module was not initialized with [init()](/data/#ciocore.data.init).
|
|
@@ -109,36 +108,31 @@ def data(force=False):
|
|
|
109
108
|
raise ValueError(
|
|
110
109
|
'Data must be initialized before use, e.g. data.init("maya-io") or data.init().'
|
|
111
110
|
)
|
|
112
|
-
products_copy =
|
|
111
|
+
products_copy = copy.copy(__products__)
|
|
112
|
+
|
|
113
113
|
if force:
|
|
114
114
|
clear()
|
|
115
115
|
init(*products_copy)
|
|
116
116
|
|
|
117
117
|
if __data__ == {}:
|
|
118
118
|
# PROJECTS
|
|
119
|
-
|
|
120
|
-
if projects_json:
|
|
121
|
-
__data__["projects"] = projects_json
|
|
122
|
-
else:
|
|
123
|
-
__data__["projects"] = sorted(api_client.request_projects())
|
|
124
|
-
|
|
119
|
+
__data__["projects"] = sorted(api_client.request_projects())
|
|
125
120
|
# INST_TYPES
|
|
126
|
-
instance_types =
|
|
127
|
-
if not instance_types:
|
|
128
|
-
instance_types = api_client.request_instance_types()
|
|
129
|
-
|
|
130
|
-
it_platforms = set([it["operating_system"] for it in instance_types])
|
|
131
|
-
valid_platforms = it_platforms.intersection(__platforms__)
|
|
132
|
-
|
|
121
|
+
instance_types = api_client.request_instance_types()
|
|
133
122
|
# SOFTWARE
|
|
134
|
-
software =
|
|
135
|
-
if not software:
|
|
136
|
-
software = api_client.request_software_packages()
|
|
123
|
+
software = api_client.request_software_packages()
|
|
137
124
|
|
|
138
|
-
#
|
|
139
|
-
|
|
140
|
-
|
|
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
|
|
141
132
|
|
|
133
|
+
# PLATFORMS
|
|
134
|
+
it_platforms = set([it["operating_system"] for it in instance_types])
|
|
135
|
+
valid_platforms = it_platforms.intersection(__platforms__)
|
|
142
136
|
kwargs = {"platforms": valid_platforms}
|
|
143
137
|
|
|
144
138
|
# If there's only one product, it's possible to initialize the software tree with a plugin.
|
|
@@ -158,14 +152,13 @@ def data(force=False):
|
|
|
158
152
|
instance_types = [
|
|
159
153
|
it for it in instance_types if it["operating_system"] in sw_platforms
|
|
160
154
|
]
|
|
161
|
-
|
|
155
|
+
# Then adjust __platforms__ to match the instance types that are represented.
|
|
162
156
|
__platforms__ = set([it["operating_system"] for it in instance_types])
|
|
163
157
|
|
|
164
158
|
__data__["instance_types"] = HardwareSet(instance_types)
|
|
165
159
|
|
|
166
160
|
return __data__
|
|
167
161
|
|
|
168
|
-
|
|
169
162
|
def valid():
|
|
170
163
|
"""
|
|
171
164
|
Check validity.
|
|
@@ -210,49 +203,9 @@ def products():
|
|
|
210
203
|
"""
|
|
211
204
|
return __products__
|
|
212
205
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
Specify a directory in which to find JSON files representing the three sets of data to provide.
|
|
217
|
-
The individual filenames are:
|
|
218
|
-
|
|
219
|
-
* `projects.json`
|
|
220
|
-
* `instance_types.json`
|
|
221
|
-
* `software.json`
|
|
222
|
-
|
|
223
|
-
These files could be used in an environment where machines can't access the internet. They are
|
|
224
|
-
also useful as a cache for developers who need to reload often as it avoids waiting for the
|
|
225
|
-
network.
|
|
226
|
-
|
|
227
|
-
In order to get the content for the fixtures files, use the following Example
|
|
228
|
-
|
|
229
|
-
Examples:
|
|
230
|
-
>>> from ciocore import api_client
|
|
231
|
-
>>> projects = api_client.request_projects()
|
|
232
|
-
>>> instance_types = api_client.request_instance_types()
|
|
233
|
-
>>> software = api_client.request_software_packages()
|
|
234
|
-
|
|
235
|
-
Write that data as JSON to the filenames listed above.
|
|
236
|
-
|
|
237
|
-
Arguments:
|
|
238
|
-
path (str): Directory in which to find the above files.
|
|
239
|
-
|
|
240
|
-
"""
|
|
241
|
-
|
|
242
|
-
global __fixtures_dir__
|
|
243
|
-
__fixtures_dir__ = path or ""
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
def _get_json_fixture(resource):
|
|
247
|
-
if __fixtures_dir__:
|
|
248
|
-
cache_path = os.path.join(__fixtures_dir__, "{}.json".format(resource))
|
|
249
|
-
if os.path.isfile(cache_path):
|
|
250
|
-
try:
|
|
251
|
-
with open(cache_path) as f:
|
|
252
|
-
return json.load(f)
|
|
253
|
-
except BaseException:
|
|
254
|
-
pass
|
|
255
|
-
|
|
206
|
+
def set_fixtures_dir(_):
|
|
207
|
+
"""Deprecated. """
|
|
208
|
+
pass
|
|
256
209
|
|
|
257
210
|
def platforms():
|
|
258
211
|
"""
|