Skip to content

Commit 802e438

Browse files
authored
Merge branch 'oracle:main' into feature/multi-model-artifact-handler
2 parents 5f3b316 + 79ab368 commit 802e438

File tree

15 files changed

+41
-22
lines changed

15 files changed

+41
-22
lines changed

.github/workflows/run-forecast-unit-tests.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
strategy:
2828
fail-fast: false
2929
matrix:
30-
python-version: ["3.8"]
30+
python-version: ["3.8", "3.9", "3.10"]
3131

3232
steps:
3333
- uses: actions/checkout@v4
@@ -56,4 +56,7 @@ jobs:
5656
$CONDA/bin/conda init
5757
source /home/runner/.bashrc
5858
pip install -r test-requirements-operators.txt
59+
pip install "oracle-automlx[classic]>=24.2.0"
60+
pip install "oracle-automlx[forecasting]>=24.2.0"
61+
pip install pandas>=2.2.0
5962
python -m pytest -v -p no:warnings --durations=5 tests/operators/forecast

.github/workflows/run-operators-unit-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
strategy:
2828
fail-fast: false
2929
matrix:
30-
python-version: ["3.8"]
30+
python-version: ["3.8", "3.9", "3.10"]
3131

3232
steps:
3333
- uses: actions/checkout@v4

ads/opctl/operator/lowcode/anomaly/__main__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ def operate(operator_config: AnomalyOperatorConfig) -> None:
4040
AnomalyOperatorModelFactory.get_model(
4141
operator_config, datasets
4242
).generate_report()
43-
except Exception as e2:
43+
except Exception as ee:
4444
logger.debug(
45-
f"Failed to backup forecast with error {e2.args}. Raising original error."
45+
f"Failed to backup forecast with error {ee.args}. Raising original error."
4646
)
47-
raise e
47+
raise ee
4848
else:
4949
raise e
5050

ads/opctl/operator/lowcode/anomaly/model/autots.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def _generate_report(self):
9191
),
9292
]
9393
model_description = rc.Text(
94-
"The automlx model automatically pre-processes, selects and engineers "
94+
"The autots model automatically pre-processes, selects and engineers "
9595
"high-quality features in your dataset, which then given to an automatically "
9696
"chosen and optimized machine learning model.."
9797
)

ads/opctl/operator/lowcode/anomaly/schema.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,8 @@ spec:
349349
model:
350350
type: string
351351
required: false
352-
default: automlx
352+
default: autots
353353
allowed:
354-
- automlx
355354
- autots
356355
- auto
357356
meta:

ads/opctl/operator/lowcode/anomaly/utils.py

Lines changed: 3 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) 2023 Oracle and/or its affiliates.
4+
# Copyright (c) 2023, 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 os
@@ -77,5 +77,6 @@ def default_signer(**kwargs):
7777

7878
return default_signer(**kwargs)
7979

80+
8081
def select_auto_model(datasets, operator_config):
81-
return SupportedModels.AutoMLX
82+
return SupportedModels.AutoTS

ads/opctl/operator/lowcode/forecast/model/arima.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ def _train_model(self, i, s_id, df, model_kwargs):
125125
logger.debug("===========Done===========")
126126
except Exception as e:
127127
self.errors_dict[s_id] = {"model_name": self.spec.model, "error": str(e)}
128+
logger.debug(f"Encountered Error: {e}. Skipping.")
128129

129130
def _build_model(self) -> pd.DataFrame:
130131
full_data_dict = self.datasets.get_data_by_series()

ads/opctl/operator/lowcode/forecast/model/automlx.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def _build_model(self) -> pd.DataFrame:
8484
loglevel=logging.CRITICAL,
8585
)
8686
except Exception as e:
87-
logger.info("Ray already initialized")
87+
logger.info(f"Error. Has Ray already been initialized? Skipping. {e}")
8888

8989
full_data_dict = self.datasets.get_data_by_series()
9090

@@ -168,6 +168,7 @@ def _build_model(self) -> pd.DataFrame:
168168
"model_name": self.spec.model,
169169
"error": str(e),
170170
}
171+
logger.debug(f"Encountered Error: {e}. Skipping.")
171172

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

ads/opctl/operator/lowcode/forecast/model/autots.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ def _build_model(self) -> pd.DataFrame:
209209
"model_name": self.spec.model,
210210
"error": str(e),
211211
}
212+
logger.debug(f"Encountered Error: {e}. Skipping.")
212213

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

ads/opctl/operator/lowcode/forecast/model/ml_forecast.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*--
3+
4+
# Copyright (c) 2024 Oracle and/or its affiliates.
5+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
16
import pandas as pd
27
import numpy as np
38

@@ -19,6 +24,7 @@ def __init__(self, config: ForecastOperatorConfig, datasets: ForecastDatasets):
1924
self.local_explanation = {}
2025
self.formatted_global_explanation = None
2126
self.formatted_local_explanation = None
27+
self.date_col = config.spec.datetime_column.name
2228

2329
def set_kwargs(self):
2430
"""
@@ -46,7 +52,6 @@ def preprocess(self, df, series_id):
4652
)
4753
def _train_model(self, data_train, data_test, model_kwargs):
4854
try:
49-
5055
import lightgbm as lgb
5156
from mlforecast import MLForecast
5257
from mlforecast.lag_transforms import ExpandingMean, RollingMean
@@ -73,8 +78,8 @@ def _train_model(self, data_train, data_test, model_kwargs):
7378
alpha=model_kwargs["lower_quantile"],
7479
),
7580
},
76-
freq=pd.infer_freq(data_train["Date"].drop_duplicates())
77-
or pd.infer_freq(data_train["Date"].drop_duplicates()[-5:]),
81+
freq=pd.infer_freq(data_train[self.date_col].drop_duplicates())
82+
or pd.infer_freq(data_train[self.date_col].drop_duplicates()[-5:]),
7883
target_transforms=[Differences([12])],
7984
lags=model_kwargs.get(
8085
"lags",
@@ -104,7 +109,7 @@ def _train_model(self, data_train, data_test, model_kwargs):
104109
data_train[self.model_columns],
105110
static_features=model_kwargs.get("static_features", []),
106111
id_col=ForecastOutputColumns.SERIES,
107-
time_col=self.spec.datetime_column.name,
112+
time_col=self.date_col,
108113
target_col=self.spec.target_column,
109114
fitted=True,
110115
max_horizon=None if num_models is False else self.spec.horizon,
@@ -158,6 +163,7 @@ def _train_model(self, data_train, data_test, model_kwargs):
158163
"model_name": self.spec.model,
159164
"error": str(e),
160165
}
166+
logger.debug(f"Encountered Error: {e}. Skipping.")
161167

162168
def _build_model(self) -> pd.DataFrame:
163169
data_train = self.datasets.get_all_data_long(include_horizon=False)
@@ -168,7 +174,7 @@ def _build_model(self) -> pd.DataFrame:
168174
confidence_interval_width=self.spec.confidence_interval_width,
169175
horizon=self.spec.horizon,
170176
target_column=self.original_target_column,
171-
dt_column=self.spec.datetime_column.name,
177+
dt_column=self.date_col,
172178
)
173179
self._train_model(data_train, data_test, model_kwargs)
174180
return self.forecast_output.get_forecast_long()

0 commit comments

Comments
 (0)