ciocore 6.3.2rc1__py2.py3-none-any.whl → 6.4.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.

Files changed (91) hide show
  1. ciocore/VERSION +1 -1
  2. ciocore/__about__.py +3 -20
  3. ciocore/api_client.py +116 -236
  4. ciocore/cli/__init__.py +3 -0
  5. ciocore/cli/conductor.py +206 -0
  6. ciocore/config.py +44 -50
  7. ciocore/data.py +131 -85
  8. ciocore/downloader.py +64 -46
  9. ciocore/hardware_set.py +99 -326
  10. ciocore/package_environment.py +74 -48
  11. ciocore/package_tree.py +377 -300
  12. ciocore/uploader/_uploader.py +2 -6
  13. ciocore-6.4.0.data/scripts/conductor +19 -0
  14. ciocore-6.4.0.data/scripts/conductor.bat +13 -0
  15. {ciocore-6.3.2rc1.dist-info → ciocore-6.4.0.dist-info}/METADATA +12 -35
  16. ciocore-6.4.0.dist-info/RECORD +51 -0
  17. {ciocore-6.3.2rc1.dist-info → ciocore-6.4.0.dist-info}/WHEEL +1 -1
  18. tests/instance_type_fixtures.py +9 -43
  19. tests/mocks/api_client_mock.py +31 -0
  20. tests/test_hardware_set.py +4 -50
  21. ciocore/cli.py +0 -336
  22. ciocore/dev_inst_tagger.py +0 -120
  23. ciocore/docsite/404.html +0 -723
  24. ciocore/docsite/apidoc/api_client/index.html +0 -2590
  25. ciocore/docsite/apidoc/apidoc/index.html +0 -868
  26. ciocore/docsite/apidoc/config/index.html +0 -1562
  27. ciocore/docsite/apidoc/data/index.html +0 -1550
  28. ciocore/docsite/apidoc/hardware_set/index.html +0 -2324
  29. ciocore/docsite/apidoc/package_environment/index.html +0 -1430
  30. ciocore/docsite/apidoc/package_tree/index.html +0 -2310
  31. ciocore/docsite/assets/_mkdocstrings.css +0 -16
  32. ciocore/docsite/assets/images/favicon.png +0 -0
  33. ciocore/docsite/assets/javascripts/bundle.4e31edb1.min.js +0 -29
  34. ciocore/docsite/assets/javascripts/bundle.4e31edb1.min.js.map +0 -8
  35. ciocore/docsite/assets/javascripts/lunr/min/lunr.ar.min.js +0 -1
  36. ciocore/docsite/assets/javascripts/lunr/min/lunr.da.min.js +0 -18
  37. ciocore/docsite/assets/javascripts/lunr/min/lunr.de.min.js +0 -18
  38. ciocore/docsite/assets/javascripts/lunr/min/lunr.du.min.js +0 -18
  39. ciocore/docsite/assets/javascripts/lunr/min/lunr.es.min.js +0 -18
  40. ciocore/docsite/assets/javascripts/lunr/min/lunr.fi.min.js +0 -18
  41. ciocore/docsite/assets/javascripts/lunr/min/lunr.fr.min.js +0 -18
  42. ciocore/docsite/assets/javascripts/lunr/min/lunr.hi.min.js +0 -1
  43. ciocore/docsite/assets/javascripts/lunr/min/lunr.hu.min.js +0 -18
  44. ciocore/docsite/assets/javascripts/lunr/min/lunr.hy.min.js +0 -1
  45. ciocore/docsite/assets/javascripts/lunr/min/lunr.it.min.js +0 -18
  46. ciocore/docsite/assets/javascripts/lunr/min/lunr.ja.min.js +0 -1
  47. ciocore/docsite/assets/javascripts/lunr/min/lunr.jp.min.js +0 -1
  48. ciocore/docsite/assets/javascripts/lunr/min/lunr.kn.min.js +0 -1
  49. ciocore/docsite/assets/javascripts/lunr/min/lunr.ko.min.js +0 -1
  50. ciocore/docsite/assets/javascripts/lunr/min/lunr.multi.min.js +0 -1
  51. ciocore/docsite/assets/javascripts/lunr/min/lunr.nl.min.js +0 -18
  52. ciocore/docsite/assets/javascripts/lunr/min/lunr.no.min.js +0 -18
  53. ciocore/docsite/assets/javascripts/lunr/min/lunr.pt.min.js +0 -18
  54. ciocore/docsite/assets/javascripts/lunr/min/lunr.ro.min.js +0 -18
  55. ciocore/docsite/assets/javascripts/lunr/min/lunr.ru.min.js +0 -18
  56. ciocore/docsite/assets/javascripts/lunr/min/lunr.sa.min.js +0 -1
  57. ciocore/docsite/assets/javascripts/lunr/min/lunr.stemmer.support.min.js +0 -1
  58. ciocore/docsite/assets/javascripts/lunr/min/lunr.sv.min.js +0 -18
  59. ciocore/docsite/assets/javascripts/lunr/min/lunr.ta.min.js +0 -1
  60. ciocore/docsite/assets/javascripts/lunr/min/lunr.te.min.js +0 -1
  61. ciocore/docsite/assets/javascripts/lunr/min/lunr.th.min.js +0 -1
  62. ciocore/docsite/assets/javascripts/lunr/min/lunr.tr.min.js +0 -18
  63. ciocore/docsite/assets/javascripts/lunr/min/lunr.vi.min.js +0 -1
  64. ciocore/docsite/assets/javascripts/lunr/min/lunr.zh.min.js +0 -1
  65. ciocore/docsite/assets/javascripts/lunr/tinyseg.js +0 -206
  66. ciocore/docsite/assets/javascripts/lunr/wordcut.js +0 -6708
  67. ciocore/docsite/assets/javascripts/workers/search.dfff1995.min.js +0 -42
  68. ciocore/docsite/assets/javascripts/workers/search.dfff1995.min.js.map +0 -8
  69. ciocore/docsite/assets/stylesheets/main.83068744.min.css +0 -1
  70. ciocore/docsite/assets/stylesheets/main.83068744.min.css.map +0 -1
  71. ciocore/docsite/assets/stylesheets/palette.ecc896b0.min.css +0 -1
  72. ciocore/docsite/assets/stylesheets/palette.ecc896b0.min.css.map +0 -1
  73. ciocore/docsite/cmdline/docs/index.html +0 -834
  74. ciocore/docsite/cmdline/downloader/index.html +0 -897
  75. ciocore/docsite/cmdline/packages/index.html +0 -841
  76. ciocore/docsite/cmdline/uploader/index.html +0 -950
  77. ciocore/docsite/how-to-guides/index.html +0 -831
  78. ciocore/docsite/index.html +0 -853
  79. ciocore/docsite/logo.png +0 -0
  80. ciocore/docsite/objects.inv +0 -0
  81. ciocore/docsite/search/search_index.json +0 -1
  82. ciocore/docsite/sitemap.xml +0 -3
  83. ciocore/docsite/sitemap.xml.gz +0 -0
  84. ciocore/docsite/stylesheets/extra.css +0 -26
  85. ciocore/docsite/stylesheets/tables.css +0 -170
  86. ciocore/package_query.py +0 -171
  87. ciocore-6.3.2rc1.dist-info/RECORD +0 -115
  88. ciocore-6.3.2rc1.dist-info/entry_points.txt +0 -2
  89. tests/test_cli.py +0 -161
  90. tests/test_downloader.py +0 -56
  91. {ciocore-6.3.2rc1.dist-info → ciocore-6.4.0.dist-info}/top_level.txt +0 -0
