Skip to content

Commit 58cb61f

Browse files
ADSDataset.show_in_notebook fails while rendering visualizations (#777)
2 parents 99946dc + 1e5b063 commit 58cb61f

File tree

8 files changed

+20
-27
lines changed

8 files changed

+20
-27
lines changed

ads/catalog/model.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8; -*-
33

4-
# Copyright (c) 2020, 2023 Oracle and/or its affiliates.
4+
# Copyright (c) 2020, 2024 Oracle and/or its affiliates.
55
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
66

77
import warnings
@@ -404,13 +404,13 @@ def show_in_notebook(self, display_format: str = "dataframe") -> None:
404404
def _repr_html_(self):
405405
"""Shows model in dataframe format."""
406406
return (
407-
self.to_dataframe().style.set_properties(**{"margin-left": "0px"}).render()
407+
self.to_dataframe().style.set_properties(**{"margin-left": "0px"}).to_html()
408408
)
409409

410410
def __repr__(self):
411411
"""Shows model in dataframe format."""
412412
return (
413-
self.to_dataframe().style.set_properties(**{"margin-left": "0px"}).render()
413+
self.to_dataframe().style.set_properties(**{"margin-left": "0px"}).to_html()
414414
)
415415

416416
def activate(self) -> None:

ads/catalog/notebook.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8; -*-
33

4-
# Copyright (c) 2020, 2022 Oracle and/or its affiliates.
4+
# Copyright (c) 2020, 2024 Oracle and/or its affiliates.
55
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
66

77
import warnings
@@ -220,7 +220,7 @@ def _repr_html_(notebook_self):
220220
lambda x: "<a href='%s'>%s</a>"
221221
% (x if x.startswith("http") else "http://%s" % x, "open")
222222
)
223-
return df.style.set_properties(**{"margin-left": "0px"}).render()
223+
return df.style.set_properties(**{"margin-left": "0px"}).to_html()
224224

225225
notebook.commit = MethodType(commit, notebook)
226226
notebook.rollback = MethodType(rollback, notebook)
@@ -295,7 +295,7 @@ def create_notebook_session(
295295
shape=None,
296296
block_storage_size_in_gbs=None,
297297
subnet_id=None,
298-
**kwargs
298+
**kwargs,
299299
):
300300
"""
301301
Create a new notebook session with the supplied details.

ads/catalog/project.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8; -*-
33

4-
# Copyright (c) 2020, 2022 Oracle and/or its affiliates.
4+
# Copyright (c) 2020, 2024 Oracle and/or its affiliates.
55
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
66

77
import warnings
@@ -237,7 +237,7 @@ def _repr_html_(project_self):
237237
return (
238238
project_self.to_dataframe()
239239
.style.set_properties(**{"margin-left": "0px"})
240-
.render()
240+
.to_html()
241241
)
242242

243243
project.commit = MethodType(commit, project)

ads/catalog/summary.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*--
33

4-
# Copyright (c) 2020, 2022 Oracle and/or its affiliates.
4+
# Copyright (c) 2020, 2024 Oracle and/or its affiliates.
55
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
66

77
from __future__ import print_function, absolute_import
@@ -98,7 +98,6 @@ def __add__(self, rhs): # pragma: no cover
9898
pass
9999

100100
def to_dataframe(self, datetime_format=None):
101-
102101
"""
103102
Returns the model catalog summary as a pandas dataframe
104103
@@ -121,7 +120,6 @@ def to_dataframe(self, datetime_format=None):
121120

