Skip to content

Commit 63a2e8a

Browse files
committed
small fixes to group/ungropu buttons, node editor
1 parent 8e1c980 commit 63a2e8a

File tree

6 files changed

+23
-142
lines changed

6 files changed

+23
-142
lines changed

mxgraph_component/mxgraph_component/frontend/public/index.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,8 @@
260260

261261
</head>
262262
<body>
263-
<div id="toolbar" style="margin-top: 100px;">
264-
<button id="groupBtn" style="display: none;">Group</button>
265-
<button id="ungroupBtn" style="display: none;">Ungroup</button>
266-
</div>
263+
<button id="groupBtn" style="display: none; margin-top:80px;">Group</button>
264+
<button id="ungroupBtn" style="display: none; margin-top:80px;">Ungroup</button>
267265

268266
<div id="graph-container" style="width: 2000px; height: 1600px; overflow: hidden;">
269267
</div>

src/flowco/builder/type_ops.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,21 @@
11
from tempfile import TemporaryFile
2-
from typing import Any, Dict, List, Tuple
2+
from typing import Any
33

4-
import json
54
import numpy as np
65
import pandas as pd
7-
from typing import Any, Dict, List, Set, Tuple
6+
from typing import Any
87

98
import pickle
109
import base64
1110
import pandas as pd
1211
import numpy as np
1312
from typing import Any
1413

15-
from regex import E
1614

17-
from flowco.util.output import error, log, logger
1815

1916
# These are for the typchecker in str_to_type
2017
import pandas as pd
2118
import numpy as np
22-
import matplotlib.pyplot as plt
23-
import seaborn as sns
24-
import sklearn
25-
import scipy
2619
from typing import get_origin, get_args
2720

2821

src/flowco/dataflow/extended_type.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
from __future__ import annotations
22
import importlib
3-
import inspect
4-
import pprint
5-
import textwrap
6-
from typing import Any, Iterable, Set, Tuple, Union, Dict, List, Literal, Optional
3+
from typing import Any, Iterable, Union, Dict, List, Literal, Optional
74
from pydantic import BaseModel, Field
85
from abc import abstractmethod
96
import numpy as np
107
import pandas as pd
11-
from sklearn.linear_model import LinearRegression
128

13-
from flowco.builder import type_ops
149
from flowco.util.output import error
1510

1611
# Define TypeRepresentation before using it in classes
@@ -25,7 +20,7 @@
2520
"RecordType",
2621
"DictType",
2722
# "TupleType",
28-
"SklearnClassType",
23+
"LibraryClassType",
2924
"SetType",
3025
"PDDataFrameType",
3126
"PDSeriesType",
@@ -755,11 +750,11 @@ def type_schema(self) -> Dict[str, Any]:
755750
return schema
756751

757752

