setta 0.0.9.dev2__py3-none-any.whl → 0.0.10.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.

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.9.dev2"
1
+ __version__ = "0.0.10.dev0"
@@ -128,9 +128,7 @@ def load_project_config(db, project_config_name, do_load_json_sources=True):
128
128
  load_ev_refs_into_data_structures(db, sectionVariants, codeInfo)
129
129
  load_template_vars_into_data_structures(db, sectionVariants)
130
130
  if do_load_json_sources:
131
- load_json_sources_into_data_structures(
132
- sections, codeInfo, codeInfoCols, sectionVariants
133
- )
131
+ load_json_sources_into_data_structures(codeInfo, codeInfoCols, sectionVariants)
134
132
 
135
133
  return {
136
134
  "projectConfig": projectConfig,
@@ -15,7 +15,7 @@ from setta.utils.generate_memorable_string import generate_memorable_available_s
15
15
  from setta.utils.utils import filter_dict
16
16
 
17
17
  from ..codeInfo.save import save_code_info, save_code_info_col
18
- from ..sections.jsonSource import remove_json_source_data, save_json_source_data
18
+ from ..sections.jsonSource import remove_json_source_values, save_json_source_data
19
19
  from ..sections.save import save_sections
20
20
  from ..sectionVariants.save import save_section_variants
21
21
  from ..uiTypes.save import save_ui_type_cols, save_ui_types
@@ -24,7 +24,7 @@ from ..uiTypes.save import save_ui_type_cols, save_ui_types
24
24
  def save_project_details(db, p, do_save_json_source_data=True):
25
25
  if do_save_json_source_data:
26
26
  save_json_source_data(p)
27
- remove_json_source_data(p)
27
+ remove_json_source_values(p)
28
28
  save_artifacts(db, p["artifacts"])
29
29
  save_artifact_groups(db, p["artifactGroups"], p["sections"])
30
30
  save_code_info(db, p["codeInfo"])
@@ -5,7 +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
+ from setta.database.db.sections.jsonSource import remove_json_source_values
9
9
  from setta.database.db.sections.load import load_json_sources_into_data_structures
10
10
  from setta.database.db.sections.utils import add_defaults_to_sections
11
11
  from setta.database.db.sectionVariants.utils import add_defaults_to_section_variants
@@ -35,7 +35,7 @@ def add_defaults_to_project(p):
35
35
  def add_defaults_to_project_and_load_json_sources(p):
36
36
  add_defaults_to_project(p)
37
37
  load_json_sources_into_data_structures(
38
- p["sections"], p["codeInfo"], p["codeInfoCols"], p["sectionVariants"]
38
+ p["codeInfo"], p["codeInfoCols"], p["sectionVariants"]
39
39
  )
40
40
 
41
41
 
@@ -44,7 +44,7 @@ def remove_empty(x):
44
44
 
45
45
 
46
46
  def filter_data_for_json_export(p):
47
- remove_json_source_data(p)
47
+ remove_json_source_values(p)
48
48
 
49
49
  p["projectConfig"] = filter_dict(
50
50
  p["projectConfig"],
@@ -2,19 +2,11 @@ from setta.database.utils import remap_ids, rename_keys
2
2
  from setta.utils.generate_memorable_string import generate_memorable_string
3
3
 
4
4
 
5
- def copy_section_variants(
6
- sections, section_variants, code_info_id_map, code_info_col_id_map
7
- ):
5
+ def copy_section_variants(section_variants, code_info_id_map, code_info_col_id_map):
8
6
  new_section_variants, section_variant_id_map = remap_ids(section_variants)
9
- keep_old_name = set()
10
- for s in sections.values():
11
- if not s["jsonSource"]:
12
- continue
13
- for v in s["variantIds"]:
14
- keep_old_name.add(section_variant_id_map[v])
15
7
 
16
- for id, obj in new_section_variants.items():
17
- if id not in keep_old_name:
8
+ for obj in new_section_variants.values():
9
+ if not obj["isJsonSource"]:
18
10
  obj["name"] = generate_memorable_string()
19
11
  obj["values"] = rename_keys(obj["values"], code_info_id_map)
20
12
  if obj["codeInfoColId"]:
@@ -44,7 +44,7 @@ def copy_sections_and_other_info(x):
44
44
  x["codeInfoCols"], code_info_id_map
45
45
  )
46
46
  new_section_variants, section_variant_id_map = copy_section_variants(
47
- x["sections"], x["sectionVariants"], code_info_id_map, code_info_col_id_map
47
+ x["sectionVariants"], code_info_id_map, code_info_col_id_map
48
48
  )
49
49
  new_ui_types, ui_type_id_map = copy_ui_types(x["uiTypes"])
50
50
  new_ui_type_cols, ui_type_col_id_map = copy_ui_type_cols(
@@ -10,68 +10,59 @@ from setta.utils.utils import (
10
10
  )
11
11
 
12
12
 
13
- def save_json_source_data(p, section_ids=None, forking_from=None):
14
- sections = {
13
+ def save_json_source_data(p, variant_ids=None):
14
+ variants = {
15
15
  k: v
16
- for k, v in p["sections"].items()
17
- if v.get("jsonSource", None) and ((not section_ids) or k in section_ids)
16
+ for k, v in p["sectionVariants"].items()
17
+ if ((not variant_ids) or k in variant_ids)
18
18
  }
19
19
 
20
20
  to_be_saved = defaultdict(dict)
21
21
 
22
- forking_from_data = {}
23
- if forking_from:
24
- with open(forking_from, "r") as f:
25
- forking_from_data = json.load(f)
26
-
27
22
  p["codeInfoCols"] = replace_null_keys_with_none(p["codeInfoCols"])
28
23
 
29
- ancestor_paths = build_ancestor_paths(p["codeInfo"], p["codeInfoCols"])
30
-
31
- for s in sections.values():
32
- if not s["jsonSource"] or s["jsonSourceMissing"]:
24
+ for variant in variants.values():
25
+ if not variant["isJsonSource"]:
33
26
  continue
27
+ codeInfoColId = variant["codeInfoColId"]
28
+ if not codeInfoColId:
29
+ continue
30
+ codeInfoCol = p["codeInfoCols"][codeInfoColId]
31
+ filename = variant["name"]
32
+
33
+ ancestor_paths = build_ancestor_paths(p["codeInfo"], codeInfoCol["children"])
34
+ recursively_add_keys(
35
+ p,
36
+ variant,
37
+ codeInfoCol,
38
+ to_be_saved[filename],
39
+ None,
40
+ variant["jsonSourceKeys"],
41
+ ancestor_paths,
42
+ )
34
43
 
35
- for variantId in s["variantIds"]:
36
- variant = p["sectionVariants"][variantId]
37
- codeInfoColId = variant["codeInfoColId"]
38
- codeInfoCol = p["codeInfoCols"][codeInfoColId]
39
- filename = variant["name"]
40
-
41
- recursively_add_keys(
42
- p,
43
- variant,
44
- codeInfoCol,
45
- to_be_saved[filename],
46
- None,
47
- s["jsonSourceKeys"],
48
- ancestor_paths,
49
- )
50
-
51
- # Make sure the jsonSourceKeys are present.
52
- # (They might not be because they are completely empty)
53
- add_key_path_to_dict(to_be_saved[filename], s["jsonSourceKeys"])
44
+ # Make sure the jsonSourceKeys are present.
45
+ # (They might not be because they are completely empty)
46
+ add_key_path_to_dict(to_be_saved[filename], variant["jsonSourceKeys"])
54
47
 
55
48
  # Save each file
56
49
  for filename, data in to_be_saved.items():
57
- data = recursive_dict_merge(forking_from_data, data)
58
50
  save_json_to_file(filename, data)
59
51
 
60
52
  return to_be_saved
61
53
 
62
54
 
63
- def build_ancestor_paths(codeInfo, codeInfoCols):
55
+ def build_ancestor_paths(codeInfo, codeInfoColChildren):
64
56
  parent_map = {}
65
- for col in codeInfoCols.values():
66
- for parent_id, children in col["children"].items():
67
- for child_id in children:
68
- parent_map[(codeInfo[child_id]["jsonSource"], child_id)] = parent_id
57
+ for parent_id, children in codeInfoColChildren.items():
58
+ for child_id in children:
59
+ parent_map[child_id] = parent_id
69
60
 
70
61
  ancestor_paths = {}
71
- for node_id in codeInfo:
72
- if node_id not in ancestor_paths:
62
+ for id in parent_map.keys():
63
+ if id not in ancestor_paths:
73
64
  path = []
74
- current_id = node_id
65
+ current_id = id
75
66
 
76
67
  # Traverse up to build the path
77
68
  while current_id is not None:
@@ -80,14 +71,12 @@ def build_ancestor_paths(codeInfo, codeInfoCols):
80
71
  path.insert(0, name)
81
72
 
82
73
  # Get parent using the map
83
- parent_id = parent_map.get(
84
- (codeInfo[current_id]["jsonSource"], current_id)
85
- )
74
+ parent_id = parent_map.get(current_id)
86
75
  current_id = parent_id
87
76
  else:
88
77
  break
89
78
 
90
- ancestor_paths[node_id] = path
79
+ ancestor_paths[id] = path
91
80
 
92
81
  return ancestor_paths
93
82
 
@@ -97,20 +86,16 @@ def recursively_add_keys(
97
86
  ):
98
87
  for k in codeInfoCol["children"][codeInfoId]:
99
88
  children = codeInfoCol["children"][k]
100
- json_source = p["codeInfo"][k].get("jsonSource")
101
89
 
102
- if json_source:
103
- # Get pre-computed key path
104
- key_path = [*jsonSourceKeys, *ancestor_paths[k]]
105
- value = try_getting_value(variant, k, children)
90
+ # Get pre-computed key path
91
+ key_path = [*jsonSourceKeys, *ancestor_paths[k]]
92
+ value = try_getting_value(variant, k, children)
93
+ current_dict = add_key_path_to_dict(input_dict, key_path[:-1])
106
94
 
107
- current_dict = add_key_path_to_dict(input_dict, key_path[:-1])
95
+ # Set the value at the final position
96
+ if key_path: # Only set if we have a path
97
+ current_dict[key_path[-1]] = value
108
98
 
109
- # Set the value at the final position
110
- if key_path: # Only set if we have a path
111
- current_dict[key_path[-1]] = value
112
-
113
- # Continue recursion regardless of whether this node has a jsonSource
114
99
  recursively_add_keys(
115
100
  p, variant, codeInfoCol, input_dict, k, jsonSourceKeys, ancestor_paths
116
101
  )
@@ -133,54 +118,7 @@ def try_getting_value(variant, codeInfoId, codeInfoChildren):
133
118
  return {}
134
119
 
135
120
 
136
- def condition_keep_code_info(codeInfo, jsonCodeInfoWithUIType):
137
- if not codeInfo:
138
- return False
139
- return not codeInfo["jsonSource"] or codeInfo["id"] in jsonCodeInfoWithUIType
140
-
141
-
142
- def remove_json_source_data(p):
121
+ def remove_json_source_values(p):
143
122
  for variant in p["sectionVariants"].values():
144
- variant["values"] = {
145
- k: v
146
- for k, v in variant["values"].items()
147
- if not p["codeInfo"][k]["jsonSource"]
148
- }
149
-
150
- jsonCodeInfoWithUIType = set()
151
- for uiTypeCol in p["uiTypeCols"].values():
152
- for paramInfoId, uiTypeInfo in uiTypeCol.items():
153
- # we want to know which json source params have an associated uiTypeId
154
- # only if it's not the base TEXT type, since that's the default
155
- if (
156
- p["codeInfo"][paramInfoId]["jsonSource"]
157
- and uiTypeInfo["uiTypeId"] != BASE_UI_TYPE_IDS[C.TEXT]
158
- ):
159
- jsonCodeInfoWithUIType.add(paramInfoId)
160
-
161
- p["codeInfo"] = {
162
- k: v
163
- for k, v in p["codeInfo"].items()
164
- if condition_keep_code_info(v, jsonCodeInfoWithUIType)
165
- }
166
-
167
- for codeInfoColId in p["codeInfoCols"].keys():
168
- codeInfoCol = p["codeInfoCols"][codeInfoColId]
169
- codeInfoCol["children"] = {
170
- k: v
171
- for k, v in codeInfoCol["children"].items()
172
- if k is None
173
- or condition_keep_code_info(
174
- p["codeInfo"].get(k),
175
- jsonCodeInfoWithUIType,
176
- )
177
- }
178
- for id, children in codeInfoCol["children"].items():
179
- codeInfoCol["children"][id] = [
180
- c
181
- for c in children
182
- if condition_keep_code_info(
183
- p["codeInfo"].get(c),
184
- jsonCodeInfoWithUIType,
185
- )
186
- ]
123
+ if variant["isJsonSource"]:
124
+ variant["values"] = {}
@@ -201,148 +201,81 @@ def num_projects_each_section_exists_in(db, section_ids):
201
201
 
202
202
 
203
203
  def load_json_sources_into_data_structures(
204
- sections, codeInfo, codeInfoCols, sectionVariants, section_ids=None
204
+ codeInfo, codeInfoCols, sectionVariants, variant_ids=None
205
205
  ):
206
- filenames_loaded = set()
207
- sections = {
206
+ sectionVariants = {
208
207
  k: v
209
- for k, v in sections.items()
210
- if v["jsonSource"] and ((not section_ids) or k in section_ids)
208
+ for k, v in sectionVariants.items()
209
+ if ((not variant_ids) or k in variant_ids)
211
210
  }
212
- for s in sections.values():
213
- logger.debug(
214
- f'Attempting to read {s["jsonSource"]} with keys {s["jsonSourceKeys"]}'
215
- )
216
- new_data = load_json_source(s["jsonSource"], s["jsonSourceKeys"])
217
- filenames_loaded.update(
218
- merge_into_existing(new_data, s, sectionVariants, codeInfo, codeInfoCols)
219
- )
220
211
 
221
- # delete variants that aren't associated with a loaded file
222
- to_delete = []
223
- for s in sections.values():
224
- for vid in s["variantIds"]:
225
- if sectionVariants[vid]["name"] not in filenames_loaded:
226
- logger.debug(
227
- f'Removing variant {sectionVariants[vid]["name"]} because the associated json was not found'
228
- )
229
- to_delete.append(vid)
212
+ for variant in sectionVariants.values():
213
+ if not variant["isJsonSource"]:
214
+ continue
215
+ new_data, isMissing = load_json_source(
216
+ variant["name"], variant["jsonSourceKeys"]
217
+ )
218
+ variant["jsonSourcMissing"] = isMissing
219
+ if not isMissing:
220
+ codeInfoCol = codeInfoCols.get(variant["codeInfoColId"], {"children": {}})
221
+ merge_into_existing(new_data, variant, codeInfo, codeInfoCol)
230
222
 
231
- for vid in to_delete:
232
- if sectionVariants[vid]["codeInfoColId"]:
233
- del codeInfoCols[sectionVariants[vid]["codeInfoColId"]]
234
- del sectionVariants[vid]
235
223
 
236
- for s in sections.values():
237
- s["jsonSourceMissing"] = False
238
- s["variantIds"] = [v for v in s["variantIds"] if v in sectionVariants]
239
- if len(s["variantIds"]) == 0:
240
- logger.debug("Section has no variantIds. Creating new section variant.")
241
- variantId, variant = new_section_variant()
242
- sectionVariants[variantId] = variant
243
- s["variantId"] = variantId
244
- s["variantIds"].append(variantId)
245
- s["jsonSourceMissing"] = True
246
- elif s["variantId"] not in s["variantIds"]:
247
- logger.debug(
248
- "Selected variantId is not in list of variantIds. Changing selected variantId"
249
- )
250
- s["variantId"] = s["variantIds"][0]
251
-
252
- if s["defaultVariantId"] not in s["variantIds"]:
253
- logger.debug(
254
- "Default variantId is not in list of variantIds. Changing default variantId"
255
- )
256
- s["defaultVariantId"] = s["variantId"]
257
-
258
-
259
- def merge_into_existing(new_data, section, sectionVariants, codeInfo, codeInfoCols):
260
- filenames_loaded = set()
224
+ def merge_into_existing(data, sectionVariant, codeInfo, codeInfoCol):
225
+ filename = sectionVariant["name"]
261
226
  jsonSourceMetadata_to_id = {}
262
- ancestor_paths = build_ancestor_paths(codeInfo, codeInfoCols)
263
- for id, info in codeInfo.items():
227
+ ancestor_paths = build_ancestor_paths(codeInfo, codeInfoCol["children"])
228
+ for id in ancestor_paths:
264
229
  jsonSourceMetadata_to_id[
265
- createMetadataJsonString(info["jsonSource"], ancestor_paths[id])
230
+ createMetadataJsonString(filename, ancestor_paths[id])
266
231
  ] = id
267
232
 
268
- for filename, data in new_data.items():
269
- replacements = {}
270
- new_ancestor_paths = build_ancestor_paths(
271
- data["codeInfo"], {None: {"children": data["codeInfoColChildren"]}}
233
+ replacements = {}
234
+ new_ancestor_paths = build_ancestor_paths(
235
+ data["codeInfo"], data["codeInfoColChildren"]
236
+ )
237
+ for newId, newInfo in data["codeInfo"].items():
238
+ existingId = jsonSourceMetadata_to_id.get(
239
+ createMetadataJsonString(filename, new_ancestor_paths[newId])
272
240
  )
273
- for newId, newInfo in data["codeInfo"].items():
274
- existingId = jsonSourceMetadata_to_id.get(
275
- createMetadataJsonString(
276
- newInfo["jsonSource"], new_ancestor_paths[newId]
277
- )
278
- )
279
- if existingId:
280
- replacements[newId] = existingId
281
- else:
282
- codeInfo[newId] = newInfo
283
-
284
- for newId, existingId in replacements.items():
285
- del data["codeInfo"][newId]
286
- data["codeInfoColChildren"][existingId] = [
287
- replacements.get(x, x) for x in data["codeInfoColChildren"][newId]
288
- ]
289
- data["codeInfoColChildren"][None] = [
290
- replacements.get(x, x) for x in data["codeInfoColChildren"][None]
291
- ]
292
- del data["codeInfoColChildren"][newId]
293
- data["sectionVariantValues"][existingId] = data["sectionVariantValues"][
294
- newId
295
- ]
296
- del data["sectionVariantValues"][newId]
297
-
298
- variantId = None
299
- for vid in section["variantIds"]:
300
- if sectionVariants[vid]["name"] == filename:
301
- variantId = vid
302
- break
303
- if not variantId:
304
- variantId, section_variant = new_section_variant(
305
- name=filename,
306
- )
307
- section["variantIds"].append(variantId)
308
- sectionVariants[variantId] = section_variant
309
-
310
- curr_section_variant = sectionVariants[variantId]
311
- curr_section_variant["values"] = data["sectionVariantValues"]
312
- codeInfoColId = curr_section_variant["codeInfoColId"]
313
-
314
- if not codeInfoColId:
315
- codeInfoColId = create_new_id()
316
- curr_section_variant["codeInfoColId"] = codeInfoColId
317
- codeInfoCols[codeInfoColId] = new_code_info_col()
318
-
319
- codeInfoCols[codeInfoColId]["children"] = data["codeInfoColChildren"]
320
-
321
- section["configLanguage"] = "json"
322
- filenames_loaded.add(filename)
323
-
324
- return filenames_loaded
325
-
326
-
327
- def load_json_source(filename_glob, jsonSourceKeys):
328
- new_data = {}
329
-
330
- filenames = glob.glob(filename_glob)
331
- for filename in filenames:
332
- try:
333
- with open(filename, "r") as f:
334
- jsonSourceData = json.load(f)
335
- except json.JSONDecodeError:
336
- jsonSourceData = {}
337
- except FileNotFoundError:
338
- logger.debug(f"couldn't find: {filename}")
339
- continue
241
+ if existingId:
242
+ replacements[newId] = existingId
243
+ else:
244
+ codeInfo[newId] = newInfo
245
+
246
+ for newId, existingId in replacements.items():
247
+ del data["codeInfo"][newId]
248
+ data["codeInfoColChildren"][existingId] = [
249
+ replacements.get(x, x) for x in data["codeInfoColChildren"][newId]
250
+ ]
251
+ data["codeInfoColChildren"][None] = [
252
+ replacements.get(x, x) for x in data["codeInfoColChildren"][None]
253
+ ]
254
+ del data["codeInfoColChildren"][newId]
255
+ data["sectionVariantValues"][existingId] = data["sectionVariantValues"][newId]
256
+ del data["sectionVariantValues"][newId]
257
+
258
+ sectionVariant["values"] = data["sectionVariantValues"]
259
+ codeInfoCol["children"] = data["codeInfoColChildren"]
260
+
261
+
262
+ def load_json_source(filename, jsonSourceKeys):
263
+ jsonSourceData = {}
264
+ isMissing = False
340
265
 
341
- new_data[filename] = process_json_object(
342
- jsonSourceData, filename, jsonSourceKeys
343
- )
266
+ try:
267
+ logger.debug(f"Attempting to read {filename} with keys {jsonSourceKeys}")
268
+ with open(filename, "r") as f:
269
+ jsonSourceData = json.load(f)
270
+ except json.JSONDecodeError:
271
+ pass
272
+ except FileNotFoundError:
273
+ logger.debug(f"couldn't find: {filename}")
274
+ isMissing = True
344
275
 
345
- return new_data
276
+ new_data = process_json_object(jsonSourceData, filename, jsonSourceKeys)
277
+
278
+ return new_data, isMissing
346
279
 
347
280
 
348
281
  def process_json_object(jsonSourceData, filename, jsonSourceKeys):
@@ -381,7 +314,7 @@ def process_json_object_helper(output, obj, filename, current_path, metadataToId
381
314
  children_keys = []
382
315
  for k, v in obj.items():
383
316
  path = current_path + [k]
384
- paramInfoId, is_dict = create_json_code_info(filename, k, v, output)
317
+ paramInfoId, is_dict = create_json_code_info(k, v, output)
385
318
  metadataToId[createMetadataJsonString(filename, path)] = paramInfoId
386
319
  children_keys.append(paramInfoId)
387
320
  if is_dict:
@@ -399,14 +332,13 @@ def process_json_object_helper(output, obj, filename, current_path, metadataToId
399
332
  return parent_id
400
333
 
401
334
 
402
- def create_json_code_info(filename, key, value, output):
335
+ def create_json_code_info(key, value, output):
403
336
  paramInfoId = create_new_id()
404
337
  # Create code info entry
405
338
  output["codeInfo"][paramInfoId] = with_code_info_defaults(
406
339
  id=paramInfoId,
407
340
  name=key,
408
341
  editable=True,
409
- jsonSource=filename,
410
342
  )
411
343
  output["codeInfoColChildren"][paramInfoId] = []
412
344
 
@@ -77,9 +77,9 @@ class MetaSettingsFile:
77
77
  return settings_slice_to_path
78
78
 
79
79
  def find_path_for_settings_slice(self, p, slice):
80
- for sectionId, section in p["sections"].items():
81
- if section["jsonSourceKeys"] == [slice]:
82
- variant = get_selected_section_variant(p, sectionId)
80
+ for sectionId in p["sections"].keys():
81
+ variant = get_selected_section_variant(p, sectionId)
82
+ if variant["jsonSourceKeys"] == [slice]:
83
83
  return variant["name"]
84
84
  return None
85
85
 
setta/routers/sections.py CHANGED
@@ -54,17 +54,16 @@ class GlobalParamSweepSectionToYamlRequest(BaseModel):
54
54
 
55
55
  class LoadSectionJSONSourceRequest(BaseModel):
56
56
  project: dict
57
- sectionIdToJSONSource: Dict[str, str]
57
+ variantIdsToLoad: List[str]
58
58
 
59
59
 
60
60
  class SaveSectionJSONSourceRequest(BaseModel):
61
61
  project: dict
62
- sectionId: str
63
- forking_from: str
62
+ variantId: str
64
63
 
65
64
 
66
65
  class NewJSONVersionNameRequest(BaseModel):
67
- filenameGlob: str
66
+ filename: str
68
67
 
69
68
 
70
69
  class CreateFileRequest(BaseModel):
@@ -134,21 +133,18 @@ def route_global_param_sweep_section_to_yaml(x: GlobalParamSweepSectionToYamlReq
134
133
  @router.post(C.ROUTE_LOAD_SECTION_JSON_SOURCE)
135
134
  def route_load_section_json_source(x: LoadSectionJSONSourceRequest):
136
135
  p = x.project
137
- for k, v in x.sectionIdToJSONSource.items():
138
- p["sections"][k]["jsonSource"] = v
139
136
  load_json_sources_into_data_structures(
140
- p["sections"],
141
137
  p["codeInfo"],
142
138
  p["codeInfoCols"],
143
139
  p["sectionVariants"],
144
- section_ids=list(x.sectionIdToJSONSource.keys()),
140
+ variant_ids=x.variantIdsToLoad,
145
141
  )
146
142
  return {"project": p}
147
143
 
148
144
 
149
145
  @router.post(C.ROUTE_NEW_JSON_VERSION_NAME)
150
146
  def route_new_json_version_name(x: NewJSONVersionNameRequest):
151
- new_filename = generate_new_filename(x.filenameGlob)
147
+ new_filename = generate_new_filename(x.filename)
152
148
  Path(new_filename).parent.mkdir(parents=True, exist_ok=True)
153
149
  Path(new_filename).touch()
154
150
  return new_filename
@@ -162,7 +158,7 @@ def route_create_file(x: CreateFileRequest):
162
158
 
163
159
  @router.post(C.ROUTE_SAVE_SECTION_JSON_SOURCE)
164
160
  def route_save_section_json_source(x: SaveSectionJSONSourceRequest):
165
- save_json_source_data(x.project, [x.sectionId], x.forking_from)
161
+ save_json_source_data(x.project, [x.variantId])
166
162
 
167
163
 
168
164
  @router.post(C.ROUTE_GET_JSON_SOURCE_PATH_TO_BE_DELETED)
@@ -21,7 +21,6 @@
21
21
  "paramSweepSectionId": null,
22
22
  "nonPresetUITypeIds": [],
23
23
  "codeLanguage": "python",
24
- "configLanguage": "python",
25
24
  "runInMemory": false,
26
25
  "isFrozen": false,
27
26
  "isHorizontalOrientation": false,
@@ -54,11 +53,8 @@
54
53
  "isReadOnlyTerminal": false,
55
54
  "renderMarkdown": false,
56
55
  "positionAndSizeLocked": false,
57
- "jsonSource": "",
58
- "jsonSourceKeys": [],
59
56
  "selectedVariantIds": {},
60
57
  "paramFilter": "",
61
- "jsonSourceMissing": false,
62
58
  "isInOtherProjectConfigs": false,
63
59
  "aspectRatio": false,
64
60
  "aspectRatioExtraHeight": 0,
@@ -80,7 +76,11 @@
80
76
  "templateVars": [],
81
77
  "isFrozen": false,
82
78
  "sweep": [],
83
- "runGroup": {}
79
+ "runGroup": {},
80
+ "configLanguage": "python",
81
+ "isJsonSource": false,
82
+ "jsonSourceKeys": [],
83
+ "jsonSourceMissing": false
84
84
  },
85
85
  "codeInfo": {
86
86
  "id": null,
@@ -94,8 +94,7 @@
94
94
  "isFrozen": false,
95
95
  "isSelected": false,
96
96
  "evRefs": [],
97
- "ignoreTypeErrors": false,
98
- "jsonSource": null
97
+ "ignoreTypeErrors": false
99
98
  },
100
99
  "codeInfoCol": {
101
100
  "children": { "null": [] }