122121
@runtime_dependency(module="IPython", install_from=OptionalDependency.NOTEBOOK)
123122
def show_in_notebook(self, datetime_format=None):
124-
125123
"""
126124
Displays the model catalog summary in a Jupyter Notebook cell
127125
@@ -144,7 +142,7 @@ def show_in_notebook(self, datetime_format=None):
144142
def _repr_html_(self):
145143
return self.df.style.applymap(
146144
self._color_lifecycle_state, subset=["lifecycle_state"]
147-
).render()
145+
).to_html()
148146

149147
def _sort_by(self, cols, reverse=False):
150148
return sorted(

ads/data_labeling/metadata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8; -*-
33

4-
# Copyright (c) 2021, 2022 Oracle and/or its affiliates.
4+
# Copyright (c) 2021, 2024 Oracle and/or its affiliates.
55
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
66

77
from dataclasses import asdict, dataclass, field
@@ -75,7 +75,7 @@ def to_dataframe(self) -> pd.DataFrame:
7575
def _repr_html_(self):
7676
"""Shows metadata in dataframe format."""
7777
return (
78-
self.to_dataframe().style.set_properties(**{"margin-left": "0px"}).render()
78+
self.to_dataframe().style.set_properties(**{"margin-left": "0px"}).to_html()
7979
)
8080

8181
@classmethod

ads/dataset/dataset.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*--
33

4-
# Copyright (c) 2020, 2023 Oracle and/or its affiliates.
4+
# Copyright (c) 2020, 2024 Oracle and/or its affiliates.
55
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
66

77
from __future__ import print_function, absolute_import, division
@@ -85,7 +85,6 @@ def __init__(
8585
interactive=False,
8686
**kwargs,
8787
):
88-
8988
#
9089
# to keep performance high and linear no matter the size of the distributed dataset we
9190
# create a pandas df that's used internally because this has a fixed upper size.
@@ -204,7 +203,7 @@ def _repr_html_(self):
204203
.style.set_table_styles(utils.get_dataframe_styles())
205204
.set_table_attributes("class=table")
206205
.hide_index()
207-
.render()
206+
.to_html()
208207
)
209208
)
210209
)
@@ -263,7 +262,7 @@ def _repr_html_(self):
263262
self.style.set_table_styles(utils.get_dataframe_styles())
264263
.set_table_attributes("class=table")
265264
.hide_index()
266-
.render()
265+
.to_html()
267266
)
268267
)
269268
)
@@ -1265,7 +1264,6 @@ def _build_new_dataset(
12651264
n=None,
12661265
**init_kwargs,
12671266
):
1268-
12691267
prev_doc_mode = utils.is_documentation_mode()
12701268

12711269
set_documentation_mode(False)

ads/dataset/factory.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8; -*-
33

4-
# Copyright (c) 2020, 2022 Oracle and/or its affiliates.
4+
# Copyright (c) 2020, 2024 Oracle and/or its affiliates.
55
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
66

77
from __future__ import print_function, absolute_import
@@ -367,7 +367,7 @@ def list_snapshots(snapshot_dir=None, name="", storage_options=None, **kwargs):
367367
HTML(
368368
list_df.style.set_table_attributes("class=table")
369369
.hide_index()
370-
.render()
370+
.to_html()
371371
)
372372
)
373373
return list_df
@@ -884,7 +884,6 @@ def read_xml(path: str, **kwargs) -> pd.DataFrame:
884884
import xml.etree.cElementTree as et
885885

886886
def get_children(df, node, parent, i):
887-
888887
for name in node.attrib.keys():
889888
df.at[i, parent + name] = node.attrib[name]
890889
for child in list(node):

ads/dataset/sampled_dataset.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8; -*-
33

4-
# Copyright (c) 2020, 2022 Oracle and/or its affiliates.
4+
# Copyright (c) 2020, 2024 Oracle and/or its affiliates.
55
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
66

77
import matplotlib
@@ -49,6 +49,7 @@
4949

5050
NATURAL_EARTH_DATASET = "naturalearth_lowres"
5151

52+
5253
class PandasDataset(object):
5354
"""
5455
This class provides APIs that can work on a sampled dataset.
@@ -107,7 +108,6 @@ def __init__(
107108
self.sampled_df = self.sampled_df.reset_index(drop=True)
108109

109110
def _find_feature_subset(self, df, target_name, include_n_features=32):
110-
111111
if len(df.columns) <= include_n_features:
112112
return self.sampled_df
113113
else:
@@ -212,7 +212,6 @@ def _calculate_dataset_statistics(self, is_wide_dataset, out):
212212
def _generate_features_html(
213213
self, is_wide_dataset, n_features, df_stats, visualizations_follow
214214
):
215-
216215
html = utils.get_bootstrap_styles()
217216

218217
if is_wide_dataset:
@@ -233,7 +232,7 @@ def _generate_features_html(
233232
if ("float" in str(type(x))) or ("int" in str(type(x)))
234233
else x
235234
)
236-
.render()
235+
.to_html()
237236
)
238237

239238
if visualizations_follow:
@@ -244,7 +243,6 @@ def _generate_features_html(
244243
def _generate_warnings_html(
245244
self, is_wide_dataset, n_rows, n_features, df_stats, out, accordion
246245
):
247-
248246
#
249247
# create the "Warnings" accordion section:
250248
# - show high cardinal categoricals

0 commit comments

Comments
 (0)