758-
class SklearnClassType(BaseType):
753+
class LibraryClassType(BaseType):
759754
type: Literal["class"]
760755
name: str = Field(
761756
...,
762-
description="The fully qualified name of any class in the sklearn library.",
757+
description="The fully qualified name of any class in the sklearn or statsmodels library.",
763758
) # Required field
764759
description: str = Field(
765760
..., description="A human-readable description of the type." # Required field
@@ -991,9 +986,9 @@ def infer_type(val) -> "TypeRepresentation":
991986
description="Automatically inferred as NumpyNdarrayType.",
992987
)
993988
elif not isinstance(val, type):
994-
return SklearnClassType(
989+
return LibraryClassType(
995990
name=str(type(val)),
996-
description="Automatically inferred as SklearnClassType.",
991+
description="Automatically inferred as LibraryClassType.",
997992
)
998993
return AnyType(description="Automatically inferred as AnyType.")
999994

@@ -1159,7 +1154,7 @@ def rep_to_summary(the_type: TypeRepresentation) -> str:
11591154
RecordType,
11601155
DictType,
11611156
# TupleType,
1162-
SklearnClassType,
1157+
LibraryClassType,
11631158
SetType,
11641159
PDDataFrameType,
11651160
PDSeriesType,
@@ -1179,7 +1174,7 @@ def rep_to_summary(the_type: TypeRepresentation) -> str:
11791174
RecordType.model_rebuild()
11801175
DictType.model_rebuild() # Newly added
11811176
# TupleType.model_rebuild()
1182-
SklearnClassType.model_rebuild()
1177+
LibraryClassType.model_rebuild()
11831178
SetType.model_rebuild()
11841179
PDDataFrameType.model_rebuild()
11851180
PDSeriesType.model_rebuild()
@@ -1204,6 +1199,7 @@ class update_node(BaseModel):
12041199

12051200

12061201
if __name__ == "__main__":
1202+
from sklearn.linear_model import LinearRegression
12071203

12081204
from openai import OpenAI
12091205
import openai

src/flowco/ui/dialogs/node_editor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,13 @@ def save(self):
262262
page: Page = ui_page.page()
263263
page.clean(node.id) # !!! this can change the page.dfg
264264

265+
node = node.update(phase=Phase.requirements)
266+
265267
dfg = ui_page.dfg() # must reload
266268

267269
for phase in visible_phases():
268270
node = node.update(cache=node.cache.update(phase=phase, node=node))
269271

270-
node = node.update(phase=min(node.phase, Phase.code))
271272

272273
log(
273274
"Updating node",

src/flowco/util/prompts.yaml

Lines changed: 8 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ system-prompt: |
22
You are an assistant to take a data science computation dataflow diagram
33
and generate code.
44
5-
You may only import matplotlib, seaborn, numpy, sklearn, and pandas.
5+
You may only import matplotlib, seaborn, numpy, sklearn, statsmodels, scipy, and pandas.
66
77
semantic-diff: |
88
Here are the old and new values for parts of a computation step:
@@ -523,113 +523,6 @@ algorithm: |
523523
524524
525525
526-
# assess: |
527-
# Here are the preconditions for a set of variables, and a post-condition:
528-
# ```
529-
# {requirements}
530-
# ```
531-
# And an algorithm:
532-
# ```
533-
# {algorithm}
534-
# ```
535-
# Assume an expert data scientist will write code for this algorithm using Python and the standard
536-
# numpy, pandas, matplotlib, seaborn, scipy, and sklearn libraries.
537-
# The expert has no other information about the function but can make reasonable choices about
538-
# how to implement parts of it.
539-
540-
# I want you to assess the algorithm. Here are the criteria:
541-
# * Are the postconditions unambiguous in their meaning?
542-
# * Does the algorithm meet the post-conditions if the preconditions are all satisfied?
543-
# * Is it a meaningful algorithm?
544-
# * Are the results easy to interpret?
545-
546-
# Answer, `Good`, `Bad`, or `More Information Needed`.
547-
548-
# If your answer is `Bad`, provide a reason why the algorithm does not meet the post-condition.
549-
550-
# If your answer is `More Information Needed`, provide the most important question that would help you make a decision:
551-
# * If additional data is needed to perform the computation, ask for that data.
552-
# * If more information about the algorithm is needed, ask the most important question related to that algorithm.
553-
554-
555-
# return-type: |
556-
# Here are the pre and post conditions for a function
557-
# ```
558-
# {requirements}
559-
# ```
560-
# Create a return type for the function that meets the postconditions.
561-
562-
# The return type's specification
563-
# should be detailed enough that users of the function can understand what
564-
# the function returns. Do not include a specificaiton if the return
565-
# type is None.
566-
567-
# Assume the client has no other information about the function.
568-
569-
# If this function returns data from a file, use the column labels
570-
# and types found in that file.
571-
572-
# The type should reflect what is described in the specification.
573-
# The return type for functions generating plots should be None.
574-
575-
# return-description: |
576-
# Here are the pre and post conditions for a function
577-
# ```
578-
# {requirements}
579-
# ```
580-
# Give a one sentence description of the value returned by
581-
# this function.
582-
583-
# description: |
584-
# Here are the preconditions for a set of variables used by
585-
# a computation:
586-
# ```
587-
# {preconditions}
588-
# ```
589-
# Here are the requirements for the return value `{function_return_var}`:
590-
# ```
591-
# {requirements}
592-
# ```
593-
594-
# Create a prose description for this step of the computation.
595-
596-
# parameters: |
597-
# Identify the function_return_vars from all direct and indirect
598-
# predecessors that will be necessary to compute the results of this stage.
599-
600-
# Your answer should be a list of variables drawn from this list:
601-
# ```
602-
# {result_vars}
603-
# ```
604-
605-
606-
# signatures: |
607-
# Create a Python function signature for this step of the computation.
608-
609-
# The signature should include the function name, the parameters, and the return
610-
# type for this step.
611-
612-
# The function name should capture the intent of this step computation.
613-
614-
# There is one parameter for each predecessor node. For this node,
615-
# there are `{n_predecessors}` predecessors. They are:
616-
# ```
617-
# {predecessors}
618-
# ```
619-
620-
# The parameter types should match the return values for
621-
# the predecessors' functions.
622-
623-
# The return type should be described with its type and any
624-
# requirements for the value. If a stage has no outgoing edges.
625-
626-
# Assume that the following modules have been imported:
627-
# ```
628-
# import pandas as pd
629-
# import numpy as np
630-
# import seaborn as sns
631-
# import matplotlib.pyplot as plt
632-
# ```
633526
634527
compile: |
635528
Write the code for this step as a single function.
@@ -649,7 +542,7 @@ compile: |
649542
* Be optimized for readability, clarity, and simplicity.
650543
* Do not include pydoc strings.
651544
652-
You may only import matplotlib, seaborn, numpy, sklearn, scipy, and pandas.
545+
You may only import matplotlib, seaborn, numpy, sklearn, statsmodels, scipy, and pandas.
653546
654547
Import any classes referenced in the return type.
655548
@@ -1046,7 +939,7 @@ ama_node_editor: |
1046939
* Be optimized for readability, clarity, and simplicity.
1047940
* Do not include pydoc strings.
1048941
1049-
You may only import matplotlib, seaborn, numpy, sklearn, scipy, and pandas.
942+
You may only import matplotlib, seaborn, numpy, sklearn, statsmodels, scipy, and pandas.
1050943
1051944
Import any classes referenced in the return type.
1052945
@@ -1207,8 +1100,8 @@ repair-syntax: |
12071100
* Have no side effects.
12081101
* Be optimized for readability, clarity, and simplicity.
12091102
* Do not include pydoc strings.
1210-
1211-
You may only import matplotlib, seaborn, numpy, sklearn, scipy, and pandas.
1103+
1104+
You may only import matplotlib, seaborn, numpy, sklearn, statsmodels, scipy, and pandas.
12121105
12131106
Import any classes referenced in the return type.
12141107
@@ -1280,7 +1173,7 @@ repair-node-run: |
12801173
* Be optimized for readability, clarity, and simplicity.
12811174
* Do not include pydoc strings.
12821175
1283-
You may only import matplotlib, seaborn, numpy, sklearn, scipy, and pandas.
1176+
You may only import matplotlib, seaborn, numpy, sklearn, statsmodels, scipy, and pandas.
12841177
12851178
Import any classes referenced in the return type.
12861179
@@ -1681,7 +1574,8 @@ full-compile-code: |
16811574
* Have no side effects.
16821575
* Be optimized for readability, clarity, and simplicity.
16831576
1684-
You may only import matplotlib, seaborn, numpy, sklearn, and pandas. Uses seaborn for all plots, with
1577+
You may only import matplotlib, seaborn, numpy, sklearn, statsmodels, scipy, and pandas.
1578+
Use seaborn for all plots, with
16851579
no changes to the base style. Do not call `plt.close()` and *do not* save them to disk.
16861580
16871581
Do not include other functions.

src/flowthon/__main__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import webbrowser
1313

1414
import nbformat
15-
from sklearn import base
1615

1716
from flowthon.nbflowthon import convert_notebook_to_flowthon
1817
from flowthon.nbsplit import split_notebook_by_heading_level

0 commit comments

Comments
 (0)