setta 0.0.3.dev13__py3-none-any.whl → 0.0.4.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.3.dev13"
1
+ __version__ = "0.0.4.dev0"
@@ -35,23 +35,28 @@ def save_artifacts(db, artifacts):
35
35
  db.executemany(query, query_params)
36
36
 
37
37
 
38
- def save_artifact_groups(db, artifact_groups):
38
+ def save_artifact_groups(db, artifact_groups, sections):
39
39
  query = """
40
- INSERT INTO ArtifactGroupId (id, name, data)
41
- VALUES (:id, :name, :data)
40
+ INSERT INTO ArtifactGroupId (id, name, data, "order")
41
+ VALUES (:id, :name, :data, :order)
42
42
  ON CONFLICT (id)
43
43
  DO UPDATE SET
44
44
  name = :name,
45
- data = :data
45
+ data = :data,
46
+ "order" = :order
46
47
  """
47
48
  query_params = []
48
49
  for k, group in artifact_groups.items():
50
+ order = get_artifact_group_idx(k, sections)
51
+ if order is None:
52
+ continue
49
53
  data_keys = group.keys() - {"name", "artifactTransforms"}
50
54
  query_params.append(
51
55
  {
52
56
  "id": k,
53
57
  "name": group["name"],
54
58
  "data": json.dumps(filter_dict(group, data_keys)),
59
+ "order": order,
55
60
  }
56
61
  )
57
62
  db.executemany(query, query_params)
@@ -83,3 +88,14 @@ def save_artifact_groups(db, artifact_groups):
83
88
  )
84
89
 
85
90
  db.executemany(query, query_params)
91
+
92
+
93
+ def get_artifact_group_idx(artifact_group_id, sections):
94
+ for section in sections.values():
95
+ try:
96
+ if "artifactGroupIds" in section:
97
+ idx = section["artifactGroupIds"].index(artifact_group_id)
98
+ return idx
99
+ except ValueError:
100
+ continue
101
+ return None
@@ -25,7 +25,7 @@ def save_project_details(db, p):
25
25
  save_json_source_data(p)
26
26
  remove_json_source_data(p)
27
27
  save_artifacts(db, p["artifacts"])
28
- save_artifact_groups(db, p["artifactGroups"])
28
+ save_artifact_groups(db, p["artifactGroups"], p["sections"])
29
29
  save_code_info(db, p["codeInfo"])
30
30
  save_code_info_col(db, p["codeInfoCols"])
31
31
  save_ui_types(db, p["uiTypes"])
@@ -57,8 +57,11 @@ def load_sections(db, ids):
57
57
  SELECT
58
58
  originSectionId,
59
59
  GROUP_CONCAT(id) AS artifactGroupIds
60
- FROM
61
- ArtifactGroupId
60
+ FROM (
61
+ SELECT id, originSectionId
62
+ FROM ArtifactGroupId
63
+ ORDER BY "order"
64
+ )
62
65
  GROUP BY
63
66
  originSectionId
64
67
  ) AS A ON S.id = A.originSectionId
@@ -110,14 +110,14 @@ def save_sections(db, sections, section_variants):
110
110
  query = """
111
111
  UPDATE ArtifactGroupId
112
112
  SET originSectionId = :sectionId
113
- WHERE id = :artifactId
113
+ WHERE id = :artifactGroupId
114
114
  """
115
115
  for s in sections.values():
116
116
  for a in s["artifactGroupIds"]:
117
117
  query_params.append(
118
118
  {
119
119
  "sectionId": s["id"],
120
- "artifactId": a,
120
+ "artifactGroupId": a,
121
121
  }
122
122
  )
123
123
  db.executemany(query, query_params)
@@ -1,3 +1,5 @@
1
+ import asyncio
2
+
1
3
  import black
2
4
  from fastapi import APIRouter, Depends
3
5
  from pydantic import BaseModel
@@ -39,12 +41,17 @@ async def route_update_interactive_code(
39
41
  tasks=Depends(get_tasks),
40
42
  lsp_writers=Depends(get_lsp_writers),
41
43
  ):
