Skip to content

Commit f3ebc2d

Browse files
authored
Merge branch 'main' into migrate_to_report_creator
2 parents f00f4e9 + 58cb61f commit f3ebc2d

File tree

14 files changed

+427
-49
lines changed

14 files changed

+427
-49
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,4 @@ Consult the security guide [SECURITY.md](https://github.com/oracle/accelerated-d
181181

182182
## License
183183

184-
Copyright (c) 2020, 2022 Oracle and/or its affiliates. Licensed under the [Universal Permissive License v1.0](https://oss.oracle.com/licenses/upl/)
184+
Copyright (c) 2020, 2024 Oracle and/or its affiliates. Licensed under the [Universal Permissive License v1.0](https://oss.oracle.com/licenses/upl/)

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

ads/jobs/ads_job.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import fsspec
1212
import oci
13+
import yaml
1314
from ads.common.auth import default_signer
1415
from ads.common.decorator.utils import class_or_instance_method
1516
from ads.jobs.builders.base import Builder
@@ -263,6 +264,9 @@ def __init__(
263264
Job runtime, by default None.
264265
265266
"""
267+
# Saves a copy of the auth object from the class to the instance.
268+
# Future changes to the class level Job.auth will not affect the auth of existing instances.
269+
self.auth = self.auth.copy()
266270
for key in ["config", "signer", "client_kwargs"]:
267271
if kwargs.get(key):
268272
self.auth[key] = kwargs.pop(key)
@@ -545,6 +549,26 @@ def to_dict(self, **kwargs: Dict) -> Dict:
545549
"spec": spec,
546550
}
547551

552+
@class_or_instance_method
553+
def from_yaml(
554+
cls,
555+
yaml_string: str = None,
556+
uri: str = None,
557+
loader: callable = yaml.SafeLoader,
558+
**kwargs,
559+
):
560+
if inspect.isclass(cls):
561+
job = cls(**cls.auth)
562+
else:
563+
job = cls.__class__(**cls.auth)
564+
565+
if yaml_string:
566+
return job.from_dict(yaml.load(yaml_string, Loader=loader))
567+
if uri:
568+
yaml_dict = yaml.load(cls._read_from_file(uri=uri, **kwargs), Loader=loader)
569+
return job.from_dict(yaml_dict)
570+
raise ValueError("Must provide either YAML string or URI location")
571+
548572
@class_or_instance_method
549573
def from_dict(cls, config: dict) -> "Job":
550574
"""Initializes a job from a dictionary containing the configurations.
@@ -573,9 +597,9 @@ def from_dict(cls, config: dict) -> "Job":
573597
"runtime": cls._RUNTIME_MAPPING,
574598
}
575599
if inspect.isclass(cls):
576-
job = cls()
600+
job = cls(**cls.auth)
577601
else:
578-
job = cls.__class__()
602+
job = cls.__class__(**cls.auth)
579603

580604
for key, value in spec.items():
581605
if key in mappings:

0 commit comments

Comments
 (0)