Skip to content

Release 2.13.2rc1 #1125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ads/opctl/operator/lowcode/anomaly/model/base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def generate_report(self):
try:
anomaly_output = self._build_model()
except Exception as e:
logger.warn(f"Found exception: {e}")
logger.warning(f"Found exception: {e}")
if self.spec.datetime_column:
anomaly_output = self._fallback_build_model()
raise e
Expand Down Expand Up @@ -347,7 +347,7 @@ def _save_report(
storage_options=storage_options,
)

logger.warn(
logger.warning(
f"The report has been successfully "
f"generated and placed to the: {unique_output_dir}."
)
Expand All @@ -356,7 +356,7 @@ def _fallback_build_model(self):
"""
Fallback method for the sub model _build_model method.
"""
logger.warn(
logger.warning(
f"The build_model method has failed for the model: {self.spec.model}. "
"A fallback model will be built."
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def _build_model(self) -> AnomalyOutput:

anomaly_output.add_output(target, anomaly, score)
except Exception as e:
logger.warn(f"Encountered Error: {e}. Skipping series {target}.")
logger.warning(f"Encountered Error: {e}. Skipping series {target}.")

return anomaly_output

Expand Down
2 changes: 1 addition & 1 deletion ads/opctl/operator/lowcode/anomaly/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def _build_metrics_df(y_true, y_pred, column_name):
# Throws exception if y_true has only one class
metrics[SupportedMetrics.ROC_AUC] = roc_auc_score(y_true, y_pred)
except Exception as e:
logger.warn(f"An exception occurred: {e}")
logger.warning(f"An exception occurred: {e}")
metrics[SupportedMetrics.ROC_AUC] = None
precision, recall, thresholds = precision_recall_curve(y_true, y_pred)
metrics[SupportedMetrics.PRC_AUC] = auc(recall, precision)
Expand Down
6 changes: 5 additions & 1 deletion ads/opctl/operator/lowcode/common/transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ def run(self, data):
return clean_df

def _remove_trailing_whitespace(self, df):
return df.apply(lambda x: x.str.strip() if x.dtype == "object" else x)
return df.apply(
lambda x: x.str.strip()
if hasattr(x, "dtype") and x.dtype == "object"
else x
)

def _clean_column_names(self, df):
"""
Expand Down
9 changes: 7 additions & 2 deletions ads/opctl/operator/lowcode/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Copyright (c) 2024, 2025 Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/

import json
import logging
import os
import shutil
Expand All @@ -12,7 +13,6 @@

import fsspec
import oracledb
import json
import pandas as pd

from ads.common.object_storage_details import ObjectStorageDetails
Expand Down Expand Up @@ -142,6 +142,11 @@ def write_data(data, filename, format, storage_options=None, index=False, **kwar
)


def write_json(json_dict, filename, storage_options=None):
with fsspec.open(filename, mode="w", **storage_options) as f:
f.write(json.dumps(json_dict))


def write_simple_json(data, path):
if ObjectStorageDetails.is_oci_path(path):
storage_options = default_signer()
Expand Down Expand Up @@ -265,7 +270,7 @@ def find_output_dirname(output_dir: OutputDirectory):
while os.path.exists(unique_output_dir):
unique_output_dir = f"{output_dir}_{counter}"
counter += 1
logger.warn(
logger.warning(
f"Since the output directory was not specified, the output will be saved to {unique_output_dir} directory."
)
return unique_output_dir
Expand Down
25 changes: 15 additions & 10 deletions ads/opctl/operator/lowcode/forecast/model/arima.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python

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

import logging
Expand Down Expand Up @@ -132,13 +132,14 @@ def _train_model(self, i, s_id, df, model_kwargs):

logger.debug("===========Done===========")
except Exception as e:
self.errors_dict[s_id] = {
new_error = {
"model_name": self.spec.model,
"error": str(e),
"error_trace": traceback.format_exc(),
}
logger.warn(f"Encountered Error: {e}. Skipping.")
logger.warn(traceback.format_exc())
self.errors_dict[s_id] = new_error
logger.warning(f"Encountered Error: {e}. Skipping.")
logger.warning(traceback.format_exc())

def _build_model(self) -> pd.DataFrame:
full_data_dict = self.datasets.get_data_by_series()
Expand Down Expand Up @@ -166,7 +167,7 @@ def _generate_report(self):
sec5_text = rc.Heading("ARIMA Model Parameters", level=2)
blocks = [
rc.Html(
m['model'].summary().as_html(),
m["model"].summary().as_html(),
label=s_id if self.target_cat_col else None,
)
for i, (s_id, m) in enumerate(self.models.items())
Expand Down Expand Up @@ -201,11 +202,15 @@ def _generate_report(self):
self.formatted_local_explanation = aggregate_local_explanations

if not self.target_cat_col:
self.formatted_global_explanation = self.formatted_global_explanation.rename(
{"Series 1": self.original_target_column},
axis=1,
self.formatted_global_explanation = (
self.formatted_global_explanation.rename(
{"Series 1": self.original_target_column},
axis=1,
)
)
self.formatted_local_explanation.drop(
"Series", axis=1, inplace=True
)
self.formatted_local_explanation.drop("Series", axis=1, inplace=True)

# Create a markdown section for the global explainability
global_explanation_section = rc.Block(
Expand Down Expand Up @@ -235,7 +240,7 @@ def _generate_report(self):
local_explanation_section,
]
except Exception as e:
logger.warn(f"Failed to generate Explanations with error: {e}.")
logger.warning(f"Failed to generate Explanations with error: {e}.")
logger.debug(f"Full Traceback: {traceback.format_exc()}")

model_description = rc.Text(
Expand Down
13 changes: 9 additions & 4 deletions ads/opctl/operator/lowcode/forecast/model/automlx.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,18 @@ def _build_model(self) -> pd.DataFrame:
"selected_model_params": model.selected_model_params_,
}
except Exception as e:
self.errors_dict[s_id] = {
new_error = {
"model_name": self.spec.model,
"error": str(e),
"error_trace": traceback.format_exc(),
}
logger.warn(f"Encountered Error: {e}. Skipping.")
logger.warn(traceback.format_exc())
if s_id in self.errors_dict:
self.errors_dict[s_id]["model_fitting"] = new_error
else:
self.errors_dict[s_id] = {"model_fitting": new_error}
logger.warning(f"Encountered Error: {e}. Skipping.")
logger.warning(f"self.errors_dict[s_id]: {self.errors_dict[s_id]}")
logger.warning(traceback.format_exc())

logger.debug("===========Forecast Generated===========")

Expand Down Expand Up @@ -314,7 +319,7 @@ def _generate_report(self):
local_explanation_section,
]
except Exception as e:
logger.warn(f"Failed to generate Explanations with error: {e}.")
logger.warning(f"Failed to generate Explanations with error: {e}.")
logger.debug(f"Full Traceback: {traceback.format_exc()}")

model_description = rc.Text(
Expand Down
12 changes: 7 additions & 5 deletions ads/opctl/operator/lowcode/forecast/model/autots.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ def _build_model(self) -> pd.DataFrame:
"error": str(e),
"error_trace": traceback.format_exc(),
}
logger.warn(f"Encountered Error: {e}. Skipping.")
logger.warn(traceback.format_exc())
logger.warning(f"Encountered Error: {e}. Skipping.")
logger.warning(traceback.format_exc())

logger.debug("===========Done===========")

Expand Down Expand Up @@ -242,7 +242,7 @@ def _generate_report(self) -> tuple:
self.models.df_wide_numeric, series=s_id
),
self.datasets.list_series_ids(),
target_category_column=self.target_cat_col
target_category_column=self.target_cat_col,
)
section_1 = rc.Block(
rc.Heading("Forecast Overview", level=2),
Expand All @@ -260,15 +260,17 @@ def _generate_report(self) -> tuple:
)

except KeyError:
logger.warn("Issue generating Model Parameters Table Section. Skipping")
logger.warning(
"Issue generating Model Parameters Table Section. Skipping"
)
sec2 = rc.Text("Error generating model parameters.")

section_2 = rc.Block(sec2_text, sec2)

all_sections = [section_1, section_2]

if self.spec.generate_explanations:
logger.warn("Explanations not yet supported for the AutoTS Module")
logger.warning("Explanations not yet supported for the AutoTS Module")

# Model Description
model_description = rc.Text(
Expand Down
Loading
Loading