Skip to content

Commit

Permalink
URL links fix to open them in new tab (#1369)
Browse files Browse the repository at this point in the history
* 34067 url links fix to open in new tab

* 34067 fixed test for pyright

* 34067 fixed test for pyright

Signed-off-by: Marta Tomzik <marta.tomzik@ibm.com>

* 34067 removed egg info

Signed-off-by: Marta Tomzik <marta.tomzik@ibm.com>

* 34067 isort fix

Signed-off-by: Marta Tomzik <marta.tomzik@ibm.com>

---------

Signed-off-by: Marta Tomzik <marta.tomzik@ibm.com>
  • Loading branch information
marta-tomzik committed Apr 29, 2024
1 parent e7cc587 commit 787b032
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lale/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def _json_to_graphviz_rec(uid, jsn, cluster2reps, is_root, dot_graph_attr):
tooltip=_indiv_op_tooltip(uid, jsn),
)
if "documentation_url" in jsn:
dot.attr("graph", URL=jsn["documentation_url"])
dot.attr("graph", URL=jsn["documentation_url"], target="_blank")
nodes = jsn["steps"]
if jsn["class"] == _LALE_SKL_PIPELINE:
names = list(nodes.keys())
Expand All @@ -192,6 +192,7 @@ def _json_to_graphviz_rec(uid, jsn, cluster2reps, is_root, dot_graph_attr):
"style": "filled",
"fillcolor": _STATE2COLOR[step_jsn["state"]],
"tooltip": tooltip,
"target": "_blank",
}
if "documentation_url" in step_jsn:
attrs["URL"] = step_jsn["documentation_url"]
Expand Down
13 changes: 13 additions & 0 deletions test/test_json_pretty_viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ def test_with_operator_choice(self):
optimizable = kernel_tfm_or_not >> tfm >> clf
optimizable.visualize(ipython_display=False)

def test_url_generation(self):
from graphviz import Source

from lale.lib.lale import NoOp
from lale.lib.sklearn import PCA, LogisticRegression

sample = NoOp >> PCA >> LogisticRegression
result = Source(str(sample.visualize(ipython_display=False)))
for i in result:
if "URL" in i:
print(i)
self.assertTrue("target=_blank" in i)

def test_invalid_input(self):
from sklearn.linear_model import LogisticRegression as SklearnLR

Expand Down

0 comments on commit 787b032

Please sign in to comment.