ciocore/cli.py DELETED
@@ -1,336 +0,0 @@
1
- import os
2
- import logging
3
- import click
4
- import webbrowser
5
- import http.server
6
- import socketserver
7
-
8
-
9
- from ciocore import (
10
- loggeria,
11
- config,
12
- api_client,
13
- package_query,
14
- )
15
-
16
- from ciocore import __version__ as VERSION
17
-
18
- from ciocore.uploader import Uploader
19
- from ciocore.downloader import Downloader
20
-
21
- logger = logging.getLogger("conductor cli")
22
-
23
- LOG_LEVEL_HELP = """The logging level to display"""
24
-
25
- LOG_DIR_HELP = """
26
- Write a log file to the given directory. The log rotates, creating a new log file every day, while
27
- storing logs for the last 7 days. The log file is named conductor_ul.log
28
- """
29
-
30
- THREADS_HELP = """The number of threads that should download simultaneously"""
31
-
32
- UPLOADER_DATABASE_FILEPATH_HELP = (
33
- "Specify a filepath to the local md5 caching database."
34
- )
35
- LOCATION_HELP = """
36
- Specify a location tag to associate with uploads, downloads, and submissions. A location tag allows
37
- you to limit the scope of your uploads and downloads to jobs sharing the same location tag. This is
38
- useful while using the uploader or downloader in daemon mode.
39
- """
40
- UPLOADER_MD5_CACHING_HELP = """
41
- Use cached md5s. This can dramatically improve the uploading times, as md5 checking can be very
42
- time consuming. Caching md5s allows subsequent uploads (of the same files) to skip the md5
43
- generation process (if the files appear to not have been modified since the last time they were
44
- submitted). The cache is stored locally and uses a file's modification time and file size to
45
- intelligently guess whether the file has changed. Set this flag to False if there is concern that
46
- files may not be getting re-uploaded properly
47
- """
48
-
49
- UPLOADER_PATHS_HELP = """
50
- A list of paths to upload. Use quotes if paths contain spaces or special characters"""
51
-
52
- DOWNLOADER_JOB_ID_HELP = """
53
- The job id(s) to download. When specified will only download those jobs and terminate afterwards
54
- """
55
-
56
- DOWNLOADER_DEST_HELP = """
57
- Override the output directory"""
58
-
59
- PACKAGES_FORMAT_OPTIONS = ["text", "markdown", "html"]
60
- PACKAGES_FORMAT_HELP = """
61
- text: The output is a simple list of software names and versions, with nesting to indicate plugin
62
- compatibility. Output is sent to stdout.
63
-
64
- markdown: Designed for use in other markdown documentation systems where it benefits from consistent
65
- styling. Output is sent to stdout and can be piped to a file.
66
-
67
- html: Opens a browser window and displays the output in a simple html page.
68
- """
69
-
70
- DOCS_PORT_HELP = """
71
- The port to serve the documentation on. Defaults to 8025.
72
- """
73
- DEFAULT_DOCS_PORT=8025
74
-
75
- LOG_FORMATTER = logging.Formatter(
76
- "%(asctime)s %(name)s%(levelname)9s %(threadName)s: %(message)s"
77
- )
78
-
79
-
80
- cfg = config.get()
81
- DEFAULT_CONFIG_MD5_CACHING = cfg["md5_caching"]
82
- DEFAULT_CONFIG_THREAD_COUNT = cfg["thread_count"]
83
- DEFAULT_CONFIG_LOG_LEVEL = cfg["log_level"]
84
-
85
- def _set_logging(log_level=None, log_filepath=None):
86
- level = loggeria.LEVEL_MAP.get(log_level)
87
- loggeria.setup_conductor_logging(
88
- logger_level=level,
89
- console_formatter=LOG_FORMATTER,
90
- file_formatter=LOG_FORMATTER,
91
- log_filepath=log_filepath,
92
- )
93
-
94
- def _register(client):
95
- api_client.ApiClient.register_client(
96
- client_name=client.CLIENT_NAME, client_version=VERSION
97
- )
98
-
99
- ########################### MAIN #################################
100
- @click.group(invoke_without_command=True)
101
- @click.pass_context
102
- @click.option('-v', '--version', is_flag=True, help='Print the version and exit.')
103
- def main(ctx, version):
104
- """Conductor Command-line interface."""
105
- if not ctx.invoked_subcommand:
106
- if version:
107
- click.echo(VERSION)
108
- ctx.exit()
109
- click.echo(ctx.get_help())
110
- ctx.exit()
111
-
112
- ############################# UPLOADER #############################
113
- @main.command()
114
- @click.option("-db", "--database_filepath", help=UPLOADER_DATABASE_FILEPATH_HELP)
115
- @click.option( "-md5", "--md5_caching", help=UPLOADER_MD5_CACHING_HELP, type=bool, default=DEFAULT_CONFIG_MD5_CACHING,)
116
- @click.option("-lv", "--log_level", help=LOG_LEVEL_HELP, type=click.Choice(choices=loggeria.LEVELS, case_sensitive=False), show_choices=True, default=DEFAULT_CONFIG_LOG_LEVEL)
117
- @click.option("-ld", "--log_dir", help=LOG_DIR_HELP)
118
- @click.option("-tc", "--thread_count", type=int, help=THREADS_HELP, default=DEFAULT_CONFIG_THREAD_COUNT)
119
- @click.option("-lc", "--location", help=LOCATION_HELP)
120
- @click.argument("paths", nargs=-1, type=click.Path(exists=True, resolve_path=True))
121
- def upload(
122
- database_filepath, location, md5_caching, log_level, log_dir, thread_count, paths
123
- ):
124
- """Upload files to Conductor.
125
-
126
- With no arguments, the uploader runs in daemon mode, watching for files to upload for submitted
127
- jobs.
128
-
129
- Alternatively, specify a list of paths to upload.
130
-
131
- Example:
132
- conductor upload file1 file2 file3
133
- """
134
- logfile = log_dir and os.path.join(log_dir, "conductor_ul.log")
135
- _set_logging(log_level, logfile)
136
-
137
- args_dict = {
138
- "database_filepath": database_filepath,
139
- "location": location,
140
- "md5_caching": md5_caching,
141
- "log_level": log_level,
142
- "log_dir": log_dir,
143
- "thread_count": thread_count,
144
- }
145
-
146
- up = Uploader(args_dict)
147
-
148
- if paths:
149
- up.assets_only(*paths)
150
- return
151
-
152
- up.main()
153
-
154
- ########################### DOWNLOADER #############################
155
- @main.command()
156
- @click.argument("jobids", nargs=-1)
157
- @click.option("-d", "--destination", help=DOWNLOADER_DEST_HELP)
158
- @click.option("-lv", "--log_level", help=LOG_LEVEL_HELP, type=click.Choice(choices=loggeria.LEVELS, case_sensitive=False), show_choices=True, default=DEFAULT_CONFIG_LOG_LEVEL)
159
- @click.option("-ld", "--log_dir", help=LOG_DIR_HELP)
160
- @click.option("-tc", "--thread_count", type=int, help=THREADS_HELP, default=DEFAULT_CONFIG_THREAD_COUNT)
161
- @click.option("-lc", "--location", help=LOCATION_HELP)
162
-
163
- def download(jobids, destination, location, log_level, log_dir, thread_count):
164
- """
165
- Download renders and other output files from Conductor. You can give a list of job ids to
166
- download, or you can omit jobids and the downloader will run in daemon mode.
167
-
168
- If you provide jobids, the default behavior is to download all the files from completed tasks
169
- for those jobs. You can however specify an explicit set of tasks to downloade by providing a
170
- task range spec after each job id. To do so, append a colon to the job id and then a compact
171
- task specification. See the examples.
172
-
173
- In daemon mode, the downloader polls for new jobs to download. You can specify a location tag to
174
- limit the scope of the downloader to only download jobs that were submitted with the same
175
- location tag.
176
-
177
- Examples:
178
- conductor download # daemon mode
179
- conductor download 1234 1235
180
- conductor download 1234:1-10
181
- conductor download 1234:1-5x2,10,12-14
182
- conductor download 1234:1-5 1235:5-10
183
- """
184
- logfile = log_dir and os.path.join(log_dir, "conductor_dl.log")
185
- _set_logging(log_level, logfile)
186
- _register(Downloader)
187
- if jobids:
188
- Downloader.download_jobs(
189
- jobids,
190
- thread_count=thread_count,
191
- output_dir=destination,
192
- )
193
- else:
194
- Downloader.start_daemon(
195
- thread_count=thread_count, location=location, output_dir=destination
196
- )
197
-
198
-
199
- ########################### PACKAGES #############################
200
- @main.command()
201
- @click.option(
202
- "-f",
203
- "--fmt",
204
- "--format",
205
- default="text",
206
- help=PACKAGES_FORMAT_HELP,
207
- type=click.Choice(choices=PACKAGES_FORMAT_OPTIONS, case_sensitive=False),
208
- )
209
- def packages(fmt):
210
- """List the softweare packages available on the render nodes in the cloud."""
211
- package_query.pq(format=fmt)
212
-
213
-
214
- ########################### DOCS #############################
215
- @main.command()
216
- @click.option(
217
- "-p",
218
- "--port",
219
- help=DOCS_PORT_HELP,
220
- type=int,
221
- default=DEFAULT_DOCS_PORT,
222
- )
223
- def docs(port):
224
- """Open the Conductor Core documentation in a web browser."""
225
-
226
- handler = http.server.SimpleHTTPRequestHandler
227
- with socketserver.TCPServer(("", port), handler) as httpd:
228
-
229
- print(f"Server started at http://localhost:{port}")
230
- print("Press Ctrl+C to stop the server")
231
-
232
- # Change to the directory containing your site
233
- current_dir = os.path.dirname(os.path.abspath(__file__))
234
- site_dir = os.path.join(current_dir, "docsite")
235
- os.chdir(site_dir)
236
-
237
- # Start the server
238
- localhost_url = f"http://localhost:{port}"
239
- webbrowser.open(localhost_url)
240
- httpd.serve_forever()
241
-
242
-
243
- ########################### DEPRECATIONS #############################
244
- ############################# UPLOADER #############################
245
- DEPRECATED_PATHS_HELP="Specify a list of paths to upload."
246
-
247
- @main.command(deprecated=True)
248
- @click.option("-db", "--database_filepath", help=UPLOADER_DATABASE_FILEPATH_HELP)
249
- @click.option( "-md5", "--md5_caching", help=UPLOADER_MD5_CACHING_HELP, type=bool, default=DEFAULT_CONFIG_MD5_CACHING )
250
- @click.option("-lv", "--log_level", help=LOG_LEVEL_HELP, type=click.Choice(choices=loggeria.LEVELS, case_sensitive=False), show_choices=True, default=DEFAULT_CONFIG_LOG_LEVEL)
251
- @click.option("-ld", "--log_dir", help=LOG_DIR_HELP)
252
- @click.option("-tc", "--thread_count", type=int, help=THREADS_HELP, default=DEFAULT_CONFIG_THREAD_COUNT)
253
- @click.option("-lc", "--location", help=LOCATION_HELP)
254
- @click.option("-p", "--paths", help=DEPRECATED_PATHS_HELP, multiple=True, type=click.Path(exists=True, resolve_path=True))
255
-
256
-
257
-
258
- def uploader(
259
- database_filepath, location, md5_caching, log_level, log_dir, thread_count, paths
260
- ):
261
- """Upload files to Conductor.
262
-
263
- With no arguments, the uploader runs in daemon mode, watching for files to upload for submitted
264
- jobs.
265
-
266
- Alternatively, specify a list of paths to upload with the --paths option.
267
-
268
- Example:
269
- conductor upload file1 file2 file3
270
- """
271
- logfile = log_dir and os.path.join(log_dir, "conductor_ul.log")
272
- _set_logging(log_level, logfile)
273
-
274
- args_dict = {
275
- "database_filepath": database_filepath,
276
- "location": location,
277
- "md5_caching": md5_caching,
278
- "log_level": log_level,
279
- "log_dir": log_dir,
280
- "thread_count": thread_count,
281
- }
282
-
283
- up = Uploader(args_dict)
284
-
285
- if paths:
286
- up.assets_only(*paths)
287
- return
288
-
289
- up.main()
290
-
291
- ########################### DOWNLOADER #############################
292
- DEPRECATED_JOBID_HELP="Download all the files from completed tasks for the given jobs."
293
- DEPRECATED_TASKID_HELP="Download the files from the given tasks in the specified job."
294
-
295
- @main.command(deprecated=True)
296
- @click.option("-o", "--output", help=DOWNLOADER_DEST_HELP)
297
- @click.option("-j", "--job_id", help=DEPRECATED_JOBID_HELP)
298
- @click.option("-t", "--task_id", help=DEPRECATED_TASKID_HELP)
299
- @click.option("-lv", "--log_level", help=LOG_LEVEL_HELP, type=click.Choice(choices=loggeria.LEVELS, case_sensitive=False), show_choices=True, default=DEFAULT_CONFIG_LOG_LEVEL)
300
- @click.option("-ld", "--log_dir", help=LOG_DIR_HELP)
301
- @click.option("-tc", "--thread_count", type=int, help=THREADS_HELP, default=DEFAULT_CONFIG_THREAD_COUNT)
302
- @click.option("-lc", "--location", help=LOCATION_HELP)
303
- @click.pass_context
304
- def downloader(ctx, job_id, task_id, output, location, log_level, log_dir, thread_count):
305
- """
306
- Download renders and other output files from Conductor. You can specify a job id and optional task id to
307
- download, or you can omit all options and the downloader will run in daemon mode.
308
-
309
- In daemon mode, the downloader polls for new jobs to download. You can specify a location tag to
310
- limit the scope of the downloader to only download jobs that were submitted with the same
311
- location tag.
312
-
313
- Examples:
314
- conductor downloader # daemon mode
315
- conductor downloader --job_id --task_id 01234
316
- conductor downloader --task_id --task_id 123
317
- """
318
-
319
- logfile = log_dir and os.path.join(log_dir, "conductor_dl.log")
320
- _set_logging(log_level, logfile)
321
- _register(Downloader)
322
-
323
- if not job_id and not task_id:
324
- Downloader.start_daemon(
325
- thread_count=thread_count, location=location, output_dir=output
326
- )
327
- ctx.exit(0)
328
-
329
- if task_id:
330
- job_id = job_id + ":" + task_id
331
-
332
- Downloader.download_jobs(
333
- (job_id,),
334
- thread_count=thread_count,
335
- output_dir=output,
336
- )
@@ -1,120 +0,0 @@
1
- """
2
- DEV only. This module is used to request instance types from the inst-tagger service. We try to isolate the cod so it can be easily removed.
3
- """
4
-
5
- import os
6
- import requests
7
- from ciocore import api_client
8
-
9
- USE_INST_TAGGER = int(os.environ.get("CIO_FEATURE_USE_INST_TAGGER", 0))
10
- SUPABASE_URL = os.environ.get("CIO_FEATURE_INST_TAGGER_SUPABASE_URL")
11
- SUPABASE_KEY = os.environ.get("CIO_FEATURE_INST_TAGGER_SUPABASE_KEY")
12
-
13
- def request_supabase_data(table_name):
14
- HEADERS = {
15
- "Authorization": f"Bearer {SUPABASE_KEY}",
16
- "apikey": SUPABASE_KEY,
17
- "Content-Type": "application/json",
18
- }
19
-
20
- response = requests.get(
21
- f"{SUPABASE_URL}/rest/v1/{table_name}", headers=HEADERS, timeout=5
22
- )
23
- if response.status_code == 200:
24
- return response.json()
25
- else:
26
- print("Error:", response.status_code, response.text)
27
- return None
28
-
29
-
30
- def get_cloud(cio_inst_types):
31
- if not cio_inst_types:
32
- return None
33
- if cio_inst_types[0]["name"].startswith("cw-"):
34
- return "cw"
35
- elif "." in cio_inst_types[0]["name"]:
36
- return "aws"
37
- return "gcp"
38
-
39
-
40
- def normalize_sb_inst_types(sb_inst_types):
41
- result = []
42
- for inst_type in sb_inst_types:
43
- el = inst_type["instance_type"].copy()
44
- el["id"] = inst_type["id"]
45
- result.append(el)
46
- return result
47
-
48
-
49
- def to_id_dict(thelist):
50
- return {d["id"]: d for d in thelist}
51
-
52
-
53
- def valid_inst_types():
54
- sb_inst_types = request_supabase_data("instance_types")
55
- sb_inst_types = normalize_sb_inst_types(sb_inst_types)
56
-
57
- cio_inst_types = api_client.request_instance_types()
58
- # print(json.dumps(cio_inst_types, indent=2))
59
-
60
- cloud = get_cloud(cio_inst_types)
61
-
62
- # filter out instance types that are not in the cloud
63
-
64
- sb_inst_types = [
65
- inst_type for inst_type in sb_inst_types if inst_type["cloud"] == cloud
66
- ]
67
- for it in sb_inst_types:
68
- it["cores"] = it["total_cpu"]
69
- it["memory"] = it["total_memory_gb"]
70
-
71
- cores = it["cores"]
72
- mem = it["memory_gb"]
73
- cpu_desc = f"{cores} cores, {mem} GB RAM"
74
- gpu_desc = ""
75
- if it["gpu"]:
76
- gpu_count = it["gpu"]["gpu_count"]
77
- gpu_model = it["gpu"]["gpu_model"]
78
- gpu_arch = it["gpu"]["gpu_architecture"]
79
- gpu_mem = it["gpu"]["total_gpu_memory"]
80
- gpu_desc = f" ({gpu_count}x {gpu_model} ({gpu_arch}) {gpu_mem} GB)"
81
-
82
- desc = f"{cpu_desc}{gpu_desc}"
83
- it["description"] = desc
84
-
85
- return sb_inst_types
86
-
87
-
88
- def request_instance_types():
89
- """
90
- Request instance types from the inst-tagger service.
91
-
92
- Returns:
93
- list(dict): A list of instance types.
94
- """
95
- if not USE_INST_TAGGER:
96
- return None
97
-
98
- inst_types = valid_inst_types()
99
-
100
- tags = request_supabase_data("tags")
101
- tag_ids = [tag["id"] for tag in tags]
102
- tags_dict = to_id_dict(tags)
103
-
104
- assignments = request_supabase_data("assignments")
105
- assignments = [a for a in assignments if a["tag_id"] in tag_ids]
106
-
107
-
108
- # assign tags to instance types
109
- for inst_type in inst_types:
110
- inst_type["categories"] = []
111
- # find assignments relating to this instance type
112
- these_assignments = [
113
- a for a in assignments if a["instance_type_id"] == inst_type["id"]
114
- ]
115
-
116
- for assignment in these_assignments:
117
- tag = tags_dict[assignment["tag_id"]]
118
- inst_type["categories"].append({"label": tag["label"], "order": tag["order"]})
119
-
120
- return inst_types