setta 0.0.1.dev0__py3-none-any.whl → 0.0.2.dev0__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- setta/__init__.py +1 -1
- setta/cli/__init__.py +1 -0
- setta/cli/connect.py +43 -0
- setta/cli/logger.py +225 -0
- setta/code_gen/__init__.py +0 -0
- setta/code_gen/create_runnable_scripts.py +466 -0
- setta/code_gen/export_selected.py +776 -0
- setta/code_gen/find_placeholders.py +13 -0
- setta/code_gen/python/__init__.py +0 -0
- setta/code_gen/python/ast_utils.py +183 -0
- setta/code_gen/python/check_scope.py +187 -0
- setta/code_gen/python/generate_code.py +280 -0
- setta/code_gen/python/make_parseable.py +97 -0
- setta/code_gen/python/position_line_col.py +33 -0
- setta/code_gen/python/validate_imports.py +87 -0
- setta/code_gen/utils.py +120 -0
- setta/code_gen/yaml/__init__.py +0 -0
- setta/code_gen/yaml/generate_yaml.py +23 -0
- setta/code_gen/yaml/section_dict.py +93 -0
- setta/database/__init__.py +0 -0
- setta/database/backup.py +80 -0
- setta/database/db/__init__.py +0 -0
- setta/database/db/artifacts/__init__.py +0 -0
- setta/database/db/artifacts/load.py +93 -0
- setta/database/db/artifacts/save.py +85 -0
- setta/database/db/artifacts/save_or_create.py +68 -0
- setta/database/db/artifacts/utils.py +13 -0
- setta/database/db/codeInfo/__init__.py +0 -0
- setta/database/db/codeInfo/copy.py +26 -0
- setta/database/db/codeInfo/load.py +65 -0
- setta/database/db/codeInfo/save.py +75 -0
- setta/database/db/codeInfo/utils.py +33 -0
- setta/database/db/evRefs/__init__.py +0 -0
- setta/database/db/evRefs/load.py +45 -0
- setta/database/db/evRefs/save.py +95 -0
- setta/database/db/projects/__init__.py +0 -0
- setta/database/db/projects/copy.py +36 -0
- setta/database/db/projects/delete.py +7 -0
- setta/database/db/projects/load.py +184 -0
- setta/database/db/projects/save.py +267 -0
- setta/database/db/projects/saveAs.py +40 -0
- setta/database/db/projects/utils.py +135 -0
- setta/database/db/sectionVariants/__init__.py +0 -0
- setta/database/db/sectionVariants/copy.py +28 -0
- setta/database/db/sectionVariants/load.py +139 -0
- setta/database/db/sectionVariants/save.py +140 -0
- setta/database/db/sectionVariants/utils.py +44 -0
- setta/database/db/sections/__init__.py +0 -0
- setta/database/db/sections/copy.py +70 -0
- setta/database/db/sections/jsonSource.py +119 -0
- setta/database/db/sections/load.py +350 -0
- setta/database/db/sections/save.py +204 -0
- setta/database/db/sections/utils.py +13 -0
- setta/database/db/uiTypes/__init__.py +0 -0
- setta/database/db/uiTypes/copy.py +33 -0
- setta/database/db/uiTypes/load.py +51 -0
- setta/database/db/uiTypes/save.py +99 -0
- setta/database/db/uiTypes/utils.py +27 -0
- setta/database/db_init.py +36 -0
- setta/database/db_objs.py +102 -0
- setta/database/db_path.py +8 -0
- setta/database/export_db/__init__.py +0 -0
- setta/database/export_db/export_db.py +43 -0
- setta/database/export_db/export_raw.py +53 -0
- setta/database/export_db/export_readable.py +242 -0
- setta/database/export_db/utils.py +16 -0
- setta/database/import_db.py +28 -0
- setta/database/seed.py +41 -0
- setta/database/settings_file.py +118 -0
- setta/database/utils.py +32 -0
- setta/lsp/__init__.py +0 -0
- setta/lsp/file_watcher.py +113 -0
- setta/lsp/reader.py +184 -0
- setta/lsp/reader_fns/__init__.py +0 -0
- setta/lsp/reader_fns/completion.py +84 -0
- setta/lsp/reader_fns/definition.py +2 -0
- setta/lsp/reader_fns/diagnostics.py +99 -0
- setta/lsp/reader_fns/documentHighlight.py +25 -0
- setta/lsp/reader_fns/references.py +34 -0
- setta/lsp/reader_fns/signatureHelp.py +99 -0
- setta/lsp/server.py +150 -0
- setta/lsp/utils.py +60 -0
- setta/lsp/writer.py +306 -0
- setta/routers/__init__.py +11 -0
- setta/routers/artifact.py +105 -0
- setta/routers/code_info.py +32 -0
- setta/routers/dependencies.py +49 -0
- setta/routers/in_memory_fn_stdout_websocket.py +21 -0
- setta/routers/interactive.py +119 -0
- setta/routers/lsp.py +14 -0
- setta/routers/projects.py +188 -0
- setta/routers/reference_renaming.py +111 -0
- setta/routers/sections.py +174 -0
- setta/routers/settings.py +40 -0
- setta/routers/terminals.py +83 -0
- setta/routers/websocket.py +36 -0
- setta/server.py +141 -0
- setta/start.py +112 -0
- setta/static/constants/BaseUITypes.json +153 -0
- setta/static/constants/Settings.json +113 -0
- setta/static/constants/constants.json +117 -0
- setta/static/constants/db_init.sql +249 -0
- setta/static/constants/defaultValues.json +125 -0
- setta/static/constants/settingsProject.json +276 -0
- setta/static/frontend/android-chrome-192x192.png +0 -0
- setta/static/frontend/android-chrome-512x512.png +0 -0
- setta/static/frontend/apple-touch-icon.png +0 -0
- setta/static/frontend/assets/KaTeX_AMS-Regular-0cdd387c.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_AMS-Regular-30da91e8.woff +0 -0
- setta/static/frontend/assets/KaTeX_AMS-Regular-68534840.ttf +0 -0
- setta/static/frontend/assets/KaTeX_Caligraphic-Bold-07d8e303.ttf +0 -0
- setta/static/frontend/assets/KaTeX_Caligraphic-Bold-1ae6bd74.woff +0 -0
- setta/static/frontend/assets/KaTeX_Caligraphic-Bold-de7701e4.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_Caligraphic-Regular-3398dd02.woff +0 -0
- setta/static/frontend/assets/KaTeX_Caligraphic-Regular-5d53e70a.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_Caligraphic-Regular-ed0b7437.ttf +0 -0
- setta/static/frontend/assets/KaTeX_Fraktur-Bold-74444efd.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_Fraktur-Bold-9163df9c.ttf +0 -0
- setta/static/frontend/assets/KaTeX_Fraktur-Bold-9be7ceb8.woff +0 -0
- setta/static/frontend/assets/KaTeX_Fraktur-Regular-1e6f9579.ttf +0 -0
- setta/static/frontend/assets/KaTeX_Fraktur-Regular-51814d27.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_Fraktur-Regular-5e28753b.woff +0 -0
- setta/static/frontend/assets/KaTeX_Main-Bold-0f60d1b8.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_Main-Bold-138ac28d.ttf +0 -0
- setta/static/frontend/assets/KaTeX_Main-Bold-c76c5d69.woff +0 -0
- setta/static/frontend/assets/KaTeX_Main-BoldItalic-70ee1f64.ttf +0 -0
- setta/static/frontend/assets/KaTeX_Main-BoldItalic-99cd42a3.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_Main-BoldItalic-a6f7ec0d.woff +0 -0
- setta/static/frontend/assets/KaTeX_Main-Italic-0d85ae7c.ttf +0 -0
- setta/static/frontend/assets/KaTeX_Main-Italic-97479ca6.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_Main-Italic-f1d6ef86.woff +0 -0
- setta/static/frontend/assets/KaTeX_Main-Regular-c2342cd8.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_Main-Regular-c6368d87.woff +0 -0
- setta/static/frontend/assets/KaTeX_Main-Regular-d0332f52.ttf +0 -0
- setta/static/frontend/assets/KaTeX_Math-BoldItalic-850c0af5.woff +0 -0
- setta/static/frontend/assets/KaTeX_Math-BoldItalic-dc47344d.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_Math-BoldItalic-f9377ab0.ttf +0 -0
- setta/static/frontend/assets/KaTeX_Math-Italic-08ce98e5.ttf +0 -0
- setta/static/frontend/assets/KaTeX_Math-Italic-7af58c5e.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_Math-Italic-8a8d2445.woff +0 -0
- setta/static/frontend/assets/KaTeX_SansSerif-Bold-1ece03f7.ttf +0 -0
- setta/static/frontend/assets/KaTeX_SansSerif-Bold-e99ae511.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_SansSerif-Bold-ece03cfd.woff +0 -0
- setta/static/frontend/assets/KaTeX_SansSerif-Italic-00b26ac8.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_SansSerif-Italic-3931dd81.ttf +0 -0
- setta/static/frontend/assets/KaTeX_SansSerif-Italic-91ee6750.woff +0 -0
- setta/static/frontend/assets/KaTeX_SansSerif-Regular-11e4dc8a.woff +0 -0
- setta/static/frontend/assets/KaTeX_SansSerif-Regular-68e8c73e.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_SansSerif-Regular-f36ea897.ttf +0 -0
- setta/static/frontend/assets/KaTeX_Script-Regular-036d4e95.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_Script-Regular-1c67f068.ttf +0 -0
- setta/static/frontend/assets/KaTeX_Script-Regular-d96cdf2b.woff +0 -0
- setta/static/frontend/assets/KaTeX_Size1-Regular-6b47c401.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_Size1-Regular-95b6d2f1.ttf +0 -0
- setta/static/frontend/assets/KaTeX_Size1-Regular-c943cc98.woff +0 -0
- setta/static/frontend/assets/KaTeX_Size2-Regular-2014c523.woff +0 -0
- setta/static/frontend/assets/KaTeX_Size2-Regular-a6b2099f.ttf +0 -0
- setta/static/frontend/assets/KaTeX_Size2-Regular-d04c5421.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_Size3-Regular-500e04d5.ttf +0 -0
- setta/static/frontend/assets/KaTeX_Size3-Regular-6ab6b62e.woff +0 -0
- setta/static/frontend/assets/KaTeX_Size4-Regular-99f9c675.woff +0 -0
- setta/static/frontend/assets/KaTeX_Size4-Regular-a4af7d41.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_Size4-Regular-c647367d.ttf +0 -0
- setta/static/frontend/assets/KaTeX_Typewriter-Regular-71d517d6.woff2 +0 -0
- setta/static/frontend/assets/KaTeX_Typewriter-Regular-e14fed02.woff +0 -0
- setta/static/frontend/assets/KaTeX_Typewriter-Regular-f01f3e87.ttf +0 -0
- setta/static/frontend/assets/cormorant-garamond-all-700-italic-c9b58582.woff +0 -0
- setta/static/frontend/assets/cormorant-garamond-cyrillic-700-italic-9101ad5f.woff2 +0 -0
- setta/static/frontend/assets/cormorant-garamond-cyrillic-ext-700-italic-950de0d6.woff2 +0 -0
- setta/static/frontend/assets/cormorant-garamond-latin-700-italic-0bc53e12.woff2 +0 -0
- setta/static/frontend/assets/cormorant-garamond-latin-ext-700-italic-525738e0.woff2 +0 -0
- setta/static/frontend/assets/cormorant-garamond-vietnamese-700-italic-99563037.woff2 +0 -0
- setta/static/frontend/assets/erase-5e0448ea.svg +15 -0
- setta/static/frontend/assets/index-1d4b4ecf.css +32 -0
- setta/static/frontend/assets/index-ee99dc72.js +678 -0
- setta/static/frontend/assets/inter-all-400-normal-054f12d0.woff +0 -0
- setta/static/frontend/assets/inter-all-600-normal-c03769e5.woff +0 -0
- setta/static/frontend/assets/inter-all-800-normal-15dc6e4b.woff +0 -0
- setta/static/frontend/assets/inter-cyrillic-400-normal-a4eee61a.woff2 +0 -0
- setta/static/frontend/assets/inter-cyrillic-600-normal-8b14f703.woff2 +0 -0
- setta/static/frontend/assets/inter-cyrillic-800-normal-e706eaaa.woff2 +0 -0
- setta/static/frontend/assets/inter-cyrillic-ext-400-normal-70047a3b.woff2 +0 -0
- setta/static/frontend/assets/inter-cyrillic-ext-600-normal-d4ab9bc4.woff2 +0 -0
- setta/static/frontend/assets/inter-cyrillic-ext-800-normal-eae7515a.woff2 +0 -0
- setta/static/frontend/assets/inter-greek-400-normal-381ea30d.woff2 +0 -0
- setta/static/frontend/assets/inter-greek-600-normal-601f93a2.woff2 +0 -0
- setta/static/frontend/assets/inter-greek-800-normal-7af4fb64.woff2 +0 -0
- setta/static/frontend/assets/inter-greek-ext-400-normal-27027b17.woff2 +0 -0
- setta/static/frontend/assets/inter-greek-ext-600-normal-f2ddf9de.woff2 +0 -0
- setta/static/frontend/assets/inter-greek-ext-800-normal-4cb6189e.woff2 +0 -0
- setta/static/frontend/assets/inter-latin-400-normal-d56fec21.woff2 +0 -0
- setta/static/frontend/assets/inter-latin-600-normal-ff769fa6.woff2 +0 -0
- setta/static/frontend/assets/inter-latin-800-normal-5eea1309.woff2 +0 -0
- setta/static/frontend/assets/inter-latin-ext-400-normal-bb698d85.woff2 +0 -0
- setta/static/frontend/assets/inter-latin-ext-600-normal-ca4808f9.woff2 +0 -0
- setta/static/frontend/assets/inter-latin-ext-800-normal-ebdacc0f.woff2 +0 -0
- setta/static/frontend/assets/logo/logo.svg +8 -0
- setta/static/frontend/assets/pen-455d7d8a.svg +19 -0
- setta/static/frontend/assets/source-code-pro-all-500-normal-6bdaa03b.woff +0 -0
- setta/static/frontend/assets/source-code-pro-cyrillic-500-normal-288a0d68.woff2 +0 -0
- setta/static/frontend/assets/source-code-pro-cyrillic-ext-500-normal-b110a13b.woff2 +0 -0
- setta/static/frontend/assets/source-code-pro-greek-500-normal-04328acb.woff2 +0 -0
- setta/static/frontend/assets/source-code-pro-latin-500-normal-06edef1e.woff2 +0 -0
- setta/static/frontend/assets/source-code-pro-latin-ext-500-normal-6dc60d5e.woff2 +0 -0
- setta/static/frontend/assets/web-vitals-44a8e082.js +1 -0
- setta/static/frontend/assets/work-sans-all-400-normal-38034a3c.woff +0 -0
- setta/static/frontend/assets/work-sans-all-500-normal-550d64e5.woff +0 -0
- setta/static/frontend/assets/work-sans-all-600-normal-ccf14060.woff +0 -0
- setta/static/frontend/assets/work-sans-all-700-normal-494c2971.woff +0 -0
- setta/static/frontend/assets/work-sans-latin-400-normal-36735bc1.woff2 +0 -0
- setta/static/frontend/assets/work-sans-latin-500-normal-3790bfda.woff2 +0 -0
- setta/static/frontend/assets/work-sans-latin-600-normal-5fba494e.woff2 +0 -0
- setta/static/frontend/assets/work-sans-latin-700-normal-a5033d0a.woff2 +0 -0
- setta/static/frontend/assets/work-sans-latin-ext-400-normal-c20f571a.woff2 +0 -0
- setta/static/frontend/assets/work-sans-latin-ext-500-normal-0f5ac96c.woff2 +0 -0
- setta/static/frontend/assets/work-sans-latin-ext-600-normal-97a237d1.woff2 +0 -0
- setta/static/frontend/assets/work-sans-latin-ext-700-normal-103e112c.woff2 +0 -0
- setta/static/frontend/browserconfig.xml +9 -0
- setta/static/frontend/favicon-16x16.png +0 -0
- setta/static/frontend/favicon-32x32.png +0 -0
- setta/static/frontend/favicon.ico +0 -0
- setta/static/frontend/index.html +30 -0
- setta/static/frontend/manifest.json +25 -0
- setta/static/frontend/mstile-144x144.png +0 -0
- setta/static/frontend/mstile-150x150.png +0 -0
- setta/static/frontend/mstile-310x150.png +0 -0
- setta/static/frontend/mstile-310x310.png +0 -0
- setta/static/frontend/mstile-70x70.png +0 -0
- setta/static/frontend/robots.txt +3 -0
- setta/static/frontend/safari-pinned-tab.svg +18 -0
- setta/static/frontend/site.webmanifest +19 -0
- setta/static/seed/.DS_Store +0 -0
- setta/static/seed/examples/.DS_Store +0 -0
- setta/tasks/__init__.py +0 -0
- setta/tasks/fns/__init__.py +9 -0
- setta/tasks/fns/codeAreaAutocomplete.py +209 -0
- setta/tasks/fns/codeAreaFindTemplateVars.py +128 -0
- setta/tasks/fns/codeAreaInitializeCode.py +98 -0
- setta/tasks/fns/findEVRefs.py +236 -0
- setta/tasks/fns/parametersRequest.py +71 -0
- setta/tasks/fns/textFieldAutocomplete.py +210 -0
- setta/tasks/fns/textFieldInitializeCode.py +99 -0
- setta/tasks/fns/typeCheck.py +40 -0
- setta/tasks/fns/utils.py +134 -0
- setta/tasks/task_runner.py +29 -0
- setta/tasks/tasks.py +152 -0
- setta/tasks/utils.py +178 -0
- setta/terminals/__init__.py +0 -0
- setta/terminals/terminals.py +242 -0
- setta/terminals/utils.py +37 -0
- setta/utils/__init__.py +0 -0
- setta/utils/constants.py +148 -0
- setta/utils/generate_memorable_string.py +431 -0
- setta/utils/generate_new_filename.py +80 -0
- setta/utils/section_contents.py +133 -0
- setta/utils/utils.py +271 -0
- setta/utils/websocket_manager.py +91 -0
- setta-0.0.2.dev0.dist-info/LICENSE +201 -0
- setta-0.0.2.dev0.dist-info/METADATA +24 -0
- setta-0.0.2.dev0.dist-info/RECORD +263 -0
- {setta-0.0.1.dev0.dist-info → setta-0.0.2.dev0.dist-info}/WHEEL +1 -1
- setta-0.0.2.dev0.dist-info/entry_points.txt +2 -0
- setta-0.0.1.dev0.dist-info/METADATA +0 -18
- setta-0.0.1.dev0.dist-info/RECORD +0 -5
- {setta-0.0.1.dev0.dist-info → setta-0.0.2.dev0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,776 @@
|
|
1
|
+
import copy
|
2
|
+
|
3
|
+
from setta.database.db.codeInfo.utils import new_code_info_col
|
4
|
+
from setta.database.db.sectionVariants.utils import new_ev_entry, new_section_variant
|
5
|
+
from setta.database.db.uiTypes.utils import new_ui_type_col_entry
|
6
|
+
from setta.utils.section_contents import findAllParametersAndPathMaps
|
7
|
+
from setta.utils.utils import QuoteInsensitiveDict, replace_null_keys_with_none
|
8
|
+
|
9
|
+
from ..utils.constants import BASE_UI_TYPES, C
|
10
|
+
from .find_placeholders import tp
|
11
|
+
from .utils import process_refs
|
12
|
+
|
13
|
+
|
14
|
+
def get_args_var_name(var_name):
|
15
|
+
return f"{C.ARGS_PREFIX}{var_name}"
|
16
|
+
|
17
|
+
|
18
|
+
def get_section_type(p, id):
|
19
|
+
ui_type_id = p["sections"][id]["uiTypeId"]
|
20
|
+
ui_type = p["uiTypes"].get(ui_type_id) or BASE_UI_TYPES[ui_type_id]
|
21
|
+
return ui_type["type"]
|
22
|
+
|
23
|
+
|
24
|
+
def get_artifacts(p, id):
|
25
|
+
return p["sections"][id]["artifacts"]
|
26
|
+
|
27
|
+
|
28
|
+
def get_drawing(p, id):
|
29
|
+
return p["sections"][id]["drawing"]
|
30
|
+
|
31
|
+
|
32
|
+
def get_section_name(p, id):
|
33
|
+
return p["sections"][id]["name"]
|
34
|
+
|
35
|
+
|
36
|
+
def get_selected_item(p, id):
|
37
|
+
selected_item = get_selected_section_variant(p, id)["selectedItem"]
|
38
|
+
if selected_item:
|
39
|
+
return p["codeInfo"][selected_item]
|
40
|
+
return None
|
41
|
+
|
42
|
+
|
43
|
+
def get_selected_item_name(p, id):
|
44
|
+
selected_item = get_selected_item(p, id)
|
45
|
+
if selected_item:
|
46
|
+
return selected_item["name"]
|
47
|
+
return None
|
48
|
+
|
49
|
+
|
50
|
+
def get_selected_item_id(p, id):
|
51
|
+
selected_item = get_selected_item(p, id)
|
52
|
+
if selected_item:
|
53
|
+
return selected_item["id"]
|
54
|
+
return None
|
55
|
+
|
56
|
+
|
57
|
+
def get_selected_item_ev_refs(p, id):
|
58
|
+
selected_item = get_selected_item(p, id)
|
59
|
+
if selected_item:
|
60
|
+
return selected_item["evRefs"]
|
61
|
+
return None
|
62
|
+
|
63
|
+
|
64
|
+
def get_code_info_children(p, section_id, id):
|
65
|
+
codeInfoChildren = get_section_code_info_children(p, section_id)
|
66
|
+
return codeInfoChildren.get(id, [])
|
67
|
+
|
68
|
+
|
69
|
+
def get_section_code_info_children(p, section_id):
|
70
|
+
codeInfoColId = get_selected_section_variant(p, section_id)["codeInfoColId"]
|
71
|
+
if not codeInfoColId:
|
72
|
+
codeInfoCol = new_code_info_col()
|
73
|
+
else:
|
74
|
+
codeInfoCol = p["codeInfoCols"][codeInfoColId]
|
75
|
+
return codeInfoCol["children"]
|
76
|
+
|
77
|
+
|
78
|
+
def get_top_level_param_ids(p, id):
|
79
|
+
selected_item_id = get_selected_item_id(p, id)
|
80
|
+
children = get_code_info_children(p, id, selected_item_id)
|
81
|
+
return [c for c in children if p["codeInfo"][c]["rcType"] == C.PARAMETER]
|
82
|
+
|
83
|
+
|
84
|
+
def get_param_ui_type(p, section_id, id):
|
85
|
+
ui_type_col_id = p["sections"][section_id]["uiTypeColId"]
|
86
|
+
ui_type_col = p["uiTypeCols"][ui_type_col_id] if ui_type_col_id else {}
|
87
|
+
ui_type_col_entry = ui_type_col.get(id, new_ui_type_col_entry())
|
88
|
+
ui_type_id = ui_type_col_entry["uiTypeId"]
|
89
|
+
ui_type = p["uiTypes"].get(ui_type_id) or BASE_UI_TYPES[ui_type_id]
|
90
|
+
return ui_type["type"]
|
91
|
+
|
92
|
+
|
93
|
+
def get_selected_section_variant(p, section_id):
|
94
|
+
variantId = get_selected_section_variant_id(p, section_id)
|
95
|
+
return p["sectionVariants"][variantId]
|
96
|
+
|
97
|
+
|
98
|
+
def get_section_variant_ids(p, section_id):
|
99
|
+
return p["sections"][section_id]["variantIds"]
|
100
|
+
|
101
|
+
|
102
|
+
def get_section_variants(p, section_id):
|
103
|
+
variantIds = get_section_variant_ids(p, section_id)
|
104
|
+
return [p["sectionVariants"][v] for v in variantIds]
|
105
|
+
|
106
|
+
|
107
|
+
def get_selected_section_variant_id(p, section_id):
|
108
|
+
return p["sections"][section_id]["variantId"]
|
109
|
+
|
110
|
+
|
111
|
+
def get_section_variant_attr(p, variantId, attr):
|
112
|
+
return p["sectionVariants"][variantId][attr]
|
113
|
+
|
114
|
+
|
115
|
+
def get_variant_code(p, variantId):
|
116
|
+
return get_section_variant_attr(p, variantId, "code")
|
117
|
+
|
118
|
+
|
119
|
+
def get_variant_name(p, variantId):
|
120
|
+
return get_section_variant_attr(p, variantId, "name")
|
121
|
+
|
122
|
+
|
123
|
+
def get_section_code(p, id):
|
124
|
+
return get_selected_section_variant(p, id)["code"]
|
125
|
+
|
126
|
+
|
127
|
+
def get_section_children(p, id):
|
128
|
+
return get_selected_section_variant(p, id)["children"]
|
129
|
+
|
130
|
+
|
131
|
+
def get_specific_template_var(template_vars, keyword, return_index=False):
|
132
|
+
for i, t in enumerate(template_vars):
|
133
|
+
if t["keyword"] == keyword:
|
134
|
+
return (t, i) if return_index else t
|
135
|
+
return (None, -1) if return_index else None
|
136
|
+
|
137
|
+
|
138
|
+
def get_gen_code_template_var(template_vars):
|
139
|
+
return get_specific_template_var(template_vars, tp(C.SETTA_GENERATED_PYTHON))
|
140
|
+
|
141
|
+
|
142
|
+
def no_entered_value(value):
|
143
|
+
return value is None or value == ""
|
144
|
+
|
145
|
+
|
146
|
+
def get_var_name(var_name_mapping):
|
147
|
+
return f"__x{len(var_name_mapping)}"
|
148
|
+
|
149
|
+
|
150
|
+
def get_for_section_id(p, section_id):
|
151
|
+
for sid, s in p["sections"].items():
|
152
|
+
if s["paramSweepSectionId"] == section_id:
|
153
|
+
return sid
|
154
|
+
return None
|
155
|
+
|
156
|
+
|
157
|
+
def get_param_full_path_name(id, pathMap, codeInfo):
|
158
|
+
if len(pathMap[id]) == 1:
|
159
|
+
return codeInfo[pathMap[id][0]]["name"]
|
160
|
+
else:
|
161
|
+
name = ""
|
162
|
+
for pathIdx, currId in enumerate(pathMap[id]):
|
163
|
+
if pathIdx == 0:
|
164
|
+
name = codeInfo[currId]["name"]
|
165
|
+
else:
|
166
|
+
name += f'["{codeInfo[currId]["name"]}"]'
|
167
|
+
return name
|
168
|
+
|
169
|
+
|
170
|
+
def export_selected(p, always_export_args_objs, force_include_template_var):
|
171
|
+
p["codeInfoCols"] = replace_null_keys_with_none(p["codeInfoCols"])
|
172
|
+
e = Exporter(
|
173
|
+
p,
|
174
|
+
always_export_args_objs=always_export_args_objs,
|
175
|
+
force_include_template_var=force_include_template_var,
|
176
|
+
)
|
177
|
+
e.export()
|
178
|
+
return e
|
179
|
+
|
180
|
+
|
181
|
+
def export_for_in_memory_fn(p):
|
182
|
+
p["codeInfoCols"] = replace_null_keys_with_none(p["codeInfoCols"])
|
183
|
+
e = ExporterForInMemoryFn(p)
|
184
|
+
e.export()
|
185
|
+
return e
|
186
|
+
|
187
|
+
|
188
|
+
def export_section_to_dict(
|
189
|
+
codeInfo,
|
190
|
+
codeInfoChildren,
|
191
|
+
sectionVariant,
|
192
|
+
pinnedUnpinnedDict,
|
193
|
+
):
|
194
|
+
codeInfoChildren = replace_null_keys_with_none(codeInfoChildren)
|
195
|
+
output = {}
|
196
|
+
for k, v in pinnedUnpinnedDict.items():
|
197
|
+
e = SectionToDict(
|
198
|
+
codeInfo,
|
199
|
+
codeInfoChildren,
|
200
|
+
sectionVariant,
|
201
|
+
v["topLevelParamIds"],
|
202
|
+
v.get("requiredParamIds", None),
|
203
|
+
)
|
204
|
+
e.export()
|
205
|
+
output[k] = e
|
206
|
+
|
207
|
+
return output
|
208
|
+
|
209
|
+
|
210
|
+
def export_param_sweep_section_to_dict(sweep, codeInfo, codeInfoChildren):
|
211
|
+
codeInfoChildren = replace_null_keys_with_none(codeInfoChildren)
|
212
|
+
e = ParamSweepSectionToDict(sweep, codeInfo, codeInfoChildren)
|
213
|
+
e.export()
|
214
|
+
return e
|
215
|
+
|
216
|
+
|
217
|
+
def export_single_run_group_to_dict(runGroup, sections, sectionVariants):
|
218
|
+
runGroup = replace_null_keys_with_none(runGroup)
|
219
|
+
e = SingleRunGroupToDict(runGroup, sections, sectionVariants)
|
220
|
+
e.export()
|
221
|
+
return e
|
222
|
+
|
223
|
+
|
224
|
+
def remove_unneeded_sections(p, keep_section_types):
|
225
|
+
to_pop = []
|
226
|
+
for id in p["sections"].keys():
|
227
|
+
section_type = get_section_type(p, id)
|
228
|
+
if section_type not in keep_section_types:
|
229
|
+
to_pop.append(id)
|
230
|
+
for id in to_pop:
|
231
|
+
parentId = p["sections"][id]["parentId"]
|
232
|
+
if parentId:
|
233
|
+
parentVariant = get_selected_section_variant(p, parentId)
|
234
|
+
parentVariant["children"] = [
|
235
|
+
c for c in parentVariant["children"] if c != id
|
236
|
+
]
|
237
|
+
p["sections"].pop(id, None)
|
238
|
+
p["projectConfig"]["children"].pop(id, None)
|
239
|
+
|
240
|
+
|
241
|
+
class Exporter:
|
242
|
+
def __init__(self, p, always_export_args_objs, force_include_template_var):
|
243
|
+
self.output = {}
|
244
|
+
self.p = copy.deepcopy(p)
|
245
|
+
self.var_name_mapping = {}
|
246
|
+
self.var_name_reverse_mapping = {}
|
247
|
+
self.always_export_args_objs = always_export_args_objs
|
248
|
+
self.force_include_template_var = force_include_template_var
|
249
|
+
self.code_gen_template_var_section_details = {
|
250
|
+
"section": {},
|
251
|
+
"sectionVariant": {},
|
252
|
+
}
|
253
|
+
if force_include_template_var:
|
254
|
+
section_details = {
|
255
|
+
"id": None,
|
256
|
+
"name": C.DEFAULT_PYTHON_SCRIPT_NAME,
|
257
|
+
"codeLanguage": "python",
|
258
|
+
}
|
259
|
+
_, section_variant = new_section_variant(
|
260
|
+
code=tp(C.SETTA_GENERATED_PYTHON),
|
261
|
+
templateVars=[
|
262
|
+
{
|
263
|
+
"startPos": 0,
|
264
|
+
"keyword": tp(C.SETTA_GENERATED_PYTHON),
|
265
|
+
"sectionId": None,
|
266
|
+
}
|
267
|
+
],
|
268
|
+
)
|
269
|
+
self.code_gen_template_var_section_details = {
|
270
|
+
"section": section_details,
|
271
|
+
"sectionVariant": section_variant,
|
272
|
+
}
|
273
|
+
|
274
|
+
def export(self):
|
275
|
+
remove_unneeded_sections(
|
276
|
+
self.p,
|
277
|
+
[
|
278
|
+
C.SECTION,
|
279
|
+
C.LIST_ROOT,
|
280
|
+
C.DICT_ROOT,
|
281
|
+
C.GROUP,
|
282
|
+
C.CODE,
|
283
|
+
C.GLOBAL_VARIABLES,
|
284
|
+
],
|
285
|
+
)
|
286
|
+
self.export_sections(list(self.p["projectConfig"]["children"].keys()))
|
287
|
+
|
288
|
+
def export_sections(self, ids):
|
289
|
+
return [self.export_section(x) for x in ids]
|
290
|
+
|
291
|
+
def export_section(self, id):
|
292
|
+
var_name = self.maybe_create_var_name(
|
293
|
+
id,
|
294
|
+
None,
|
295
|
+
)
|
296
|
+
if var_name not in self.output:
|
297
|
+
type = get_section_type(self.p, id)
|
298
|
+
info = {
|
299
|
+
"sectionId": id,
|
300
|
+
"name": get_section_name(self.p, id),
|
301
|
+
"type": type,
|
302
|
+
}
|
303
|
+
if type == C.SECTION:
|
304
|
+
if self.always_export_args_objs:
|
305
|
+
self.export_args_obj(id)
|
306
|
+
(
|
307
|
+
used_params,
|
308
|
+
unused_params,
|
309
|
+
positionalOnlyParams,
|
310
|
+
) = self.export_section_params(id)
|
311
|
+
|
312
|
+
selected_item_ev_refs = get_selected_item_ev_refs(self.p, id)
|
313
|
+
if selected_item_ev_refs:
|
314
|
+
callable, ref_template_var_positions = process_refs(
|
315
|
+
get_selected_item_name(self.p, id),
|
316
|
+
selected_item_ev_refs,
|
317
|
+
self.maybe_create_ref_var_name,
|
318
|
+
)
|
319
|
+
ref_var_name_positions = ref_template_var_positions["refs"]
|
320
|
+
used_ref_var_names = [x["value"] for x in ref_var_name_positions]
|
321
|
+
else:
|
322
|
+
callable = get_selected_item_name(self.p, id)
|
323
|
+
used_ref_var_names = []
|
324
|
+
ref_var_name_positions = []
|
325
|
+
|
326
|
+
info["value"] = {
|
327
|
+
"callable": callable,
|
328
|
+
"usedParams": used_params,
|
329
|
+
"unusedParams": unused_params,
|
330
|
+
"positionalOnlyParams": positionalOnlyParams,
|
331
|
+
}
|
332
|
+
info["dependencies"] = [*used_params, *used_ref_var_names]
|
333
|
+
info["ref_var_name_positions"] = ref_var_name_positions
|
334
|
+
self.output[var_name] = info
|
335
|
+
elif type in [C.LIST_ROOT, C.DICT_ROOT, C.GROUP]:
|
336
|
+
children = get_section_children(self.p, id)
|
337
|
+
children = [
|
338
|
+
c
|
339
|
+
for c in children
|
340
|
+
if get_section_type(self.p, c)
|
341
|
+
in [C.SECTION, C.LIST_ROOT, C.DICT_ROOT, C.GROUP]
|
342
|
+
]
|
343
|
+
info["value"] = self.export_sections(children)
|
344
|
+
info["dependencies"] = info["value"]
|
345
|
+
info[
|
346
|
+
"ref_var_name_positions"
|
347
|
+
] = [] # has to be populated when the code is generated
|
348
|
+
self.output[var_name] = info
|
349
|
+
elif type == C.CODE:
|
350
|
+
variant = get_selected_section_variant(self.p, id)
|
351
|
+
gen_code_template_var = get_gen_code_template_var(
|
352
|
+
variant["templateVars"]
|
353
|
+
)
|
354
|
+
if gen_code_template_var:
|
355
|
+
self.code_gen_template_var_section_details = {
|
356
|
+
"section": self.p["sections"][id],
|
357
|
+
"sectionVariant": variant,
|
358
|
+
}
|
359
|
+
# Make sure any necessary variables get created.
|
360
|
+
# We don't do any replacements here, because that's done later
|
361
|
+
# when the code is actually run.
|
362
|
+
process_refs(
|
363
|
+
get_section_code(self.p, id),
|
364
|
+
variant["evRefs"],
|
365
|
+
self.maybe_create_ref_var_name,
|
366
|
+
)
|
367
|
+
elif type == C.GLOBAL_VARIABLES:
|
368
|
+
# don't need to process the output since the global variables get added directly to the output
|
369
|
+
# i.e. they aren't children of anything
|
370
|
+
self.export_section_params(id)
|
371
|
+
else:
|
372
|
+
raise ValueError
|
373
|
+
return var_name
|
374
|
+
|
375
|
+
def export_args_obj(self, id):
|
376
|
+
var_name = self.maybe_create_var_name(
|
377
|
+
id,
|
378
|
+
None,
|
379
|
+
is_args_obj=True,
|
380
|
+
)
|
381
|
+
if var_name not in self.output:
|
382
|
+
(
|
383
|
+
used_params,
|
384
|
+
unused_params,
|
385
|
+
positionalOnlyParams,
|
386
|
+
) = self.export_section_params(id)
|
387
|
+
info = {
|
388
|
+
"sectionId": id,
|
389
|
+
"name": get_section_name(self.p, id),
|
390
|
+
"type": C.SECTION,
|
391
|
+
"value": {
|
392
|
+
"callable": None,
|
393
|
+
"usedParams": used_params,
|
394
|
+
"unusedParams": unused_params,
|
395
|
+
"positionalOnlyParams": positionalOnlyParams,
|
396
|
+
},
|
397
|
+
"dependencies": used_params,
|
398
|
+
"ref_var_name_positions": [], # has to be populated when the code is generated
|
399
|
+
}
|
400
|
+
self.output[var_name] = info
|
401
|
+
return var_name
|
402
|
+
|
403
|
+
def export_section_params(self, section_id):
|
404
|
+
ids = get_top_level_param_ids(self.p, section_id)
|
405
|
+
return self.export_params(section_id, ids)
|
406
|
+
|
407
|
+
def export_params(self, section_id, ids):
|
408
|
+
var_names = [self.export_param(section_id, x) for x in ids]
|
409
|
+
var_names = [x for x in var_names if x]
|
410
|
+
used_params = []
|
411
|
+
unused_params = []
|
412
|
+
positionalOnlyParams = set()
|
413
|
+
for v in var_names:
|
414
|
+
if no_entered_value(self.output[v]["value"]):
|
415
|
+
unused_params.append(v)
|
416
|
+
else:
|
417
|
+
used_params.append(v)
|
418
|
+
|
419
|
+
curr_param_info_id = self.output[v]["paramInfoId"]
|
420
|
+
positionalOnly = self.p["codeInfo"][curr_param_info_id].get(
|
421
|
+
"positionalOnly", False
|
422
|
+
)
|
423
|
+
if positionalOnly:
|
424
|
+
positionalOnlyParams.add(v)
|
425
|
+
return used_params, unused_params, positionalOnlyParams
|
426
|
+
|
427
|
+
def export_param(self, section_id, id):
|
428
|
+
codeInfo = self.p["codeInfo"][id]
|
429
|
+
param_name = codeInfo["name"]
|
430
|
+
if not param_name:
|
431
|
+
return None
|
432
|
+
var_name = self.maybe_create_var_name(
|
433
|
+
section_id,
|
434
|
+
id,
|
435
|
+
)
|
436
|
+
|
437
|
+
if var_name not in self.output:
|
438
|
+
param_children = get_code_info_children(self.p, section_id, id)
|
439
|
+
if len(param_children) > 0:
|
440
|
+
used_params, _, _ = self.export_params(section_id, param_children)
|
441
|
+
info = {
|
442
|
+
"sectionId": section_id,
|
443
|
+
"paramInfoId": id,
|
444
|
+
"name": param_name,
|
445
|
+
"type": C.NESTED_PARAM,
|
446
|
+
"value": used_params,
|
447
|
+
"dependencies": used_params,
|
448
|
+
"ref_var_name_positions": [], # has to be populated when the code is generated
|
449
|
+
}
|
450
|
+
self.output[var_name] = info
|
451
|
+
else:
|
452
|
+
(
|
453
|
+
value,
|
454
|
+
used_ref_var_names,
|
455
|
+
ref_var_name_positions,
|
456
|
+
) = self.export_param_value(section_id, id)
|
457
|
+
self.output[var_name] = {
|
458
|
+
"sectionId": section_id,
|
459
|
+
"paramInfoId": id,
|
460
|
+
"name": param_name,
|
461
|
+
"type": get_param_ui_type(self.p, section_id, id),
|
462
|
+
"value": value,
|
463
|
+
"dependencies": used_ref_var_names,
|
464
|
+
"ref_var_name_positions": ref_var_name_positions,
|
465
|
+
}
|
466
|
+
|
467
|
+
return var_name
|
468
|
+
|
469
|
+
def export_param_value(self, section_id, id):
|
470
|
+
variant = get_selected_section_variant(self.p, section_id)
|
471
|
+
if id in variant["values"]:
|
472
|
+
value = variant["values"][id]["value"]
|
473
|
+
refs = variant["values"][id]["evRefs"]
|
474
|
+
value, ref_template_var_positions = process_refs(
|
475
|
+
value, refs, self.maybe_create_ref_var_name
|
476
|
+
)
|
477
|
+
ref_var_name_positions = ref_template_var_positions["refs"]
|
478
|
+
used_ref_var_names = [x["value"] for x in ref_var_name_positions]
|
479
|
+
else:
|
480
|
+
value = new_ev_entry()["value"]
|
481
|
+
used_ref_var_names = []
|
482
|
+
ref_var_name_positions = []
|
483
|
+
return value, used_ref_var_names, ref_var_name_positions
|
484
|
+
|
485
|
+
def maybe_create_ref_var_name(
|
486
|
+
self, ref_section_id, ref_param_info_id, ref_is_args_obj
|
487
|
+
):
|
488
|
+
if ref_is_args_obj:
|
489
|
+
return self.export_args_obj(ref_section_id)
|
490
|
+
elif ref_param_info_id:
|
491
|
+
return self.export_param(ref_section_id, ref_param_info_id)
|
492
|
+
elif ref_section_id:
|
493
|
+
return self.export_section(ref_section_id)
|
494
|
+
else:
|
495
|
+
raise ValueError
|
496
|
+
|
497
|
+
def get_ref_var_name(self, ref_section_id, ref_param_info_id, ref_is_args_obj):
|
498
|
+
return self.var_name_mapping[
|
499
|
+
(ref_section_id, ref_param_info_id, ref_is_args_obj)
|
500
|
+
]
|
501
|
+
|
502
|
+
def maybe_create_var_name(
|
503
|
+
self,
|
504
|
+
section_id,
|
505
|
+
param_info_id,
|
506
|
+
is_args_obj=False,
|
507
|
+
):
|
508
|
+
mapping_key = (section_id, param_info_id, is_args_obj)
|
509
|
+
var_name = self.var_name_mapping.get(mapping_key)
|
510
|
+
if not var_name:
|
511
|
+
var_name = get_var_name(self.var_name_mapping)
|
512
|
+
self.var_name_mapping[mapping_key] = var_name
|
513
|
+
self.var_name_reverse_mapping[var_name] = mapping_key
|
514
|
+
elif var_name not in self.output:
|
515
|
+
# this means the var_name has already been created
|
516
|
+
# but it hasn't been added to the output.
|
517
|
+
# This only happens in a circular dependency.
|
518
|
+
raise RecursionError("There is a circular reference")
|
519
|
+
return var_name
|
520
|
+
|
521
|
+
|
522
|
+
class ExporterForInMemoryFn:
|
523
|
+
def __init__(self, p):
|
524
|
+
self.output = {}
|
525
|
+
self.p = copy.deepcopy(p)
|
526
|
+
self.var_name_mapping = {}
|
527
|
+
self.var_name_reverse_mapping = QuoteInsensitiveDict()
|
528
|
+
|
529
|
+
def export(self):
|
530
|
+
remove_unneeded_sections(
|
531
|
+
self.p,
|
532
|
+
[
|
533
|
+
C.SECTION,
|
534
|
+
C.LIST_ROOT,
|
535
|
+
C.DICT_ROOT,
|
536
|
+
C.GROUP,
|
537
|
+
# C.IMAGE,
|
538
|
+
# C.CHART,
|
539
|
+
C.DRAW,
|
540
|
+
C.GLOBAL_VARIABLES,
|
541
|
+
],
|
542
|
+
)
|
543
|
+
for id in list(self.p["projectConfig"]["children"].keys()):
|
544
|
+
name = get_section_name(self.p, id)
|
545
|
+
value, value_is_returned = self.export_section(id, name)
|
546
|
+
if value_is_returned:
|
547
|
+
self.output[name] = value
|
548
|
+
|
549
|
+
def export_section(self, id, name):
|
550
|
+
type = get_section_type(self.p, id)
|
551
|
+
self.create_var_mapping((id,), name)
|
552
|
+
value = None
|
553
|
+
value_is_returned = True
|
554
|
+
if type == C.SECTION:
|
555
|
+
selectedItem = get_selected_item_name(self.p, id)
|
556
|
+
params = self.export_section_params(
|
557
|
+
id, f'{name}["params"]', is_global=False
|
558
|
+
)
|
559
|
+
value = {"selectedItem": selectedItem, "params": params}
|
560
|
+
self.create_var_mapping((id, "selectedItem"), f'{name}["selectedItem"]')
|
561
|
+
elif type in [C.LIST_ROOT, C.DICT_ROOT, C.GROUP]:
|
562
|
+
children = get_section_children(self.p, id)
|
563
|
+
if type == C.LIST_ROOT:
|
564
|
+
value = [
|
565
|
+
self.export_section(c, f"{name}[{idx}]")
|
566
|
+
for idx, c in enumerate(children)
|
567
|
+
]
|
568
|
+
elif type in [C.DICT_ROOT, C.GROUP]:
|
569
|
+
value = {}
|
570
|
+
for c in children:
|
571
|
+
child_name = get_section_name(self.p, c)
|
572
|
+
value[child_name] = self.export_section(
|
573
|
+
c, f'{name}["{child_name}"]'
|
574
|
+
)
|
575
|
+
# elif type in [C.IMAGE, C.CHART]:
|
576
|
+
# value = get_artifacts(self.p, id)
|
577
|
+
# self.create_var_mapping((id, "artifact"), name)
|
578
|
+
elif type == C.DRAW:
|
579
|
+
value = {"drawing": get_drawing(self.p, id)}
|
580
|
+
self.create_var_mapping((id, "drawing"), f'{name}["drawing"]')
|
581
|
+
elif type == C.GLOBAL_VARIABLES:
|
582
|
+
self.output.update(self.export_section_params(id, "", is_global=True))
|
583
|
+
value_is_returned = False
|
584
|
+
else:
|
585
|
+
raise ValueError
|
586
|
+
return value, value_is_returned
|
587
|
+
|
588
|
+
def export_section_params(self, section_id, name, is_global):
|
589
|
+
return self.export_params(
|
590
|
+
section_id, get_top_level_param_ids(self.p, section_id), name, is_global
|
591
|
+
)
|
592
|
+
|
593
|
+
def export_params(self, section_id, ids, name, is_global):
|
594
|
+
params = {}
|
595
|
+
for param_id in ids:
|
596
|
+
codeInfo = self.p["codeInfo"][param_id]
|
597
|
+
param_name = codeInfo["name"]
|
598
|
+
if not param_name:
|
599
|
+
continue
|
600
|
+
param_children = get_code_info_children(self.p, section_id, param_id)
|
601
|
+
if len(param_children) > 0:
|
602
|
+
value = self.export_params(section_id, param_children, name, is_global)
|
603
|
+
else:
|
604
|
+
value = self.export_param_value(section_id, param_id)
|
605
|
+
param_name = codeInfo["name"]
|
606
|
+
params[param_name] = value
|
607
|
+
if is_global:
|
608
|
+
self.create_var_mapping((section_id, param_id), param_name)
|
609
|
+
else:
|
610
|
+
self.create_var_mapping(
|
611
|
+
(section_id, param_id), f'{name}["{param_name}"]'
|
612
|
+
)
|
613
|
+
return params
|
614
|
+
|
615
|
+
def export_param_value(self, section_id, id):
|
616
|
+
values = get_selected_section_variant(self.p, section_id)["values"]
|
617
|
+
if id in values:
|
618
|
+
return values[id]["value"]
|
619
|
+
return ""
|
620
|
+
|
621
|
+
def create_var_mapping(self, key, value):
|
622
|
+
self.var_name_mapping[key] = value
|
623
|
+
self.var_name_reverse_mapping[value] = key
|
624
|
+
|
625
|
+
|
626
|
+
class SectionToDict:
|
627
|
+
def __init__(
|
628
|
+
self,
|
629
|
+
codeInfo,
|
630
|
+
codeInfoChildren,
|
631
|
+
sectionVariant,
|
632
|
+
topLevelParamIds,
|
633
|
+
requiredParamIds,
|
634
|
+
):
|
635
|
+
self.output = {}
|
636
|
+
self.prettyOutput = {}
|
637
|
+
self.codeInfo = codeInfo
|
638
|
+
self.codeInfoChildren = codeInfoChildren
|
639
|
+
self.sectionVariant = sectionVariant
|
640
|
+
self.topLevelParamIds = topLevelParamIds
|
641
|
+
self.requiredParamIds = set(requiredParamIds) if requiredParamIds else None
|
642
|
+
|
643
|
+
def export(self):
|
644
|
+
self.output, self.prettyOutput = self.export_params(self.topLevelParamIds)
|
645
|
+
|
646
|
+
def export_params(self, ids):
|
647
|
+
params = {}
|
648
|
+
prettyParams = {}
|
649
|
+
for param_id in ids:
|
650
|
+
if (
|
651
|
+
self.requiredParamIds is not None
|
652
|
+
and param_id not in self.requiredParamIds
|
653
|
+
):
|
654
|
+
continue
|
655
|
+
codeInfo = self.codeInfo[param_id]
|
656
|
+
param_name = codeInfo["name"]
|
657
|
+
if not param_name:
|
658
|
+
continue
|
659
|
+
param_children = self.codeInfoChildren[param_id]
|
660
|
+
if len(param_children) > 0:
|
661
|
+
value, prettyValue = self.export_params(param_children)
|
662
|
+
else:
|
663
|
+
value, prettyValue = self.export_param_value(param_id)
|
664
|
+
params[codeInfo["name"]] = {
|
665
|
+
"id": param_id,
|
666
|
+
"value": value,
|
667
|
+
"editable": codeInfo["editable"],
|
668
|
+
}
|
669
|
+
prettyParams[codeInfo["name"]] = prettyValue
|
670
|
+
return params, prettyParams
|
671
|
+
|
672
|
+
def export_param_value(self, id):
|
673
|
+
values = self.sectionVariant["values"]
|
674
|
+
if id in values:
|
675
|
+
value = values[id]["value"]
|
676
|
+
else:
|
677
|
+
value = new_ev_entry()["value"]
|
678
|
+
return value, value
|
679
|
+
|
680
|
+
|
681
|
+
class ParamSweepSectionToDict:
|
682
|
+
def __init__(
|
683
|
+
self,
|
684
|
+
sweep,
|
685
|
+
codeInfo,
|
686
|
+
codeInfoChildren,
|
687
|
+
):
|
688
|
+
self.prettyOutput = []
|
689
|
+
self.sweep = sweep
|
690
|
+
self.codeInfo = codeInfo
|
691
|
+
self.codeInfoChildren = codeInfoChildren
|
692
|
+
|
693
|
+
def export(self):
|
694
|
+
for selectedItemSweep in self.sweep:
|
695
|
+
self.export_selected_item_sweep(selectedItemSweep)
|
696
|
+
|
697
|
+
def export_selected_item_sweep(self, selectedItemSweep):
|
698
|
+
selectedItem = selectedItemSweep["selectedItem"]
|
699
|
+
params = selectedItemSweep["params"]
|
700
|
+
if selectedItem:
|
701
|
+
selectedItemName = self.codeInfo[selectedItem]["name"]
|
702
|
+
currObj = {selectedItemName: []}
|
703
|
+
curr = currObj[selectedItemName]
|
704
|
+
else:
|
705
|
+
curr = currObj = []
|
706
|
+
result = findAllParametersAndPathMaps(
|
707
|
+
allCodeInfo=self.codeInfo,
|
708
|
+
codeInfoChildren=self.codeInfoChildren,
|
709
|
+
startingId=selectedItem,
|
710
|
+
)
|
711
|
+
pathMap = result["pathMap"]
|
712
|
+
for p in params:
|
713
|
+
if p["paramInfoId"]:
|
714
|
+
paramFullPathName = get_param_full_path_name(
|
715
|
+
p["paramInfoId"], pathMap, self.codeInfo
|
716
|
+
)
|
717
|
+
else:
|
718
|
+
paramFullPathName = None
|
719
|
+
curr.append({paramFullPathName: p["values"]})
|
720
|
+
self.prettyOutput.append(currObj)
|
721
|
+
|
722
|
+
|
723
|
+
class SingleRunGroupToDict:
|
724
|
+
def __init__(
|
725
|
+
self,
|
726
|
+
runGroup,
|
727
|
+
sections,
|
728
|
+
sectionVariants,
|
729
|
+
):
|
730
|
+
self.prettyOutput = {}
|
731
|
+
self.runGroup = runGroup
|
732
|
+
self.sections = sections
|
733
|
+
self.sectionVariants = sectionVariants
|
734
|
+
|
735
|
+
def export(self):
|
736
|
+
if not self.runGroup:
|
737
|
+
return
|
738
|
+
for s in self.sections.values():
|
739
|
+
if not s["parentId"]:
|
740
|
+
result = self.export_section_details(s["id"], None)
|
741
|
+
if result:
|
742
|
+
self.prettyOutput.update(result)
|
743
|
+
|
744
|
+
def export_section_details(self, sectionId, parentVariantId):
|
745
|
+
details = self.runGroup.get(sectionId, {}).get(parentVariantId, None)
|
746
|
+
if not details or not details["selected"]:
|
747
|
+
return {}
|
748
|
+
section_info = self.sections[sectionId]
|
749
|
+
section_name = section_info["name"]
|
750
|
+
output = {section_name: {}}
|
751
|
+
|
752
|
+
for variantId, selected in details["versions"].items():
|
753
|
+
if not selected:
|
754
|
+
continue
|
755
|
+
variant = self.sectionVariants[variantId]
|
756
|
+
variant_name = f'@{variant["name"]}'
|
757
|
+
children = variant["children"]
|
758
|
+
child_dict = {}
|
759
|
+
for c in children:
|
760
|
+
child_result = self.export_section_details(c, variantId)
|
761
|
+
if child_result:
|
762
|
+
child_dict.update(child_result)
|
763
|
+
output[section_name][variant_name] = child_dict
|
764
|
+
|
765
|
+
if len(section_info["variantIds"]) == 1:
|
766
|
+
output[section_name] = output[section_name][variant_name]
|
767
|
+
|
768
|
+
for paramSweepSectionVariantId, selected in details["paramSweeps"].items():
|
769
|
+
if not selected:
|
770
|
+
continue
|
771
|
+
param_sweep_name = (
|
772
|
+
f'~{self.sectionVariants[paramSweepSectionVariantId]["name"]}'
|
773
|
+
)
|
774
|
+
output[section_name][param_sweep_name] = {}
|
775
|
+
|
776
|
+
return output
|