Spaces:
Running
Running
Fix group parameters.
Browse files
biome.json
CHANGED
@@ -25,6 +25,7 @@
|
|
25 |
"useValidAnchor": "off",
|
26 |
"useButtonType": "off",
|
27 |
"noAutofocus": "off",
|
|
|
28 |
"noNoninteractiveTabindex": "off"
|
29 |
}
|
30 |
}
|
|
|
25 |
"useValidAnchor": "off",
|
26 |
"useButtonType": "off",
|
27 |
"noAutofocus": "off",
|
28 |
+
"noLabelWithoutControl": "off",
|
29 |
"noNoninteractiveTabindex": "off"
|
30 |
}
|
31 |
}
|
lynxkite-app/web/src/workspace/nodes/NodeGroupParameter.tsx
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
-
import {
|
2 |
-
import NodeParameter from "./NodeParameter";
|
3 |
|
4 |
interface SelectorType {
|
5 |
name: string;
|
@@ -23,44 +22,27 @@ interface GroupsType {
|
|
23 |
|
24 |
interface NodeGroupParameterProps {
|
25 |
meta: { selector: SelectorType; groups: GroupsType };
|
26 |
-
value: any;
|
27 |
data: any;
|
28 |
-
setParam: (name: string, value: any, options
|
29 |
-
deleteParam: (name: string, options?: { delay: number }) => void;
|
30 |
}
|
31 |
|
32 |
-
export default function NodeGroupParameter({
|
33 |
-
meta,
|
34 |
-
value,
|
35 |
-
data,
|
36 |
-
setParam,
|
37 |
-
deleteParam,
|
38 |
-
}: NodeGroupParameterProps) {
|
39 |
const selector = meta.selector;
|
40 |
-
const
|
41 |
-
const
|
42 |
-
|
43 |
-
const handleSelectorChange = (value: any, opts?: { delay: number }) => {
|
44 |
-
setSelectedValue(value);
|
45 |
-
setParam(selector.name, value, opts);
|
46 |
-
};
|
47 |
-
|
48 |
-
useEffect(() => {
|
49 |
-
// Clean possible previous parameters first
|
50 |
-
Object.values(groups).flatMap((group) => group.map((entry) => deleteParam(entry.name)));
|
51 |
-
for (const param of groups[selectedValue]) {
|
52 |
-
setParam(param.name, param.default);
|
53 |
-
}
|
54 |
-
}, [selectedValue]);
|
55 |
|
56 |
return (
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
|
|
|
|
|
|
|
|
65 |
);
|
66 |
}
|
|
|
1 |
+
import NodeParameter, { type UpdateOptions } from "./NodeParameter";
|
|
|
2 |
|
3 |
interface SelectorType {
|
4 |
name: string;
|
|
|
22 |
|
23 |
interface NodeGroupParameterProps {
|
24 |
meta: { selector: SelectorType; groups: GroupsType };
|
|
|
25 |
data: any;
|
26 |
+
setParam: (name: string, value: any, options: UpdateOptions) => void;
|
|
|
27 |
}
|
28 |
|
29 |
+
export default function NodeGroupParameter({ meta, data, setParam }: NodeGroupParameterProps) {
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
const selector = meta.selector;
|
31 |
+
const selectorValue = data.params[selector.name] || selector.default;
|
32 |
+
const group = meta.groups[selectorValue] || [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
return (
|
35 |
+
<>
|
36 |
+
{group.map((meta: any) => (
|
37 |
+
<NodeParameter
|
38 |
+
name={meta.name}
|
39 |
+
key={meta.name}
|
40 |
+
value={data.params[meta.name] ?? meta.default}
|
41 |
+
data={data}
|
42 |
+
meta={meta}
|
43 |
+
setParam={setParam}
|
44 |
+
/>
|
45 |
+
))}
|
46 |
+
</>
|
47 |
);
|
48 |
}
|
lynxkite-app/web/src/workspace/nodes/NodeParameter.tsx
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import { useRef } from "react";
|
2 |
// @ts-ignore
|
3 |
import ArrowsHorizontal from "~icons/tabler/arrows-horizontal.jsx";
|
|
|
4 |
|
5 |
const BOOLEAN = "<class 'bool'>";
|
6 |
const MODEL_TRAINING_INPUT_MAPPING =
|
@@ -189,77 +190,79 @@ interface NodeParameterProps {
|
|
189 |
value: any;
|
190 |
meta: any;
|
191 |
data: any;
|
192 |
-
|
193 |
}
|
194 |
|
195 |
-
export
|
196 |
-
|
197 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
<label className="param">
|
199 |
-
{
|
200 |
-
|
201 |
-
<ParamName name={name} />
|
202 |
-
<button className="collapsed-param">⋯</button>
|
203 |
-
</>
|
204 |
-
) : meta?.type?.format === "textarea" ? (
|
205 |
-
<>
|
206 |
-
<ParamName name={name} />
|
207 |
-
<textarea
|
208 |
-
className="textarea textarea-bordered w-full"
|
209 |
-
rows={6}
|
210 |
-
value={value}
|
211 |
-
onChange={(evt) => onChange(evt.currentTarget.value, { delay: 2 })}
|
212 |
-
onBlur={(evt) => onChange(evt.currentTarget.value, { delay: 0 })}
|
213 |
-
/>
|
214 |
-
</>
|
215 |
-
) : meta?.type?.enum ? (
|
216 |
-
<>
|
217 |
-
<ParamName name={name} />
|
218 |
-
<select
|
219 |
-
className="select select-bordered w-full"
|
220 |
-
value={value || meta.type.enum[0]}
|
221 |
-
onChange={(evt) => onChange(evt.currentTarget.value)}
|
222 |
-
>
|
223 |
-
{meta.type.enum.map((option: string) => (
|
224 |
-
<option key={option} value={option}>
|
225 |
-
{option}
|
226 |
-
</option>
|
227 |
-
))}
|
228 |
-
</select>
|
229 |
-
</>
|
230 |
-
) : meta?.type?.type === BOOLEAN ? (
|
231 |
-
<div className="form-control">
|
232 |
-
<label className="label cursor-pointer">
|
233 |
-
{name.replace(/_/g, " ")}
|
234 |
-
<input
|
235 |
-
className="checkbox"
|
236 |
-
type="checkbox"
|
237 |
-
checked={value}
|
238 |
-
onChange={(evt) => onChange(evt.currentTarget.checked)}
|
239 |
-
/>
|
240 |
-
</label>
|
241 |
-
</div>
|
242 |
-
) : meta?.type?.type === MODEL_TRAINING_INPUT_MAPPING ? (
|
243 |
-
<>
|
244 |
-
<ParamName name={name} />
|
245 |
-
<ModelMapping value={value} data={data} variant="training input" onChange={onChange} />
|
246 |
-
</>
|
247 |
-
) : meta?.type?.type === MODEL_INFERENCE_INPUT_MAPPING ? (
|
248 |
-
<>
|
249 |
-
<ParamName name={name} />
|
250 |
-
<ModelMapping value={value} data={data} variant="inference input" onChange={onChange} />
|
251 |
-
</>
|
252 |
-
) : meta?.type?.type === MODEL_OUTPUT_MAPPING ? (
|
253 |
-
<>
|
254 |
-
<ParamName name={name} />
|
255 |
-
<ModelMapping value={value} data={data} variant="output" onChange={onChange} />
|
256 |
-
</>
|
257 |
-
) : (
|
258 |
-
<>
|
259 |
-
<ParamName name={name} />
|
260 |
-
<Input value={value} onChange={onChange} />
|
261 |
-
</>
|
262 |
-
)}
|
263 |
</label>
|
264 |
);
|
265 |
}
|
|
|
1 |
import { useRef } from "react";
|
2 |
// @ts-ignore
|
3 |
import ArrowsHorizontal from "~icons/tabler/arrows-horizontal.jsx";
|
4 |
+
import NodeGroupParameter from "./NodeGroupParameter";
|
5 |
|
6 |
const BOOLEAN = "<class 'bool'>";
|
7 |
const MODEL_TRAINING_INPUT_MAPPING =
|
|
|
190 |
value: any;
|
191 |
meta: any;
|
192 |
data: any;
|
193 |
+
setParam: (name: string, value: any, options: UpdateOptions) => void;
|
194 |
}
|
195 |
|
196 |
+
export type UpdateOptions = { delay?: number };
|
197 |
+
|
198 |
+
export default function NodeParameter({ name, value, meta, data, setParam }: NodeParameterProps) {
|
199 |
+
function onChange(value: any, opts?: UpdateOptions) {
|
200 |
+
setParam(meta.name, value, opts || {});
|
201 |
+
}
|
202 |
+
return meta?.type?.format === "collapsed" ? (
|
203 |
+
<label className="param">
|
204 |
+
<ParamName name={name} />
|
205 |
+
<button className="collapsed-param">⋯</button>
|
206 |
+
</label>
|
207 |
+
) : meta?.type?.format === "textarea" ? (
|
208 |
+
<label className="param">
|
209 |
+
<ParamName name={name} />
|
210 |
+
<textarea
|
211 |
+
className="textarea textarea-bordered w-full"
|
212 |
+
rows={6}
|
213 |
+
value={value}
|
214 |
+
onChange={(evt) => onChange(evt.currentTarget.value, { delay: 2 })}
|
215 |
+
onBlur={(evt) => onChange(evt.currentTarget.value, { delay: 0 })}
|
216 |
+
/>
|
217 |
+
</label>
|
218 |
+
) : meta?.type === "group" ? (
|
219 |
+
<NodeGroupParameter meta={meta} data={data} setParam={setParam} />
|
220 |
+
) : meta?.type?.enum ? (
|
221 |
+
<label className="param">
|
222 |
+
<ParamName name={name} />
|
223 |
+
<select
|
224 |
+
className="select select-bordered w-full"
|
225 |
+
value={value || meta.type.enum[0]}
|
226 |
+
onChange={(evt) => onChange(evt.currentTarget.value)}
|
227 |
+
>
|
228 |
+
{meta.type.enum.map((option: string) => (
|
229 |
+
<option key={option} value={option}>
|
230 |
+
{option}
|
231 |
+
</option>
|
232 |
+
))}
|
233 |
+
</select>
|
234 |
+
</label>
|
235 |
+
) : meta?.type?.type === BOOLEAN ? (
|
236 |
+
<div className="form-control">
|
237 |
+
<label className="label cursor-pointer">
|
238 |
+
{name.replace(/_/g, " ")}
|
239 |
+
<input
|
240 |
+
className="checkbox"
|
241 |
+
type="checkbox"
|
242 |
+
checked={value}
|
243 |
+
onChange={(evt) => onChange(evt.currentTarget.checked)}
|
244 |
+
/>
|
245 |
+
</label>
|
246 |
+
</div>
|
247 |
+
) : meta?.type?.type === MODEL_TRAINING_INPUT_MAPPING ? (
|
248 |
+
<label className="param">
|
249 |
+
<ParamName name={name} />
|
250 |
+
<ModelMapping value={value} data={data} variant="training input" onChange={onChange} />
|
251 |
+
</label>
|
252 |
+
) : meta?.type?.type === MODEL_INFERENCE_INPUT_MAPPING ? (
|
253 |
+
<label className="param">
|
254 |
+
<ParamName name={name} />
|
255 |
+
<ModelMapping value={value} data={data} variant="inference input" onChange={onChange} />
|
256 |
+
</label>
|
257 |
+
) : meta?.type?.type === MODEL_OUTPUT_MAPPING ? (
|
258 |
+
<label className="param">
|
259 |
+
<ParamName name={name} />
|
260 |
+
<ModelMapping value={value} data={data} variant="output" onChange={onChange} />
|
261 |
+
</label>
|
262 |
+
) : (
|
263 |
<label className="param">
|
264 |
+
<ParamName name={name} />
|
265 |
+
<Input value={value} onChange={onChange} />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
266 |
</label>
|
267 |
);
|
268 |
}
|
lynxkite-app/web/src/workspace/nodes/NodeWithParams.tsx
CHANGED
@@ -3,10 +3,7 @@ import React from "react";
|
|
3 |
// @ts-ignore
|
4 |
import Triangle from "~icons/tabler/triangle-inverted-filled.jsx";
|
5 |
import LynxKiteNode from "./LynxKiteNode";
|
6 |
-
import
|
7 |
-
import NodeParameter from "./NodeParameter";
|
8 |
-
|
9 |
-
export type UpdateOptions = { delay?: number };
|
10 |
|
11 |
export function NodeWithParams(props: any) {
|
12 |
const reactFlow = useReactFlow();
|
@@ -21,16 +18,6 @@ export function NodeWithParams(props: any) {
|
|
21 |
}));
|
22 |
}
|
23 |
|
24 |
-
function deleteParam(name: string, opts: UpdateOptions) {
|
25 |
-
if (props.data.params[name] === undefined) {
|
26 |
-
return;
|
27 |
-
}
|
28 |
-
delete props.data.params[name];
|
29 |
-
reactFlow.updateNodeData(props.id, {
|
30 |
-
params: { ...props.data.params },
|
31 |
-
__execution_delay: opts.delay || 0,
|
32 |
-
});
|
33 |
-
}
|
34 |
return (
|
35 |
<>
|
36 |
{props.collapsed && metaParams.length > 0 && (
|
@@ -39,31 +26,16 @@ export function NodeWithParams(props: any) {
|
|
39 |
</div>
|
40 |
)}
|
41 |
{!collapsed &&
|
42 |
-
metaParams.map((meta: any) =>
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
deleteParam={(name: string, opts?: UpdateOptions) => deleteParam(name, opts || {})}
|
53 |
-
/>
|
54 |
-
) : (
|
55 |
-
<NodeParameter
|
56 |
-
name={meta.name}
|
57 |
-
key={meta.name}
|
58 |
-
value={props.data.params[meta.name]}
|
59 |
-
data={props.data}
|
60 |
-
meta={meta}
|
61 |
-
onChange={(value: any, opts?: UpdateOptions) =>
|
62 |
-
setParam(meta.name, value, opts || {})
|
63 |
-
}
|
64 |
-
/>
|
65 |
-
),
|
66 |
-
)}
|
67 |
{props.children}
|
68 |
</>
|
69 |
);
|
|
|
3 |
// @ts-ignore
|
4 |
import Triangle from "~icons/tabler/triangle-inverted-filled.jsx";
|
5 |
import LynxKiteNode from "./LynxKiteNode";
|
6 |
+
import NodeParameter, { type UpdateOptions } from "./NodeParameter";
|
|
|
|
|
|
|
7 |
|
8 |
export function NodeWithParams(props: any) {
|
9 |
const reactFlow = useReactFlow();
|
|
|
18 |
}));
|
19 |
}
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
return (
|
22 |
<>
|
23 |
{props.collapsed && metaParams.length > 0 && (
|
|
|
26 |
</div>
|
27 |
)}
|
28 |
{!collapsed &&
|
29 |
+
metaParams.map((meta: any) => (
|
30 |
+
<NodeParameter
|
31 |
+
name={meta.name}
|
32 |
+
key={meta.name}
|
33 |
+
value={props.data.params[meta.name]}
|
34 |
+
data={props.data}
|
35 |
+
meta={meta}
|
36 |
+
setParam={setParam}
|
37 |
+
/>
|
38 |
+
))}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
{props.children}
|
40 |
</>
|
41 |
);
|
lynxkite-graph-analytics/src/lynxkite_graph_analytics/lynxkite_ops.py
CHANGED
@@ -60,17 +60,17 @@ def import_file(
|
|
60 |
Bundle: Bundle with a single table with the contents of the file.
|
61 |
"""
|
62 |
if file_format == "csv":
|
63 |
-
names = kwargs.
|
64 |
names = pd.api.extensions.no_default if names == "<from file>" else names.split(",")
|
65 |
-
sep = kwargs.
|
66 |
sep = pd.api.extensions.no_default if sep == "<auto>" else sep
|
67 |
-
df = pd.read_csv(file_path, names=names, sep=sep
|
68 |
elif file_format == "json":
|
69 |
-
df = pd.read_json(file_path
|
70 |
elif file_format == "parquet":
|
71 |
-
df = pd.read_parquet(file_path
|
72 |
elif file_format == "excel":
|
73 |
-
df = pd.read_excel(file_path,
|
74 |
else:
|
75 |
df = ValueError(f"Unsupported file format: {file_format}")
|
76 |
return core.Bundle(dfs={table_name: df})
|
|
|
60 |
Bundle: Bundle with a single table with the contents of the file.
|
61 |
"""
|
62 |
if file_format == "csv":
|
63 |
+
names = kwargs.get("columns", "<from file>")
|
64 |
names = pd.api.extensions.no_default if names == "<from file>" else names.split(",")
|
65 |
+
sep = kwargs.get("separator", "<auto>")
|
66 |
sep = pd.api.extensions.no_default if sep == "<auto>" else sep
|
67 |
+
df = pd.read_csv(file_path, names=names, sep=sep)
|
68 |
elif file_format == "json":
|
69 |
+
df = pd.read_json(file_path)
|
70 |
elif file_format == "parquet":
|
71 |
+
df = pd.read_parquet(file_path)
|
72 |
elif file_format == "excel":
|
73 |
+
df = pd.read_excel(file_path, sheet_name=kwargs.get("sheet_name", "Sheet1"))
|
74 |
else:
|
75 |
df = ValueError(f"Unsupported file format: {file_format}")
|
76 |
return core.Bundle(dfs={table_name: df})
|