setta 0.0.6.dev0__py3-none-any.whl → 0.0.7__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 setta might be problematic. Click here for more details.

setta/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.0.6.dev0"
1
+ __version__ = "0.0.7"
@@ -18,13 +18,22 @@ def get_section_type(p, id):
18
18
 
19
19
 
20
20
  def get_artifacts(p, id):
21
- return p["sections"][id]["artifacts"]
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.types_to_process = [
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.types_to_process,
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.types_to_process
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 type_value == C.TEXT:
74
- output = str(x["value"])
75
- relative_positions = []
76
- elif type_value == C.SLIDER or type_value == C.DROPDOWN:
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 or type_value == C.PASSWORD:
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(
@@ -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
- save_json_source_data(p)
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"])
@@ -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 = {}
@@ -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 export_info_section(folder, config, section_id, variant_id, with_variants):
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.INFO:
230
- return export_info_section
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:
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):
@@ -96,7 +96,7 @@
96
96
  },
97
97
  "2b06a83b-b96a-490d-a2d7-3631619e6495": {
98
98
  "id": "2b06a83b-b96a-490d-a2d7-3631619e6495",
99
- "type": "INFO",
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": true,
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
- "INFO": {
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
- "INFO": "INFO",
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
  }
@@ -65,7 +65,8 @@
65
65
  "aspectRatioExtraWidth": 0,
66
66
  "columnWidth": null,
67
67
  "renderedValue": null,
68
- "subprocessStartMethod": "fork"
68
+ "subprocessStartMethod": "fork",
69
+ "headingAsSectionName": false
69
70
  },
70
71
  "sectionVariant": {
71
72
  "name": "",