42
- idx = 0
43
- content = []
44
- for p in x.projects:
45
- initialContent = await update_interactive_code(p, tasks, lsp_writers, idx)
46
- content.extend(initialContent)
47
- idx += 1
44
+ # Create list of coroutines to run in parallel
45
+ update_tasks = [
46
+ update_interactive_code(p, tasks, lsp_writers, idx)
47
+ for idx, p in enumerate(x.projects)
48
+ ]
49
+
50
+ # Run all updates in parallel and gather results
51
+ all_content = await asyncio.gather(*update_tasks)
52
+
53
+ # Flatten the list of content
54
+ content = [item for sublist in all_content for item in sublist]
48
55
 
49
56
  inMemorySubprocessInfo = tasks.getInMemorySubprocessInfo()
50
57
  return {"inMemorySubprocessInfo": inMemorySubprocessInfo, "content": content}
@@ -75,20 +82,34 @@ async def update_interactive_code(p, tasks, lsp_writers, idx):
75
82
  template_var_replacement_values=template_var_replacement_values,
76
83
  )
77
84
 
85
+ runCodeBlocks = p["runCodeBlocks"]
86
+ if runCodeBlocks is None:
87
+ runCodeBlocks = [
88
+ k for k in p["sections"].keys() if get_section_type(p, k) == C.CODE
89
+ ]
90
+
78
91
  top_node_ids, section_dependencies = prune_and_find_top_nodes(
79
- code_dict, p["runCodeBlocks"]
92
+ code_dict, runCodeBlocks
80
93
  )
81
94
  code_graph = []
82
95
  project_config_id = p["projectConfig"]["id"]
83
96
  for section_id in top_node_ids:
97
+ import_order = get_import_order_for_top_node(section_id, section_dependencies)
98
+ imports = [
99
+ {
100
+ "code": code_dict[s]["code"],
101
+ "module_name": create_in_memory_module_name(p, s),
102
+ }
103
+ for s in import_order
104
+ ]
105
+
84
106
  code_graph.append(
85
107
  {
108
+ "imports": imports,
86
109
  "subprocess_key": f"{project_config_id}-{section_id}-{idx}",
87
- "code": code_dict[section_id]["code"],
88
- "imports": get_import_order_for_top_node(
89
- section_id, section_dependencies
90
- ),
91
- "module_name": create_in_memory_module_name(p, section_id),
110
+ "subprocessStartMethod": p["sections"][section_id][
111
+ "subprocessStartMethod"
112
+ ],
92
113
  }
93
114
  )
94
115
 
@@ -207,6 +207,7 @@ CREATE TABLE IF NOT EXISTS ArtifactGroupId (
207
207
  name TEXT,
208
208
  data TEXT,
209
209
  originSectionId TEXT,
210
+ "order" INTEGER,
210
211
  FOREIGN KEY (originSectionId) REFERENCES Section(id) ON DELETE CASCADE
211
212
 
212
213
  );
@@ -214,7 +215,7 @@ CREATE TABLE IF NOT EXISTS ArtifactGroup (
214
215
  idid TEXT,
215
216
  artifactId TEXT,
216
217
  data TEXT,
217
- "order", INTEGER,
218
+ "order" INTEGER,
218
219
  PRIMARY KEY (idid, "order"),
219
220
  FOREIGN KEY (idid) REFERENCES ArtifactGroupId(id) ON DELETE CASCADE,
220
221
  FOREIGN KEY (artifactId) REFERENCES Artifact(id) ON DELETE CASCADE
@@ -64,7 +64,8 @@
64
64
  "aspectRatioExtraHeight": 0,
65
65
  "aspectRatioExtraWidth": 0,
66
66
  "columnWidth": null,
67
- "renderedValue": null
67
+ "renderedValue": null,
68
+ "subprocessStartMethod": "fork"
68
69
  },
69
70
  "sectionVariant": {
70
71
  "name": "",