setta 0.0.6.dev0__py3-none-any.whl → 0.0.8.dev0__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.
- setta/__init__.py +1 -1
- setta/code_gen/export_selected.py +30 -4
- setta/code_gen/python/generate_code.py +10 -5
- setta/database/db/projects/load.py +7 -6
- setta/database/db/projects/save.py +3 -2
- setta/database/db/projects/utils.py +4 -1
- setta/database/db/sections/load.py +3 -0
- setta/database/export_db/export_db.py +2 -2
- setta/database/export_db/export_readable.py +3 -3
- setta/database/export_db/utils.py +1 -1
- setta/database/seed.py +1 -1
- setta/database/settings_file.py +2 -6
- setta/routers/projects.py +1 -1
- setta/start.py +13 -2
- setta/static/constants/BaseUITypes.json +8 -1
- setta/static/constants/Settings.json +5 -3
- setta/static/constants/constants.json +4 -2
- setta/static/constants/defaultValues.json +2 -1
- setta/static/frontend/assets/index-3a6274db.css +32 -0
- setta/static/frontend/assets/{index-105d4b9e.js → index-c90491bb.js} +177 -176
- setta/static/frontend/index.html +2 -2
- setta/utils/constants.py +1 -0
- {setta-0.0.6.dev0.dist-info → setta-0.0.8.dev0.dist-info}/METADATA +23 -9
- {setta-0.0.6.dev0.dist-info → setta-0.0.8.dev0.dist-info}/RECORD +28 -28
- setta/static/frontend/assets/index-a5bd0f52.css +0 -32
- {setta-0.0.6.dev0.dist-info → setta-0.0.8.dev0.dist-info}/LICENSE +0 -0
- {setta-0.0.6.dev0.dist-info → setta-0.0.8.dev0.dist-info}/WHEEL +0 -0
- {setta-0.0.6.dev0.dist-info → setta-0.0.8.dev0.dist-info}/entry_points.txt +0 -0
- {setta-0.0.6.dev0.dist-info → setta-0.0.8.dev0.dist-info}/top_level.txt +0 -0
setta/__init__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "0.0.
|
1
|
+
__version__ = "0.0.8.dev0"
|
@@ -18,13 +18,22 @@ def get_section_type(p, id):
|
|
18
18
|
|
19
19
|
|
20
20
|
def get_artifacts(p, id):
|
21
|
-
|
21
|
+
artifactGroupIds = p["sections"][id]["artifactGroupIds"]
|
22
|
+
artifacts = []
|
23
|
+
for groupId in artifactGroupIds:
|
24
|
+
for transform in p["artifactGroups"][groupId]["artifactTransforms"]:
|
25
|
+
artifacts.append(p["artifacts"][transform["artifactId"]])
|
26
|
+
return artifacts
|
22
27
|
|
23
28
|
|
24
29
|
def get_drawing(p, id):
|
25
30
|
return p["sections"][id]["drawing"]
|
26
31
|
|
27
32
|
|
33
|
+
def get_chat_message(p, id):
|
34
|
+
return p["sections"][id]["latestChatMessage"]
|
35
|
+
|
36
|
+
|
28
37
|
def get_section_name(p, id):
|
29
38
|
return p["sections"][id]["name"]
|
30
39
|
|
@@ -266,19 +275,20 @@ class Exporter:
|
|
266
275
|
"section": section_details,
|
267
276
|
"sectionVariant": section_variant,
|
268
277
|
}
|
269
|
-
self.
|
278
|
+
self.section_types_to_process = [
|
270
279
|
C.SECTION,
|
271
280
|
C.LIST_ROOT,
|
272
281
|
C.DICT_ROOT,
|
273
282
|
C.GROUP,
|
274
283
|
C.CODE,
|
275
284
|
C.GLOBAL_VARIABLES,
|
285
|
+
C.TEXT_BLOCK,
|
276
286
|
]
|
277
287
|
|
278
288
|
def export(self):
|
279
289
|
remove_unneeded_sections(
|
280
290
|
self.p,
|
281
|
-
self.
|
291
|
+
self.section_types_to_process,
|
282
292
|
)
|
283
293
|
self.export_sections(list(self.p["projectConfig"]["children"].keys()))
|
284
294
|
|
@@ -334,7 +344,7 @@ class Exporter:
|
|
334
344
|
children = [
|
335
345
|
c
|
336
346
|
for c in children
|
337
|
-
if get_section_type(self.p, c) in self.
|
347
|
+
if get_section_type(self.p, c) in self.section_types_to_process
|
338
348
|
]
|
339
349
|
# some sections (like CODE) don't get added to self.output
|
340
350
|
info["value"] = [
|
@@ -367,6 +377,12 @@ class Exporter:
|
|
367
377
|
# don't need to process the output since the global variables get added directly to the output
|
368
378
|
# i.e. they aren't children of anything
|
369
379
|
self.export_section_params(id)
|
380
|
+
elif type == C.TEXT_BLOCK:
|
381
|
+
variant = get_selected_section_variant(self.p, id)
|
382
|
+
info["value"] = variant["description"]
|
383
|
+
info["dependencies"] = []
|
384
|
+
info["ref_var_name_positions"] = []
|
385
|
+
self.output[var_name] = info
|
370
386
|
else:
|
371
387
|
raise ValueError
|
372
388
|
return var_name
|
@@ -536,6 +552,7 @@ class ExporterForInMemoryFn:
|
|
536
552
|
# C.IMAGE,
|
537
553
|
# C.CHART,
|
538
554
|
C.DRAW,
|
555
|
+
C.CHAT,
|
539
556
|
C.GLOBAL_VARIABLES,
|
540
557
|
],
|
541
558
|
)
|
@@ -577,6 +594,15 @@ class ExporterForInMemoryFn:
|
|
577
594
|
elif type == C.DRAW:
|
578
595
|
value = {"drawing": get_drawing(self.p, id)}
|
579
596
|
self.create_var_mapping((id, "drawing"), f'{name}["drawing"]')
|
597
|
+
elif type == C.CHAT:
|
598
|
+
latestChatMessage = get_chat_message(self.p, id)
|
599
|
+
artifacts = get_artifacts(self.p, id)
|
600
|
+
chatHistory = artifacts[0]["value"] if len(artifacts) > 0 else None
|
601
|
+
value = {"latestChatMessage": latestChatMessage, "chatHistory": chatHistory}
|
602
|
+
self.create_var_mapping(
|
603
|
+
(id, "latestChatMessage"), f'{name}["latestChatMessage"]'
|
604
|
+
)
|
605
|
+
self.create_var_mapping((id, "chatHistory"), f'{name}["chatHistory"]')
|
580
606
|
elif type == C.GLOBAL_VARIABLES:
|
581
607
|
self.output.update(self.export_section_params(id, "", is_global=True))
|
582
608
|
value_is_returned = False
|
@@ -70,18 +70,23 @@ def var_declaration(
|
|
70
70
|
# TODO: remove str(x["value"]). I don't think it's necessary since x["value"] should always be a string already.
|
71
71
|
def get_value(x, selected):
|
72
72
|
type_value = x["type"]
|
73
|
-
if
|
74
|
-
|
75
|
-
|
76
|
-
|
73
|
+
if (
|
74
|
+
type_value == C.TEXT
|
75
|
+
or type_value == C.SLIDER
|
76
|
+
or type_value == C.DROPDOWN
|
77
|
+
or type_value == C.PASSWORD
|
78
|
+
):
|
77
79
|
output = str(x["value"])
|
78
80
|
relative_positions = []
|
79
81
|
elif type_value == C.SWITCH:
|
80
82
|
output = str(get_boolean(x["value"]))
|
81
83
|
relative_positions = []
|
82
|
-
elif type_value == C.COLOR_PICKER
|
84
|
+
elif type_value == C.COLOR_PICKER:
|
83
85
|
output = f'"{x["value"]}"'
|
84
86
|
relative_positions = []
|
87
|
+
elif type_value == C.TEXT_BLOCK:
|
88
|
+
output = f'"""{x["value"]}"""'
|
89
|
+
relative_positions = []
|
85
90
|
elif type_value == C.SECTION:
|
86
91
|
if not x["value"]["callable"]:
|
87
92
|
output, relative_positions = get_dict_contents(
|
@@ -113,7 +113,7 @@ def load_project_config_metadata(db, config_name):
|
|
113
113
|
return list(output.values())[0]
|
114
114
|
|
115
115
|
|
116
|
-
def load_project_config(db, project_config_name):
|
116
|
+
def load_project_config(db, project_config_name, do_load_json_sources=True):
|
117
117
|
projectConfig = load_project_config_metadata(db, project_config_name)
|
118
118
|
sections_data = load_sections(db, list(projectConfig["children"].keys()))
|
119
119
|
sectionConfigs = load_section_configs(db, projectConfig["id"])
|
@@ -127,9 +127,10 @@ def load_project_config(db, project_config_name):
|
|
127
127
|
codeInfo, codeInfoCols = load_code_info_cols(db, sectionVariants)
|
128
128
|
load_ev_refs_into_data_structures(db, sectionVariants, codeInfo)
|
129
129
|
load_template_vars_into_data_structures(db, sectionVariants)
|
130
|
-
|
131
|
-
|
132
|
-
|
130
|
+
if do_load_json_sources:
|
131
|
+
load_json_sources_into_data_structures(
|
132
|
+
sections, codeInfo, codeInfoCols, sectionVariants
|
133
|
+
)
|
133
134
|
|
134
135
|
return {
|
135
136
|
"projectConfig": projectConfig,
|
@@ -159,11 +160,11 @@ def load_project_config_names(db, excludeProjectConfigName=None):
|
|
159
160
|
return [r[0] for r in db.fetchall()]
|
160
161
|
|
161
162
|
|
162
|
-
def load_full_project(db, excludeProjectConfigName=None):
|
163
|
+
def load_full_project(db, excludeProjectConfigName=None, do_load_json_sources=True):
|
163
164
|
config_names = load_project_config_names(db, excludeProjectConfigName)
|
164
165
|
configs = []
|
165
166
|
for c in config_names:
|
166
|
-
p = load_project_config(db, c)
|
167
|
+
p = load_project_config(db, c, do_load_json_sources)
|
167
168
|
configs.append(p)
|
168
169
|
|
169
170
|
return configs
|
@@ -21,8 +21,9 @@ from ..sectionVariants.save import save_section_variants
|
|
21
21
|
from ..uiTypes.save import save_ui_type_cols, save_ui_types
|
22
22
|
|
23
23
|
|
24
|
-
def save_project_details(db, p):
|
25
|
-
|
24
|
+
def save_project_details(db, p, do_save_json_source_data=True):
|
25
|
+
if do_save_json_source_data:
|
26
|
+
save_json_source_data(p)
|
26
27
|
remove_json_source_data(p)
|
27
28
|
save_artifacts(db, p["artifacts"])
|
28
29
|
save_artifact_groups(db, p["artifactGroups"], p["sections"])
|
@@ -5,6 +5,7 @@ from setta.database.db.codeInfo.utils import (
|
|
5
5
|
add_defaults_to_code_info,
|
6
6
|
add_defaults_to_code_info_cols,
|
7
7
|
)
|
8
|
+
from setta.database.db.sections.jsonSource import remove_json_source_data
|
8
9
|
from setta.database.db.sections.load import load_json_sources_into_data_structures
|
9
10
|
from setta.database.db.sections.utils import add_defaults_to_sections
|
10
11
|
from setta.database.db.sectionVariants.utils import add_defaults_to_section_variants
|
@@ -42,7 +43,9 @@ def remove_empty(x):
|
|
42
43
|
return {k: v for k, v in x.items() if len(v) > 0}
|
43
44
|
|
44
45
|
|
45
|
-
def filter_data_for_json_export(p):
|
46
|
+
def filter_data_for_json_export(p, keepCodeInfoThatHaveUITypes):
|
47
|
+
remove_json_source_data(p, keepCodeInfoThatHaveUITypes)
|
48
|
+
|
46
49
|
p["projectConfig"] = filter_dict(
|
47
50
|
p["projectConfig"],
|
48
51
|
DEFAULT_VALUES["projectConfig"].keys(),
|
@@ -262,6 +262,9 @@ def load_json_sources_into_data_structures(
|
|
262
262
|
elif s["variantId"] not in s["variantIds"]:
|
263
263
|
s["variantId"] = s["variantIds"][0]
|
264
264
|
|
265
|
+
if s["defaultVariantId"] not in s["variantIds"]:
|
266
|
+
s["defaultVariantId"] = s["variantId"]
|
267
|
+
|
265
268
|
|
266
269
|
def load_json_source(filename_glob, jsonSourceKeys):
|
267
270
|
new_data = {}
|
@@ -21,13 +21,13 @@ def _export_database(
|
|
21
21
|
export_readable(db, filename, with_variants=True)
|
22
22
|
|
23
23
|
|
24
|
-
def export_database(path):
|
24
|
+
def export_database(path, raw, readable, readable_with_variants):
|
25
25
|
# Connect to the SQLite database
|
26
26
|
dbq = DBQueue(path)
|
27
27
|
dbq.connect()
|
28
28
|
with dbq as db:
|
29
29
|
# Export the database, including schema and data, to JSON and YAML
|
30
|
-
_export_database(db, path,
|
30
|
+
_export_database(db, path, raw, readable, readable_with_variants)
|
31
31
|
dbq.disconnect()
|
32
32
|
|
33
33
|
|
@@ -138,7 +138,7 @@ def export_list_section(folder, config, section_id, variant_id, with_variants):
|
|
138
138
|
export_section(children_folder, config, c, with_variants)
|
139
139
|
|
140
140
|
|
141
|
-
def
|
141
|
+
def export_text_block_section(folder, config, section_id, variant_id, with_variants):
|
142
142
|
base = maybe_with_variant_in_filename(config, section_id, variant_id, with_variants)
|
143
143
|
section = config["sections"][section_id]
|
144
144
|
description = get_section_variant_attr(config, variant_id, "description")
|
@@ -226,8 +226,8 @@ def get_exporter_fn(config, section_id):
|
|
226
226
|
return export_regular_section
|
227
227
|
elif stype in [C.LIST_ROOT, C.DICT_ROOT, C.GROUP]:
|
228
228
|
return export_list_section
|
229
|
-
elif stype == C.
|
230
|
-
return
|
229
|
+
elif stype == C.TEXT_BLOCK:
|
230
|
+
return export_text_block_section
|
231
231
|
elif stype == C.PARAM_SWEEP:
|
232
232
|
return export_param_sweep_section
|
233
233
|
elif stype == C.GLOBAL_PARAM_SWEEP:
|
@@ -10,6 +10,6 @@ from setta.utils.constants import SETTA_FILES_FOLDER
|
|
10
10
|
def get_configs_and_root_folder(db, filename):
|
11
11
|
# export defaultdict the same way as dict
|
12
12
|
yaml.add_representer(defaultdict, Representer.represent_dict)
|
13
|
-
configs = load_full_project(db)
|
13
|
+
configs = load_full_project(db, do_load_json_sources=False)
|
14
14
|
root_folder = SETTA_FILES_FOLDER / f"{filename}_export"
|
15
15
|
return configs, root_folder
|
setta/database/seed.py
CHANGED
@@ -31,7 +31,7 @@ def seed_examples(db):
|
|
31
31
|
with open(filepath, "r") as f:
|
32
32
|
data = json.load(f)
|
33
33
|
add_defaults_to_project(data) # json files don't have all the defaults
|
34
|
-
save_project_details(db, data)
|
34
|
+
save_project_details(db, data, do_save_json_source_data=False)
|
35
35
|
|
36
36
|
|
37
37
|
def seed(db, with_examples=False, with_base_ui_types=False):
|
setta/database/settings_file.py
CHANGED
@@ -7,10 +7,7 @@ from setta.database.db.projects.utils import (
|
|
7
7
|
add_defaults_to_project_and_load_json_sources,
|
8
8
|
filter_data_for_json_export,
|
9
9
|
)
|
10
|
-
from setta.database.db.sections.jsonSource import
|
11
|
-
remove_json_source_data,
|
12
|
-
save_json_source_data,
|
13
|
-
)
|
10
|
+
from setta.database.db.sections.jsonSource import save_json_source_data
|
14
11
|
from setta.utils.constants import CONSTANTS_FOLDER, SETTA_FILES_FOLDER, USER_SETTINGS
|
15
12
|
from setta.utils.utils import get_absolute_path, save_json_to_file
|
16
13
|
|
@@ -113,6 +110,5 @@ class MetaSettingsFile:
|
|
113
110
|
|
114
111
|
def save_settings_project(self, p):
|
115
112
|
save_json_source_data(p)
|
116
|
-
|
117
|
-
filter_data_for_json_export(p)
|
113
|
+
filter_data_for_json_export(p, keepCodeInfoThatHaveUITypes=False)
|
118
114
|
save_json_to_file(self.path_meta_settings, p)
|
setta/routers/projects.py
CHANGED
@@ -178,7 +178,7 @@ def router_set_as_default_project(x: SetAsDefaultProjectRequest, dbq=Depends(get
|
|
178
178
|
|
179
179
|
@router.post(C.ROUTE_FILTER_DATA_FOR_JSON_EXPORT)
|
180
180
|
def router_filter_data_for_json_export(x: FilterDataForJSONExportRequest):
|
181
|
-
filter_data_for_json_export(x.project)
|
181
|
+
filter_data_for_json_export(x.project, keepCodeInfoThatHaveUITypes=True)
|
182
182
|
return x.project
|
183
183
|
|
184
184
|
|
setta/start.py
CHANGED
@@ -43,8 +43,19 @@ def init_db(path, with_examples):
|
|
43
43
|
|
44
44
|
@click.command()
|
45
45
|
@click.argument("path", default=get_default_db_path(), required=False)
|
46
|
-
|
47
|
-
|
46
|
+
@click.option("--raw", is_flag=True, help="Export raw database format")
|
47
|
+
@click.option("--readable", is_flag=True, help="Export in human-readable format")
|
48
|
+
@click.option(
|
49
|
+
"--readable-with-variants",
|
50
|
+
is_flag=True,
|
51
|
+
help="Export in readable format with variants",
|
52
|
+
)
|
53
|
+
def export_db(path, raw, readable, readable_with_variants):
|
54
|
+
# If no export options are specified, default to raw format
|
55
|
+
if not any([raw, readable, readable_with_variants]):
|
56
|
+
readable_with_variants = True
|
57
|
+
|
58
|
+
export_database(path, raw, readable, readable_with_variants)
|
48
59
|
|
49
60
|
|
50
61
|
@click.command()
|
@@ -96,7 +96,7 @@
|
|
96
96
|
},
|
97
97
|
"2b06a83b-b96a-490d-a2d7-3631619e6495": {
|
98
98
|
"id": "2b06a83b-b96a-490d-a2d7-3631619e6495",
|
99
|
-
"type": "
|
99
|
+
"type": "TEXT_BLOCK",
|
100
100
|
"name": "",
|
101
101
|
"presetType": "BASE",
|
102
102
|
"config": {}
|
@@ -149,5 +149,12 @@
|
|
149
149
|
"name": "",
|
150
150
|
"presetType": "BASE",
|
151
151
|
"config": {}
|
152
|
+
},
|
153
|
+
"5d7859dd-fd3f-4f5f-9b8c-fe9bede13c33": {
|
154
|
+
"id": "5d7859dd-fd3f-4f5f-9b8c-fe9bede13c33",
|
155
|
+
"type": "CHAT",
|
156
|
+
"name": "",
|
157
|
+
"presetType": "BASE",
|
158
|
+
"config": {}
|
152
159
|
}
|
153
160
|
}
|
@@ -68,7 +68,7 @@
|
|
68
68
|
"panOnScrollMode": "free",
|
69
69
|
"zoomOnScroll": true,
|
70
70
|
"zoomOnPinch": true,
|
71
|
-
"zoomOnDoubleClick":
|
71
|
+
"zoomOnDoubleClick": false,
|
72
72
|
"selectionMode": "partial",
|
73
73
|
"leftSidePaneShiftsMap": true,
|
74
74
|
"transitionDuration": 50
|
@@ -105,9 +105,11 @@
|
|
105
105
|
"GLOBAL_PARAM_SWEEP": {
|
106
106
|
"name": "Global Param Sweep"
|
107
107
|
},
|
108
|
-
"
|
109
|
-
"name": "Empty Info Section",
|
108
|
+
"TEXT_BLOCK": {
|
110
109
|
"displayMode": "RENDER"
|
110
|
+
},
|
111
|
+
"CHAT": {
|
112
|
+
"size": { "width": 405, "height": 405 }
|
111
113
|
}
|
112
114
|
}
|
113
115
|
}
|
@@ -15,7 +15,7 @@
|
|
15
15
|
"GROUP": "GROUP",
|
16
16
|
"GLOBAL_VARIABLES": "GLOBAL_VARIABLES",
|
17
17
|
"CODE": "CODE",
|
18
|
-
"
|
18
|
+
"TEXT_BLOCK": "TEXT_BLOCK",
|
19
19
|
"PARAM_SWEEP": "PARAM_SWEEP",
|
20
20
|
"TERMINAL": "TERMINAL",
|
21
21
|
"GLOBAL_PARAM_SWEEP": "GLOBAL_PARAM_SWEEP",
|
@@ -24,6 +24,7 @@
|
|
24
24
|
"DRAW": "DRAW",
|
25
25
|
"SOCIAL": "SOCIAL",
|
26
26
|
"IFRAME": "IFRAME",
|
27
|
+
"CHAT": "CHAT",
|
27
28
|
"NON_SECTION_TYPES": [
|
28
29
|
"TEXT",
|
29
30
|
"SLIDER",
|
@@ -116,6 +117,7 @@
|
|
116
117
|
"ALLOWED_ARTIFACT_TYPES": {
|
117
118
|
"DRAW": ["img", "brushStrokes"],
|
118
119
|
"IMAGE": ["img"],
|
119
|
-
"CHART": ["list"]
|
120
|
+
"CHART": ["list"],
|
121
|
+
"CHAT": ["chatHistory"]
|
120
122
|
}
|
121
123
|
}
|