from k1lib.imports import *
2024-03-05 18:38:00,192 INFO worker.py:1458 -- Connecting to existing Ray cluster at address: 192.168.1.17:6379...
2024-03-05 18:38:00,202 INFO worker.py:1633 -- Connected to Ray cluster. View the dashboard at 127.0.0.1:8265
Graphviz rendering server.
# serve
_k1_d = {"edges": lambda: kgv.edges(), "nodes": lambda: kgv.nodes()}
def endpoint(obj:serve.json()=[["edges", {"it": ["ab", "bc", "ca"]}]], sketchKw:serve.json()={}) -> serve.html():
"""Renders graphviz plot dynamically, so as to add JS transpilation capabilities to k1lib.kgv.
Btw, this is so ridiculously short for a complex operation that it's just hilarious. Anyway"""
genFs = obj | cut(0) | lookup(_k1_d) | aS(list)
return obj | lookup(_k1_d, 0) | (kgv.sketch(**sketchKw) | ~apply(lambda fn, o: o["it"] | fn()) | deref()) | toHtml()
# return obj | kgv.edges() | toHtml()
endpoint() | aS(IPython.display.HTML)
jsF = ["ab", "bc", "ca", "da", "db", "dc"] | (toJsFunc(("n", range(3, 6))) | head("n") | kgv.edges()); jsF.interface()
jsF
//k1_moveOutStart
//k1_moveOutEnd
_jsD_153_1709681878_14 = ["ab", "bc", "ca", "da", "db", "dc"];
async function _jsF_759_1709681878_8(n) {
const _jsF_759_1709681878_1 = (_jsD_153_1709681878_4) => _jsD_153_1709681878_4.head(n, false)
let _jsD_153_1709681878_8 = null;
const _jsF_759_1709681878_7 = (_jsD_153_1709681878_13) => _jsD_153_1709681878_13
const _jsF_759_1709681878_5 = (_jsD_153_1709681878_10) => {
// why not just pass dataIdx in directly? Well, in Python, the interface is that __ror__ should return a 6-column input, so here, gotta honor that, in case the user has some operation downstream of this
let it = [];
for (const row of _jsD_153_1709681878_10) {
const n = row.length;
if (n === 2) it.push(["", row[0], "", row[1], {}, null]);
else if (n === 3) it.push(["", row[0], "", row[1], row[2], null]);
else if (n === 4) it.push([...row, {}, null]);
else if (n === 5) it.push([...row, null]);
else if (n === 6) it.push(row);
else throw new Error(`kgv.edges() can only accept tables from 2 to 6 columns. Detected ${n} columns instead`)
}
it = _jsF_759_1709681878_7(it);
_jsD_153_1709681878_8.push(["edges", {it, args: []}]); return it;
}
const _jsF_759_1709681878_4 = (_jsD_153_1709681878_9) => { return _jsF_759_1709681878_5(_jsD_153_1709681878_9); };
const _jsF_759_1709681878_3 = async (_jsD_153_1709681878_7) => {
_jsD_153_1709681878_8 = [];
const out = _jsF_759_1709681878_4(_jsD_153_1709681878_7);
const res = (await (await fetch("https://local.mlexps.com/routeServer/kapi_10-graphviz", {
method: "POST",
body: JSON.stringify({ "obj": _jsD_153_1709681878_8, "sketchKw": {} }),
headers: { "Content-Type": "application/json" }
})).json());
if (!res.success) throw new Error(res.reason);
return atob(res.data);
}
const _jsF_759_1709681878_0 = async (_jsD_153_1709681878_3) => { return await _jsF_759_1709681878_3(_jsF_759_1709681878_1(_jsD_153_1709681878_3)); };
return await _jsF_759_1709681878_0(_jsD_153_1709681878_14);
}
# thumbnail
jsF = [["ab", "bc", "ca", "da", "db", "dc"], [["", "a", {"color": "red", "popup": "<h3>a</h3>Some longer content"}], ["", "c", {"popup": "<h3>c</h3>Some content"}]]]\
| (toJsFunc(("n", range(3, 6))) | head("n") + iden() | (kgv.sketch() | kgv.edges() + kgv.nodes())); jsF.interface()
jsF
//k1_moveOutStart
//k1_moveOutEnd
_jsD_153_1709681878_33 = [["ab", "bc", "ca", "da", "db", "dc"], [["", "a", {"color": "red", "popup": "<h3>a</h3>Some longer content"}], ["", "c", {"popup": "<h3>c</h3>Some content"}]]];
async function _jsF_759_1709681878_23(n) {
const _jsF_759_1709681878_12 = (_jsD_153_1709681878_18) => _jsD_153_1709681878_18.head(n, false)
const _jsF_759_1709681878_13 = (_jsD_153_1709681878_20) => _jsD_153_1709681878_20
const _jsF_759_1709681878_11 = (_jsD_153_1709681878_17) => [_jsF_759_1709681878_12(_jsD_153_1709681878_17[0]), _jsF_759_1709681878_13(_jsD_153_1709681878_17[1])];
let _jsD_153_1709681878_22 = null;
const _jsF_759_1709681878_19 = (_jsD_153_1709681878_28) => _jsD_153_1709681878_28
const _jsF_759_1709681878_17 = (_jsD_153_1709681878_25) => {
// why not just pass dataIdx in directly? Well, in Python, the interface is that __ror__ should return a 6-column input, so here, gotta honor that, in case the user has some operation downstream of this
let it = [];
for (const row of _jsD_153_1709681878_25) {
const n = row.length;
if (n === 2) it.push(["", row[0], "", row[1], {}, null]);
else if (n === 3) it.push(["", row[0], "", row[1], row[2], null]);
else if (n === 4) it.push([...row, {}, null]);
else if (n === 5) it.push([...row, null]);
else if (n === 6) it.push(row);
else throw new Error(`kgv.edges() can only accept tables from 2 to 6 columns. Detected ${n} columns instead`)
}
it = _jsF_759_1709681878_19(it);
_jsD_153_1709681878_22.push(["edges", {it, args: []}]); return it;
}
const _jsF_759_1709681878_22 = (_jsD_153_1709681878_32) => _jsD_153_1709681878_32
const _jsF_759_1709681878_20 = (_jsD_153_1709681878_29) => {
let it = [];
for (const row of _jsD_153_1709681878_29) {
const n = row.length;
if (n === 1) it.push(["", row[0], {}, null]);
else if (n === 2) it.push([...row, {}, null]);
else if (n === 3) it.push([...row, null]);
else if (n === 4) it.push(row);
else throw new Error(`kgv.nodes() can only accept tables from 1 to 4 columns. Detected ${n} columns instead`)
}
it = _jsF_759_1709681878_22(it);
_jsD_153_1709681878_22.push(["nodes", {it, args: []}]); return it;
}
const _jsF_759_1709681878_16 = (_jsD_153_1709681878_24) => [_jsF_759_1709681878_17(_jsD_153_1709681878_24[0]), _jsF_759_1709681878_20(_jsD_153_1709681878_24[1])];
const _jsF_759_1709681878_15 = (_jsD_153_1709681878_23) => { return _jsF_759_1709681878_16(_jsD_153_1709681878_23); };
const _jsF_759_1709681878_14 = async (_jsD_153_1709681878_21) => {
_jsD_153_1709681878_22 = [];
const out = _jsF_759_1709681878_15(_jsD_153_1709681878_21);
const res = (await (await fetch("https://local.mlexps.com/routeServer/kapi_10-graphviz", {
method: "POST",
body: JSON.stringify({ "obj": _jsD_153_1709681878_22, "sketchKw": {} }),
headers: { "Content-Type": "application/json" }
})).json());
if (!res.success) throw new Error(res.reason);
return atob(res.data);
}
const _jsF_759_1709681878_10 = async (_jsD_153_1709681878_16) => { return await _jsF_759_1709681878_14(_jsF_759_1709681878_11(_jsD_153_1709681878_16)); };
return await _jsF_759_1709681878_10(_jsD_153_1709681878_33);
}
jsF = [["ab", "bc", "ca", "da", "db", "dc"], [["", "a", {"label": "alt a"}]]] | (toJsFunc(("n", range(3, 6))) | (kgv.sketch() | (head("n") | kgv.edges()) + kgv.nodes())); jsF.interface()
3 | (toJsFunc(("n", range(3, 6))) | (kgv.sketch() | (head("n") | kgv.edges()) + kgv.nodes()))
//k1_moveOutStart
//k1_moveOutEnd
_jsD_153_1709681878_69 = 3;
async function _jsF_759_1709681878_51(n) {
let _jsD_153_1709681878_55 = null;
const _jsF_759_1709681878_44 = (_jsD_153_1709681878_59) => _jsD_153_1709681878_59.head(n, false)
const _jsF_759_1709681878_47 = (_jsD_153_1709681878_64) => _jsD_153_1709681878_64
const _jsF_759_1709681878_45 = (_jsD_153_1709681878_61) => {
// why not just pass dataIdx in directly? Well, in Python, the interface is that __ror__ should return a 6-column input, so here, gotta honor that, in case the user has some operation downstream of this
let it = [];
for (const row of _jsD_153_1709681878_61) {
const n = row.length;
if (n === 2) it.push(["", row[0], "", row[1], {}, null]);
else if (n === 3) it.push(["", row[0], "", row[1], row[2], null]);
else if (n === 4) it.push([...row, {}, null]);
else if (n === 5) it.push([...row, null]);
else if (n === 6) it.push(row);
else throw new Error(`kgv.edges() can only accept tables from 2 to 6 columns. Detected ${n} columns instead`)
}
it = _jsF_759_1709681878_47(it);
_jsD_153_1709681878_55.push(["edges", {it, args: []}]); return it;
}
const _jsF_759_1709681878_43 = (_jsD_153_1709681878_58) => { return _jsF_759_1709681878_45(_jsF_759_1709681878_44(_jsD_153_1709681878_58)); };
const _jsF_759_1709681878_50 = (_jsD_153_1709681878_68) => _jsD_153_1709681878_68
const _jsF_759_1709681878_48 = (_jsD_153_1709681878_65) => {
let it = [];
for (const row of _jsD_153_1709681878_65) {
const n = row.length;
if (n === 1) it.push(["", row[0], {}, null]);
else if (n === 2) it.push([...row, {}, null]);
else if (n === 3) it.push([...row, null]);
else if (n === 4) it.push(row);
else throw new Error(`kgv.nodes() can only accept tables from 1 to 4 columns. Detected ${n} columns instead`)
}
it = _jsF_759_1709681878_50(it);
_jsD_153_1709681878_55.push(["nodes", {it, args: []}]); return it;
}
const _jsF_759_1709681878_42 = (_jsD_153_1709681878_57) => [_jsF_759_1709681878_43(_jsD_153_1709681878_57[0]), _jsF_759_1709681878_48(_jsD_153_1709681878_57[1])];
const _jsF_759_1709681878_41 = (_jsD_153_1709681878_56) => { return _jsF_759_1709681878_42(_jsD_153_1709681878_56); };
const _jsF_759_1709681878_40 = async (_jsD_153_1709681878_54) => {
_jsD_153_1709681878_55 = [];
const out = _jsF_759_1709681878_41(_jsD_153_1709681878_54);
const res = (await (await fetch("https://local.mlexps.com/routeServer/kapi_10-graphviz", {
method: "POST",
body: JSON.stringify({ "obj": _jsD_153_1709681878_55, "sketchKw": {} }),
headers: { "Content-Type": "application/json" }
})).json());
if (!res.success) throw new Error(res.reason);
return atob(res.data);
}
const _jsF_759_1709681878_39 = async (_jsD_153_1709681878_53) => { return await _jsF_759_1709681878_40(_jsD_153_1709681878_53); };
return await _jsF_759_1709681878_39(_jsD_153_1709681878_69);
}
data = [
["a1", "b1"], ["b1", "c1"], ["b1", "c2"], ["a1", "b2"], ["b2", "c3"], ["b2", "c4"],
["a2", "b3"], ["b3", "c5"], ["b3", "c6"], ["a2", "b4"], ["b4", "c7"], ["b4", "c8"], ["z1", "a1"], ["z1", "a2"]
]
g = data | kgv.edges(); g
g.focus("b2")
g.focus??
Signature: g.focus(name, depth=1) -> 'InteractiveGraph' Docstring: Creates a complex interactive graph that users can click on a node to zoom in to its surroundings. Example:: g = ["ab", "bc", "ca", "cd"] | kgv.edges() g.focus("a") :param name: name of the node, like "a" or "subgraph1\ue002b". The second example is just the subgraph name and node name joined together by "\ue002" :param depth: all nodes <= depth away from the selected node will be displayed :param nodeF: function to run on all nodes after filtering out-of-focus nodes :param edgeF: function to run on all edges after filtering out-of-focus nodes Source: def focus(self, name, depth=1) -> "InteractiveGraph": # Graph """Creates a complex interactive graph that users can click on a node to zoom in to its surroundings. Example:: g = ["ab", "bc", "ca", "cd"] | kgv.edges() g.focus("a") :param name: name of the node, like "a" or "subgraph1\\ue002b". The second example is just the subgraph name and node name joined together by "\\ue002" :param depth: all nodes <= depth away from the selected node will be displayed :param nodeF: function to run on all nodes after filtering out-of-focus nodes :param edgeF: function to run on all edges after filtering out-of-focus nodes""" # Graph return InteractiveGraph(self.nodes, self.edges, self.sketchKw, name, depth, self.nodesPostProcessF, self.edgesPostProcessF) # Graph File: ~/anaconda3/envs/ray2/lib/python3.9/site-packages/k1lib-1.5.2-py3.9.egg/k1lib/cli/kgv.py Type: method
fmt.html(g.focus("b2")._repr_html_())
<button id="_k1_svg_pre_3_1709681881544_homeBtn" style="padding: 4px 6px">Home</button><span style="margin-left: 8px">Focused on: </span><span id="_k1_svg_pre_3_1709681881544_focusedOn">nothing</span>. <span style="margin-left: 6px">Click on any node to focus on it. Click home to view all nodes (might be big!)</span>
<div id="_k1_svg_pre_3_1709681881544_loading"></div>
<div id="_k1_svg_pre_3_1709681881544_wrapper" style="margin-top: 8px">(Rendering...)</div>
<script>
const _jsF_759_1709681878_57 = (_jsD_153_1709681878_80) => { return _jsD_153_1709681878_80; };
const _jsF_759_1709681878_59 = (_jsD_153_1709681878_83) => { return _jsD_153_1709681878_83; };
_k1_svg_pre_3_1709681881544_nodes = [["\ue002a1", {"onclick": "_k1_svg_pre_3_1709681881544_ocb"}, null], ["\ue002c5", {"onclick": "_k1_svg_pre_3_1709681881544_ocb"}, null], ["\ue002b2", {"onclick": "_k1_svg_pre_3_1709681881544_ocb"}, null], ["\ue002c2", {"onclick": "_k1_svg_pre_3_1709681881544_ocb"}, null], ["\ue002c6", {"onclick": "_k1_svg_pre_3_1709681881544_ocb"}, null], ["\ue002c3", {"onclick": "_k1_svg_pre_3_1709681881544_ocb"}, null], ["\ue002c4", {"onclick": "_k1_svg_pre_3_1709681881544_ocb"}, null], ["\ue002c8", {"onclick": "_k1_svg_pre_3_1709681881544_ocb"}, null], ["\ue002b4", {"onclick": "_k1_svg_pre_3_1709681881544_ocb"}, null], ["\ue002c1", {"onclick": "_k1_svg_pre_3_1709681881544_ocb"}, null], ["\ue002c7", {"onclick": "_k1_svg_pre_3_1709681881544_ocb"}, null], ["\ue002z1", {"onclick": "_k1_svg_pre_3_1709681881544_ocb"}, null], ["\ue002b1", {"onclick": "_k1_svg_pre_3_1709681881544_ocb"}, null], ["\ue002a2", {"onclick": "_k1_svg_pre_3_1709681881544_ocb"}, null], ["\ue002b3", {"onclick": "_k1_svg_pre_3_1709681881544_ocb"}, null]]; _k1_svg_pre_3_1709681881544_edges = [["\ue002a1", "\ue002b1", {}, null], ["\ue002b1", "\ue002c1", {}, null], ["\ue002b1", "\ue002c2", {}, null], ["\ue002a1", "\ue002b2", {}, null], ["\ue002b2", "\ue002c3", {}, null], ["\ue002b2", "\ue002c4", {}, null], ["\ue002a2", "\ue002b3", {}, null], ["\ue002b3", "\ue002c5", {}, null], ["\ue002b3", "\ue002c6", {}, null], ["\ue002a2", "\ue002b4", {}, null], ["\ue002b4", "\ue002c7", {}, null], ["\ue002b4", "\ue002c8", {}, null], ["\ue002z1", "\ue002a1", {}, null], ["\ue002z1", "\ue002a2", {}, null]];
_k1_svg_pre_3_1709681881544_sNodes = null; _k1_svg_pre_3_1709681881544_sEdges = null; // selected nodes and edges to be rendered
_k1_svg_pre_3_1709681881544_name2Idx = {"\ue002a1": 0, "\ue002c5": 1, "\ue002b2": 2, "\ue002c2": 3, "\ue002c6": 4, "\ue002c3": 5, "\ue002c4": 6, "\ue002c8": 7, "\ue002b4": 8, "\ue002c1": 9, "\ue002c7": 10, "\ue002z1": 11, "\ue002b1": 12, "\ue002a2": 13, "\ue002b3": 14}; _k1_svg_pre_3_1709681881544_wrapper = document.querySelector("#_k1_svg_pre_3_1709681881544_wrapper"); _k1_svg_pre_3_1709681881544_loading = document.querySelector("#_k1_svg_pre_3_1709681881544_loading");
_k1_svg_pre_3_1709681881544_focusedOn = document.querySelector("#_k1_svg_pre_3_1709681881544_focusedOn");
async function _k1_svg_pre_3_1709681881544_render() { // renders sNodes and sEdges using mlexps's demo, then inject into wrapper
const nodes = _jsF_759_1709681878_57(_k1_svg_pre_3_1709681881544_nodes.map(([name, kw,extras], i) => [...name.split(""), kw, extras]).filter((e, i) => _k1_svg_pre_3_1709681881544_sNodes[i]));
const edges = _jsF_759_1709681878_59(_k1_svg_pre_3_1709681881544_edges.map(([n1,n2,kw,extras], i) => [...n1.split(""), ...n2.split(""), kw, extras]).filter((e, i) => _k1_svg_pre_3_1709681881544_sEdges[i]));
_k1_svg_pre_3_1709681881544_loading.innerHTML = "Loading...";
const res = (await (await fetch("https://local.mlexps.com/routeServer/kapi_10-graphviz", {
method: "POST",
body: JSON.stringify({ 'obj': [["edges", {"it": edges}], ["nodes", {"it": nodes}]], 'sketchKw': {} }),
headers: { "Content-Type": "application/json" }
})).json()).data;
_k1_svg_pre_3_1709681881544_wrapper.innerHTML = atob(res);
(async () => {
await (new Promise(r => setTimeout(r, 100)));
try {
for (const script of _k1_svg_pre_3_1709681881544_wrapper.getElementsByTagName("script")) eval(script.innerHTML);
_k1_svg_pre_3_1709681881544_loading.innerHTML = "";
} catch (e) { _k1_svg_pre_3_1709681881544_loading.innerHTML = `<pre style="color: red">Error encountered:
${e}</pre>`; }
})();
}
function _k1_svg_pre_3_1709681881544_reset() {
_k1_svg_pre_3_1709681881544_sNodes = [...new Array(15 ).keys()].map((x) => 1);
_k1_svg_pre_3_1709681881544_sEdges = [...new Array(14).keys()].map((x) => 1);
}; _k1_svg_pre_3_1709681881544_reset();
function _k1_svg_pre_3_1709681881544_home() {
_k1_svg_pre_3_1709681881544_focusedOn.innerHTML = "nothing";
_k1_svg_pre_3_1709681881544_sNodes = [...new Array(15 ).keys()].map((x) => 1);
_k1_svg_pre_3_1709681881544_sEdges = [...new Array(14).keys()].map((x) => 1);
_k1_svg_pre_3_1709681881544_render();
}; setTimeout(() => _k1_svg_pre_3_1709681881544_ocb("\ue002b2"), 300);
document.querySelector("#_k1_svg_pre_3_1709681881544_homeBtn").onclick = _k1_svg_pre_3_1709681881544_home;
function _k1_svg_pre_3_1709681881544_ocb(name, ctx) { // callback to inject into all. Forms sNodes and sEdges from nodes and edges
_k1_svg_pre_3_1709681881544_focusedOn.innerHTML = name.replace("", ">");
const depth = 1;
let sNodes = new Set([name]); // set of node names that will be selected to display out
for (let i = 0; i < depth; i++) {
let newOnes = [];
for (const [n1,n2,kw] of _k1_svg_pre_3_1709681881544_edges) {
if (sNodes.includes(n1)) newOnes.push(n2);
if (sNodes.includes(n2)) newOnes.push(n1);
}
for (const e of newOnes) sNodes.add(e);
}
_k1_svg_pre_3_1709681881544_sEdges = _k1_svg_pre_3_1709681881544_edges.map(([n1,n2,kw]) => sNodes.includes(n1) && sNodes.includes(n2));
_k1_svg_pre_3_1709681881544_sNodes = _k1_svg_pre_3_1709681881544_nodes.map(([n,kw]) => sNodes.includes(n));
_k1_svg_pre_3_1709681881544_render();
}
</script>
g.focus("b2", 2)
g = [[["", "light", {}, 0.2], ["", "medium", {}, 0.5], ["", "heavy", {}, 0.8]], [["", "light", "", "medium"], ["", "medium", "", "heavy"]]] | (kgv.sketch() | kgv.nodes(apply(aS("{'whiten': x}") | (viz.onload() | kapi.demo("demos_2-whiten")), 3) | ~apply(lambda a,b,c,d: [a,b,{**c, "popup": d},None]) ) + kgv.edges())
g
fmt.html(g | toHtml())
<div id="_k1_svg_pre_6_1709681881739_wrapper" style="position: relative"><?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 2.50.0 (0) -->
<!-- Pages: 1 -->
<svg width="89pt" height="188pt" viewBox="0.00 0.00 88.59 188.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="_k1_svg_24" class="graph" transform="scale(1 1) rotate(0) translate(4 184)">
<polygon fill="white" stroke="transparent" points="-4,4 -4,-184 84.59,-184 84.59,4 -4,4"/>
<!-- _idx_18 -->
<g id="_idx_18" class="node">
<ellipse fill="none" stroke="black" cx="40.3" cy="-162" rx="27" ry="18"/>
<text text-anchor="middle" x="40.3" y="-158.3" font-family="Times,serif" font-size="14.00">light</text>
</g>
<!-- _idx_19 -->
<g id="_idx_19" class="node">
<ellipse fill="none" stroke="black" cx="40.3" cy="-90" rx="40.09" ry="18"/>
<text text-anchor="middle" x="40.3" y="-86.3" font-family="Times,serif" font-size="14.00">medium</text>
</g>
<!-- _idx_18->_idx_19 -->
<g id="_k1_svg_22" class="edge">
<path fill="none" stroke="black" d="M40.3,-143.7C40.3,-135.98 40.3,-126.71 40.3,-118.11"/>
<polygon fill="black" stroke="black" points="43.8,-118.1 40.3,-108.1 36.8,-118.1 43.8,-118.1"/>
</g>
<!-- _idx_20 -->
<g id="_idx_20" class="node">
<ellipse fill="none" stroke="black" cx="40.3" cy="-18" rx="31.7" ry="18"/>
<text text-anchor="middle" x="40.3" y="-14.3" font-family="Times,serif" font-size="14.00">heavy</text>
</g>
<!-- _idx_19->_idx_20 -->
<g id="_k1_svg_23" class="edge">
<path fill="none" stroke="black" d="M40.3,-71.7C40.3,-63.98 40.3,-54.71 40.3,-46.11"/>
<polygon fill="black" stroke="black" points="43.8,-46.1 40.3,-36.1 36.8,-46.1 43.8,-46.1"/>
</g>
</g>
</svg><div id="_k1_svg_pre_6_1709681881739_popup" style="position: absolute; display: none; background: white; padding: 8px 12px; border-radius: 6px; box-shadow: 0 3px 5px rgb(0 0 0 / 0.3); z-index: 1000000"></div></div>
<script>
_k1_svg_pre_6_1709681881739_idx2Name = {"_idx_18": "\ue002light", "_idx_19": "\ue002medium", "_idx_20": "\ue002heavy"}; _k1_svg_pre_6_1709681881739_name2Idx = {"\ue002light": "_idx_18", "\ue002medium": "_idx_19", "\ue002heavy": "_idx_20"};
_k1_svg_pre_6_1709681881739_nodeId_node_popup = ([["_idx_18", atob('CjxkaXYgaWQ9J19qc0RfMTUzXzE3MDk2ODE4NzhfOTRfZGl2Jz4oTG9hZGluZy4uLik8L2Rpdj4KPHNjcmlwdD4KICAgIC8vazFfbW92ZU91dFN0YXJ0CgovL2sxX21vdmVPdXRFbmQKCl9qc0RfMTUzXzE3MDk2ODE4NzhfOTMgPSB7IndoaXRlbiI6IDAuMn07CmFzeW5jIGZ1bmN0aW9uIF9qc0ZfNzU5XzE3MDk2ODE4NzhfNjcoKSB7CiAgICBjb25zdCBfanNGXzc1OV8xNzA5NjgxODc4XzY2ID0gYXN5bmMgKF9qc0RfMTUzXzE3MDk2ODE4NzhfOTIpID0+IHsKICAgICAgICBjb25zdCBtZXRhID0gYXdhaXQgKGF3YWl0IGZldGNoKCJodHRwczovL21sZXhwcy5jb20vZGVtb3MvMi13aGl0ZW4vZGVtb19tZXRhLmpzb24iKSkuanNvbigpOwogICAgICAgIGNvbnN0IGt3ID0ge307CiAgICAgICAgZm9yIChjb25zdCBhcmcgb2YgbWV0YS5hcmdzKSB7CiAgICAgICAgICAgIGxldCBhID0gbWV0YS5kZWZhdWx0c1thcmddOyBhbm5vID0gbWV0YS5hbm5vc1thcmddOwogICAgICAgICAgICBpZiAoWyJjaGVja2JveCIsICJieXRlcyIsICJpbWFnZSIsICJzZXJpYWxpemVkIl0uaW5jbHVkZXMoYW5ubykpIGEgPSBhOwogICAgICAgICAgICBlbHNlIGlmIChhbm5vID09PSAiZHJvcGRvd24iKSBhID0gYVsxXVthWzBdXTsKICAgICAgICAgICAgZWxzZSBpZiAoYW5ubyA9PT0gImFwaUtleSIpIGEgPSAib213QTRwTWtHYW9GbXA3MEh3NnhuZkJrdUZKRW52YzUiOwogICAgICAgICAgICBlbHNlIGEgPSB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GVuIjogMC44fTsKYXN5bmMgZnVuY3Rpb24gX2pzRl83NTlfMTcwOTY4MTg3OF83NSgpIHsKICAgIGNvbnN0IF9qc0ZfNzU5XzE3MDk2ODE4NzhfNzQgPSBhc3luYyAoX2pzRF8xNTNfMTcwOTY4MTg3OF8xMDIpID0+IHsKICAgICAgICBjb25zdCBtZXRhID0gYXdhaXQgKGF3YWl0IGZldGNoKCJodHRwczovL21sZXhwcy5jb20vZGVtb3MvMi13aGl0ZW4vZGVtb19tZXRhLmpzb24iKSkuanNvbigpOwogICAgICAgIGNvbnN0IGt3ID0ge307CiAgICAgICAgZm9yIChjb25zdCBhcmcgb2YgbWV0YS5hcmdzKSB7CiAgICAgICAgICAgIGxldCBhID0gbWV0YS5kZWZhdWx0c1thcmddOyBhbm5vID0gbWV0YS5hbm5vc1thcmddOwogICAgICAgICAgICBpZiAoWyJjaGVja2JveCIsICJieXRlcyIsICJpbWFnZSIsICJzZXJpYWxpemVkIl0uaW5jbHVkZXMoYW5ubykpIGEgPSBhOwogICAgICAgICAgICBlbHNlIGlmIChhbm5vID09PSAiZHJvcGRvd24iKSBhID0gYVsxXVthWzBdXTsKICAgICAgICAgICAgZWxzZSBpZiAoYW5ubyA9PT0gImFwaUtleSIpIGEgPSAib213QTRwTWtHYW9GbXA3MEh3NnhuZkJrdUZKRW52YzUiOwogICAgICAgICAgICBlbHNlIGEgPSBhWzBdOwogICAgICAgICAgICBrd1thcmddID0gYQogICAgICAgIH0KICAgICAgICBmb3IgKGNvbnN0IFtrLHZdIG9mIE9iamVjdC5lbnRyaWVzKF9qc0RfMTUzXzE3MDk2ODE4NzhfMTAyKSkgeyBrd1trXSA9IHY7IH0KICAgICAgICBsZXQgcmVzID0gYXdhaXQgKGF3YWl0IGZldGNoKCJodHRwczovL2xvY2FsLm1sZXhwcy5jb20vcm91dGVTZXJ2ZXIvZGVtb3NfMi13aGl0ZW4iLCB7IG1ldGhvZDogIlBPU1QiLCBoZWFkZXJzOiB7ICJDb250ZW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RUaW1lb3V0KGFzeW5jICgpID0+IHsKICAgICAgICBkb2N1bWVudC5xdWVyeVNlbGVjdG9yKCcjX2pzRF8xNTNfMTcwOTY4MTg3OF8xMDRfZGl2JykuaW5uZXJIVE1MID0gYXdhaXQgX2pzRl83NTlfMTcwOTY4MTg3OF83NSgpOwogICAgfSwgMTApOwo8L3NjcmlwdD4=')]]).map(([x,y]) => [x, document.querySelector(`#${x}`), y]);
_k1_svg_pre_6_1709681881739_nodeId_node_onclick = ([]).map(([x,y]) => [x, document.querySelector(`#${x}`), y]);
_k1_svg_pre_6_1709681881739_nodes = _k1_svg_pre_6_1709681881739_nodeId_node_popup.map(([x,n,y]) => n); _k1_svg_pre_6_1709681881739_activeNode = null;
_k1_svg_pre_6_1709681881739_popup = document.querySelector("#_k1_svg_pre_6_1709681881739_popup"); _k1_svg_pre_6_1709681881739_wrapper = document.querySelector("#_k1_svg_pre_6_1709681881739_wrapper");
_k1_svg_pre_6_1709681881739_nodeId2Popup = {}; for (const [x,n,y] of _k1_svg_pre_6_1709681881739_nodeId_node_popup) { _k1_svg_pre_6_1709681881739_nodeId2Popup[x] = y; };
_k1_svg_pre_6_1709681881739_context = {nodeId_node_popup: _k1_svg_pre_6_1709681881739_nodeId_node_popup, nodeId_node_onclick: _k1_svg_pre_6_1709681881739_nodeId_node_onclick, nodes: _k1_svg_pre_6_1709681881739_nodes, idx2Name: _k1_svg_pre_6_1709681881739_idx2Name, name2Idx: _k1_svg_pre_6_1709681881739_name2Idx};
_k1_svg_pre_6_1709681881739_mouseX = 0; _k1_svg_pre_6_1709681881739_mouseY = 0; _k1_svg_pre_6_1709681881739_wrapper.onmousemove = (e) => { _k1_svg_pre_6_1709681881739_mouseX = e.clientX; _k1_svg_pre_6_1709681881739_mouseY = e.clientY; };
_k1_svg_pre_6_1709681881739_adjustInterval = null;
_k1_svg_pre_6_1709681881739_wrapper.onclick = (e) => {
const wRect = _k1_svg_pre_6_1709681881739_wrapper.getBoundingClientRect();
for (const [nodeId, node, f] of _k1_svg_pre_6_1709681881739_nodeId_node_onclick) {
const rect = node.getBoundingClientRect();
if (rect.x <= _k1_svg_pre_6_1709681881739_mouseX && _k1_svg_pre_6_1709681881739_mouseX < rect.x+rect.width && rect.y <= _k1_svg_pre_6_1709681881739_mouseY && _k1_svg_pre_6_1709681881739_mouseY < rect.y+rect.height) { f(_k1_svg_pre_6_1709681881739_idx2Name[nodeId], _k1_svg_pre_6_1709681881739_context); break; }
}
};
setInterval(() => {
if (_k1_svg_pre_6_1709681881739_activeNode) {
const rect = _k1_svg_pre_6_1709681881739_activeNode.getBoundingClientRect();
if (!(rect.x <= _k1_svg_pre_6_1709681881739_mouseX && _k1_svg_pre_6_1709681881739_mouseX < rect.x+rect.width && rect.y <= _k1_svg_pre_6_1709681881739_mouseY && _k1_svg_pre_6_1709681881739_mouseY < rect.y+rect.height)) { clearInterval(_k1_svg_pre_6_1709681881739_adjustInterval); _k1_svg_pre_6_1709681881739_adjustInterval = null; _k1_svg_pre_6_1709681881739_activeNode = null; _k1_svg_pre_6_1709681881739_popup.innerHTML = ""; _k1_svg_pre_6_1709681881739_popup.style.display = "none"; }
}
if (!_k1_svg_pre_6_1709681881739_activeNode) { // can't just do `if (activeNode) ... else ...` btw. Separated out for a reason
const wRect = _k1_svg_pre_6_1709681881739_wrapper.getBoundingClientRect();
for (const node of _k1_svg_pre_6_1709681881739_nodes) {
const rect = node.getBoundingClientRect();
if (rect.x <= _k1_svg_pre_6_1709681881739_mouseX && _k1_svg_pre_6_1709681881739_mouseX < rect.x+rect.width && rect.y <= _k1_svg_pre_6_1709681881739_mouseY && _k1_svg_pre_6_1709681881739_mouseY < rect.y+rect.height) {
const popup = _k1_svg_pre_6_1709681881739_nodeId2Popup[node.id];
_k1_svg_pre_6_1709681881739_activeNode = node;
if (popup) {
_k1_svg_pre_6_1709681881739_popup.style.left = rect.x + rect.width/2 + 10 - wRect.x + "px";
_k1_svg_pre_6_1709681881739_popup.style.top = 0; _k1_svg_pre_6_1709681881739_popup.innerHTML = popup; _k1_svg_pre_6_1709681881739_popup.style.display = "block";
(async () => { // popup might have <script> tags, so let's execute all of them
await (new Promise(r => setTimeout(r, 30)));
try { for (const script of _k1_svg_pre_6_1709681881739_popup.getElementsByTagName("script")) eval(script.innerHTML);
} catch (e) { _k1_svg_pre_6_1709681881739_popup.innerHTML = `<pre style="color: red">Error encountered:
${e}</pre>`; }
})();
if (_k1_svg_pre_6_1709681881739_adjustInterval) clearInterval(_k1_svg_pre_6_1709681881739_adjustInterval);
const adjustF = () => {
if (_k1_svg_pre_6_1709681881739_activeNode) {
const pRect = _k1_svg_pre_6_1709681881739_popup.getBoundingClientRect();
const t1 = rect.y + rect.height/2 + 10 - wRect.y; // "t" for "top"
const t2 = wRect.height - pRect.height;
_k1_svg_pre_6_1709681881739_popup.style.top = ((t2 < 0) ? 0 : Math.min(t1, t2)) + "px";
}
}; adjustF();
_k1_svg_pre_6_1709681881739_adjustInterval = setInterval(adjustF, 100);
}
break;
}
}
}
}, 30);
console.log("k1.Graph '_k1_svg_pre_6_1709681881739' loaded");
</script>
jsF = [[["", "light", {}, 0.2], ["", "medium", {}, 0.5], ["", "heavy", {}, 0.8]], [["", "light", "", "medium"], ["", "medium", "", "heavy"]]] | (toJsFunc() | (kgv.sketch() | kgv.nodes(apply(aS("{'whiten': x}") | (viz.onload() | kapi.demo("demos_2-whiten")), 3) | ~apply('lambda a,b,c,d: [a,b,{**c, "popup": d},None]') ) + kgv.edges()))
jsF.interface()
jsF
//k1_moveOutStart
const _jsF_759_1709681878_130 = async (_jsD_153_1709681878_185) => {
const meta = await (await fetch("https://mlexps.com/demos/2-whiten/demo_meta.json")).json();
const kw = {};
for (const arg of meta.args) {
let a = meta.defaults[arg]; anno = meta.annos[arg];
if (["checkbox", "bytes", "image", "serialized"].includes(anno)) a = a;
else if (anno === "dropdown") a = a[1][a[0]];
else if (anno === "apiKey") a = "omwA4pMkGaoFmp70Hw6xnfBkuFJEnvc5";
else a = a[0];
kw[arg] = a
}
for (const [k,v] of Object.entries(_jsD_153_1709681878_185)) { kw[k] = v; }
let res = await (await fetch("https://local.mlexps.com/routeServer/demos_2-whiten", { method: "POST", headers: { "Content-Type": "application/json" }, "body": JSON.stringify(kw) })).text();
try { res = JSON.parse(res); } catch (e) { throw new Error(`Can't decode json of '${res}'`); }
if (!res.success) throw new Error(`Request failed: '${res.reason}'`);
let data = res.data;
if (meta.annos.return === "html") return atob(data);
if (meta.annos.return === "image") return `<img src="data:image;base64,${data}">`
return data;
}
const _jsF_759_1709681878_129 = async (_jsD_153_1709681878_184) => { return await _jsF_759_1709681878_130(_jsD_153_1709681878_184); };
_jsD_153_1709681878_182 = null;
//k1_moveOutEnd
_jsD_153_1709681878_194 = [[["", "light", {}, 0.2], ["", "medium", {}, 0.5], ["", "heavy", {}, 0.8]], [["", "light", "", "medium"], ["", "medium", "", "heavy"]]];
async function _jsF_759_1709681878_136() {
let _jsD_153_1709681878_168 = null;
const _jsF_759_1709681878_127 = (x) => {
return {'whiten': x};
}
_jsF_759_1709681878_128 = (x) => { // returns html string that will run the function on load
_jsD_153_1709681878_182 = x;
return unescape(`<div id='_jsD_153_1709681878_183_div'></div>
%3Cscript%3E
setTimeout(async () => {
console.log("executed");
document.querySelector('#_jsD_153_1709681878_183_div').innerHTML = await _jsF_759_1709681878_129(_jsD_153_1709681878_182)
}, 100);
%3C/script%3E`);
};
const _jsF_759_1709681878_125 = (_jsD_153_1709681878_178) => { return _jsF_759_1709681878_128(_jsF_759_1709681878_127(_jsD_153_1709681878_178)); };
const _jsD_153_1709681878_176 = {};
const _jsF_759_1709681878_124 = (_jsD_153_1709681878_175) => _jsD_153_1709681878_175.apply((_jsD_153_1709681878_177) => _jsF_759_1709681878_125(_jsD_153_1709681878_177), 3, _jsD_153_1709681878_176, false)
const c = 299792458;
const _jsF_759_1709681878_132 = (a, b, c, d) => {
return [a, b, {...c, 'popup': d}, null];
}
const _jsD_153_1709681878_187 = {};
const _jsF_759_1709681878_131 = (_jsD_153_1709681878_186) => _jsD_153_1709681878_186.apply((_jsD_153_1709681878_188) => _jsF_759_1709681878_132(..._jsD_153_1709681878_188), null, _jsD_153_1709681878_187, false)
const _jsF_759_1709681878_123 = (_jsD_153_1709681878_174) => { return _jsF_759_1709681878_131(_jsF_759_1709681878_124(_jsD_153_1709681878_174)); };
const _jsF_759_1709681878_121 = (_jsD_153_1709681878_171) => {
let it = [];
for (const row of _jsD_153_1709681878_171) {
const n = row.length;
if (n === 1) it.push(["", row[0], {}, null]);
else if (n === 2) it.push([...row, {}, null]);
else if (n === 3) it.push([...row, null]);
else if (n === 4) it.push(row);
else throw new Error(`kgv.nodes() can only accept tables from 1 to 4 columns. Detected ${n} columns instead`)
}
it = _jsF_759_1709681878_123(it);
_jsD_153_1709681878_168.push(["nodes", {it, args: []}]); return it;
}
const _jsF_759_1709681878_135 = (_jsD_153_1709681878_193) => _jsD_153_1709681878_193
const _jsF_759_1709681878_133 = (_jsD_153_1709681878_190) => {
// why not just pass dataIdx in directly? Well, in Python, the interface is that __ror__ should return a 6-column input, so here, gotta honor that, in case the user has some operation downstream of this
let it = [];
for (const row of _jsD_153_1709681878_190) {
const n = row.length;
if (n === 2) it.push(["", row[0], "", row[1], {}, null]);
else if (n === 3) it.push(["", row[0], "", row[1], row[2], null]);
else if (n === 4) it.push([...row, {}, null]);
else if (n === 5) it.push([...row, null]);
else if (n === 6) it.push(row);
else throw new Error(`kgv.edges() can only accept tables from 2 to 6 columns. Detected ${n} columns instead`)
}
it = _jsF_759_1709681878_135(it);
_jsD_153_1709681878_168.push(["edges", {it, args: []}]); return it;
}
const _jsF_759_1709681878_120 = (_jsD_153_1709681878_170) => [_jsF_759_1709681878_121(_jsD_153_1709681878_170[0]), _jsF_759_1709681878_133(_jsD_153_1709681878_170[1])];
const _jsF_759_1709681878_119 = (_jsD_153_1709681878_169) => { return _jsF_759_1709681878_120(_jsD_153_1709681878_169); };
const _jsF_759_1709681878_118 = async (_jsD_153_1709681878_167) => {
_jsD_153_1709681878_168 = [];
const out = _jsF_759_1709681878_119(_jsD_153_1709681878_167);
const res = (await (await fetch("https://local.mlexps.com/routeServer/kapi_10-graphviz", {
method: "POST",
body: JSON.stringify({ "obj": _jsD_153_1709681878_168, "sketchKw": {} }),
headers: { "Content-Type": "application/json" }
})).json());
if (!res.success) throw new Error(res.reason);
return atob(res.data);
}
const _jsF_759_1709681878_117 = async (_jsD_153_1709681878_166) => { return await _jsF_759_1709681878_118(_jsD_153_1709681878_166); };
return await _jsF_759_1709681878_117(_jsD_153_1709681878_194);
}