Skip to content

Commit

Permalink
Optimized uts script
Browse files Browse the repository at this point in the history
  • Loading branch information
liangs6212 committed Jul 22, 2022
1 parent 603c230 commit 6349247
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 35 deletions.
36 changes: 2 additions & 34 deletions python/chronos/dev/test/run-pytests-onnxrt16.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,40 +27,8 @@ fi

ray stop -f

echo "Running chronos tests TF1 and Deprecated API"
python -m pytest -v test/bigdl/chronos/autots/test_autotsestimator.py::TestAutoTrainer::test_fit_lstm_feature \
test/bigdl/chronos/autots/test_autotsestimator.py::TestAutoTrainer::test_fit_tcn_feature \
test/bigdl/chronos/autots/test_autotsestimator.py::TestAutoTrainer::test_fit_seq2seq_feature \
test/bigdl/chronos/autots/test_tspipeline.py::TestTSPipeline::test_seq2seq_tsppl_support_dataloader \
test/bigdl/chronos/autots/test_tspipeline.py::TestTSPipeline::test_tsppl_quantize_data_creator \
test/bigdl/chronos/autots/model/test_auto_lstm.py::TestAutoLSTM::test_onnx_methods \
test/bigdl/chronos/autots/model/test_auto_lstm.py::TestAutoLSTM::test_save_load \
test/bigdl/chronos/autots/model/test_auto_tcn.py::TestAutoTCN::test_onnx_methods \
test/bigdl/chronos/autots/model/test_auto_tcn.py::TestAutoTCN::test_save_load \
test/bigdl/chronos/autots/model/test_auto_seq2seq.py::TestAutoSeq2Seq::test_onnx_methods \
test/bigdl/chronos/autots/model/test_auto_seq2seq.py::TestAutoSeq2Seq::test_save_load \
test/bigdl/chronos/forecaster/test_lstm_forecaster.py::TestChronosModelLSTMForecaster::test_lstm_forecaster_onnx_methods \
test/bigdl/chronos/forecaster/test_lstm_forecaster.py::TestChronosModelLSTMForecaster::test_lstm_forecaster_quantization_onnx \
test/bigdl/chronos/forecaster/test_lstm_forecaster.py::TestChronosModelLSTMForecaster::test_lstm_forecaster_quantization_onnx_tuning \
test/bigdl/chronos/forecaster/test_lstm_forecaster.py::TestChronosModelLSTMForecaster::test_lstm_forecaster_distributed \
test/bigdl/chronos/forecaster/test_lstm_forecaster.py::TestChronosModelLSTMForecaster::test_lstm_forecaster_fit_loader \
test/bigdl/chronos/forecaster/test_lstm_forecaster.py::TestChronosModelLSTMForecaster::test_forecaster_from_tsdataset_data_loader_onnx \
test/bigdl/chronos/forecaster/test_seq2seq_forecaster.py::TestChronosModelSeq2SeqForecaster::test_s2s_forecaster_onnx_methods \
test/bigdl/chronos/forecaster/test_seq2seq_forecaster.py::TestChronosModelSeq2SeqForecaster::test_s2s_forecaster_distributed \
test/bigdl/chronos/forecaster/test_seq2seq_forecaster.py::TestChronosModelSeq2SeqForecaster::test_s2s_forecaster_fit_loader \
test/bigdl/chronos/forecaster/test_seq2seq_forecaster.py::TestChronosModelSeq2SeqForecaster::test_forecaster_from_tsdataset_data_loader_onnx \
test/bigdl/chronos/forecaster/test_tcn_forecaster.py::TestChronosModelTCNForecaster::test_tcn_forecaster_onnx_methods \
test/bigdl/chronos/forecaster/test_tcn_forecaster.py::TestChronosModelTCNForecaster::test_tcn_forecaster_quantization_onnx \
test/bigdl/chronos/forecaster/test_tcn_forecaster.py::TestChronosModelTCNForecaster::test_tcn_forecaster_quantization_onnx_tuning \
test/bigdl/chronos/forecaster/test_tcn_forecaster.py::TestChronosModelTCNForecaster::test_tcn_forecaster_distributed \
test/bigdl/chronos/forecaster/test_tcn_forecaster.py::TestChronosModelTCNForecaster::test_tcn_forecaster_fit_loader \
test/bigdl/chronos/forecaster/test_tcn_forecaster.py::TestChronosModelTCNForecaster::test_forecaster_from_tsdataset_data_loader_onnx \
test/bigdl/chronos/forecaster/test_nbeats_forecaster.py::TestChronosNBeatsForecaster::test_nbeats_forecaster_onnx_methods \
test/bigdl/chronos/forecaster/test_nbeats_forecaster.py::TestChronosNBeatsForecaster::test_nbeats_forecaster_quantization_onnx \
test/bigdl/chronos/forecaster/test_nbeats_forecaster.py::TestChronosNBeatsForecaster::test_nbeats_forecaster_quantization_onnx_tuning \
test/bigdl/chronos/forecaster/test_nbeats_forecaster.py::TestChronosNBeatsForecaster::test_nbeats_forecaster_fit_loader \
test/bigdl/chronos/forecaster/test_nbeats_forecaster.py::TestChronosNBeatsForecaster::test_nbeats_forecaster_distributed \
test/bigdl/chronos/forecaster/test_nbeats_forecaster.py::TestChronosNBeatsForecaster::test_forecaster_from_tsdataset_data_loader_onnx
echo "Running chronos tests onnxrt16"
python -m pytest -v -m "skipif and onnxrt16" test/bigdl/chronos/

exit_status_0=$?
if [ $exit_status_0 -ne 0 ];
Expand Down
2 changes: 1 addition & 1 deletion python/chronos/dev/test/run-pytests-tf1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fi
ray stop -f

echo "Running chronos tests TF1 and Deprecated API"
python -m pytest -v test/bigdl/chronos/model/tf1
python -m pytest -v -m "skipif and tf1" test/bigdl/chronos/model/

exit_status_0=$?
if [ $exit_status_0 -ne 0 ];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ def test_predict_evaluation(self):
auto_lstm.evaluate((test_data_x, test_data_y))

@skip_onnxrt
@pytest.mark.onnxrt16
def test_onnx_methods(self):
auto_lstm = get_auto_estimator()
auto_lstm.fit(data=train_dataloader_creator(config={"batch_size": 64}),
Expand All @@ -165,6 +166,7 @@ def test_onnx_methods(self):
pass

@skip_onnxrt
@pytest.mark.onnxrt16
def test_save_load(self):
auto_lstm = get_auto_estimator()
auto_lstm.fit(data=train_dataloader_creator(config={"batch_size": 64}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ def test_predict_evaluation(self):
auto_seq2seq.evaluate((test_data_x, test_data_y))

@skip_onnxrt
@pytest.mark.onnxrt16
def test_onnx_methods(self):
auto_seq2seq = get_auto_estimator()
auto_seq2seq.fit(data=train_dataloader_creator(config={"batch_size": 64}),
Expand All @@ -173,6 +174,7 @@ def test_onnx_methods(self):
pass

@skip_onnxrt
@pytest.mark.onnxrt16
def test_save_load(self):
auto_seq2seq = get_auto_estimator()
auto_seq2seq.fit(data=train_dataloader_creator(config={"batch_size": 64}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ def test_predict_evaluation(self):
auto_tcn.evaluate((test_data_x, test_data_y))

@skip_onnxrt
@pytest.mark.onnxrt16
def test_onnx_methods(self):
auto_tcn = get_auto_estimator()
auto_tcn.fit(data=train_dataloader_creator(config={"batch_size": 64}),
Expand All @@ -208,6 +209,7 @@ def test_onnx_methods(self):
pass

@skip_onnxrt
@pytest.mark.onnxrt16
def test_save_load(self):
auto_tcn = get_auto_estimator()
auto_tcn.fit(data=train_dataloader_creator(config={"batch_size": 64}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ def customized_metric(y_true, y_pred):
assert 4 <= best_config["past_seq_len"] <= 6

@skip_onnxrt
@pytest.mark.onnxrt16
def test_fit_lstm_feature(self):
from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
Expand Down Expand Up @@ -379,6 +380,7 @@ def test_fit_lstm_feature(self):
new_ts_pipeline.fit(tsdata_valid)

@skip_onnxrt
@pytest.mark.onnxrt16
def test_fit_tcn_feature(self):
from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
Expand Down Expand Up @@ -447,6 +449,7 @@ def test_fit_tcn_feature(self):
new_ts_pipeline.fit(tsdata_valid)

@skip_onnxrt
@pytest.mark.onnxrt16
def test_fit_seq2seq_feature(self):
from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
Expand Down
2 changes: 2 additions & 0 deletions python/chronos/test/bigdl/chronos/autots/test_tspipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def tearDown(self) -> None:
pass

@skip_onnxrt
@pytest.mark.onnxrt16
def test_seq2seq_tsppl_support_dataloader(self):
# load
tsppl_seq2seq = TSPipeline.load(
Expand Down Expand Up @@ -181,6 +182,7 @@ def test_tsppl_mixed_data_type_usage(self):
yhat = tsppl_lstm.predict(data=get_test_tsdataset(), batch_size=16)

@skip_onnxrt
@pytest.mark.onnxrt16
def test_tsppl_quantize_data_creator(self):
# s2s not support quantize
with pytest.raises(RuntimeError):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def test_lstm_forecaster_fit_eva_pred(self):
assert test_mse[0].shape == test_data[1].shape[1:]

@skip_onnxrt
@pytest.mark.onnxrt16
def test_lstm_forecaster_fit_loader(self):
train_loader, val_loader, test_loader = create_data(loader=True)
forecaster = LSTMForecaster(past_seq_len=24,
Expand All @@ -128,6 +129,7 @@ def test_lstm_forecaster_fit_loader(self):
forecaster.evaluate_with_onnx(test_loader, batch_size=32, quantize=True)

@skip_onnxrt
@pytest.mark.onnxrt16
def test_lstm_forecaster_onnx_methods(self):
train_data, val_data, test_data = create_data()
forecaster = LSTMForecaster(past_seq_len=24,
Expand Down Expand Up @@ -205,6 +207,7 @@ def test_lstm_forecaster_quantization(self):
np.testing.assert_almost_equal(test_pred_save_q, test_pred_load_q)

@skip_onnxrt
@pytest.mark.onnxrt16
def test_lstm_forecaster_quantization_onnx(self):
train_data, val_data, test_data = create_data()
forecaster = LSTMForecaster(past_seq_len=24,
Expand All @@ -219,6 +222,7 @@ def test_lstm_forecaster_quantization_onnx(self):
eval_q = forecaster.evaluate_with_onnx(test_data, quantize=True)

@skip_onnxrt
@pytest.mark.onnxrt16
def test_lstm_forecaster_quantization_onnx_tuning(self):
train_data, val_data, test_data = create_data()
forecaster = LSTMForecaster(past_seq_len=24,
Expand Down Expand Up @@ -308,6 +312,7 @@ def transform_to_dict_x(data):
stop_orca_context()

@skip_onnxrt
@pytest.mark.onnxrt16
def test_lstm_forecaster_distributed(self):
from bigdl.orca import init_orca_context, stop_orca_context
train_data, val_data, test_data = create_data()
Expand Down Expand Up @@ -448,6 +453,7 @@ def test_forecaster_from_tsdataset(self):
assert yhat.shape == y_test.shape

@skip_onnxrt
@pytest.mark.onnxrt16
def test_forecaster_from_tsdataset_data_loader_onnx(self):
train, test = create_tsdataset(roll=False)
train.gen_dt_feature(one_hot_features=['WEEK'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def test_nbeats_forecaster_fit_pred_eva(self):
assert eva[0].shape == test_data[1].shape[1:]

@skip_onnxrt
@pytest.mark.onnxrt16
def test_nbeats_forecaster_fit_loader(self):
train_loader, val_loader, test_loader = create_data(loader=True)
forecaster = NBeatsForecaster(past_seq_len=24,
Expand All @@ -123,6 +124,7 @@ def test_nbeats_forecaster_fit_loader(self):
forecaster.evaluate_with_onnx(test_loader, batch_size=32, quantize=True)

@skip_onnxrt
@pytest.mark.onnxrt16
def test_nbeats_forecaster_onnx_methods(self):
train_data, val_data, test_data = create_data()
forecaster = NBeatsForecaster(past_seq_len=24,
Expand Down Expand Up @@ -199,6 +201,7 @@ def test_nbeats_forecaster_quantization_tuning(self):
np.testing.assert_almost_equal(test_pred_save_q, test_pred_load_q)

@skip_onnxrt
@pytest.mark.onnxrt16
def test_nbeats_forecaster_quantization_onnx(self):
train_data, val_data, test_data = create_data()
forecaster = NBeatsForecaster(past_seq_len=24,
Expand All @@ -212,6 +215,7 @@ def test_nbeats_forecaster_quantization_onnx(self):
eval_q = forecaster.evaluate_with_onnx(test_data, quantize=True)

@skip_onnxrt
@pytest.mark.onnxrt16
def test_nbeats_forecaster_quantization_onnx_tuning(self):
train_data, val_data, test_data = create_data()
forecaster = NBeatsForecaster(past_seq_len=24,
Expand Down Expand Up @@ -289,6 +293,7 @@ def transform_to_dict_x(data):
stop_orca_context()

@skip_onnxrt
@pytest.mark.onnxrt16
def test_nbeats_forecaster_distributed(self):
train_data, val_data, test_data = create_data()
_train_loader, _, _test_loader = create_data(loader=True)
Expand Down Expand Up @@ -434,6 +439,7 @@ def test_forecaster_from_tsdataset(self):
assert yhat.shape == y_test.shape

@skip_onnxrt
@pytest.mark.onnxrt16
def test_forecaster_from_tsdataset_data_loader_onnx(self):
train, test = create_tsdataset(roll=False)
loader = train.to_torch_data_loader(roll=True,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def test_s2s_forecaster_fit_eva_pred(self):
assert test_mse[0].shape == test_data[1].shape[1:]

@skip_onnxrt
@pytest.mark.onnxrt16
def test_s2s_forecaster_fit_loader(self):
train_loader, val_loader, test_loader = create_data(loader=True)
forecaster = Seq2SeqForecaster(past_seq_len=24,
Expand All @@ -120,6 +121,7 @@ def test_s2s_forecaster_fit_loader(self):


@skip_onnxrt
@pytest.mark.onnxrt16
def test_s2s_forecaster_onnx_methods(self):
train_data, val_data, test_data = create_data()
forecaster = Seq2SeqForecaster(past_seq_len=24,
Expand Down Expand Up @@ -250,6 +252,7 @@ def transform_to_dict_x(data):
stop_orca_context()

@skip_onnxrt
@pytest.mark.onnxrt16
def test_s2s_forecaster_distributed(self):
from bigdl.orca import init_orca_context, stop_orca_context
train_data, val_data, test_data = create_data()
Expand Down Expand Up @@ -391,6 +394,7 @@ def test_forecaster_from_tsdataset(self):
assert yhat.shape == y_test.shape

@skip_onnxrt
@pytest.mark.onnxrt16
def test_forecaster_from_tsdataset_data_loader_onnx(self):
train, test = create_tsdataset(roll=False)
train.gen_dt_feature(one_hot_features=['WEEK'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def test_tcn_forecaster_fit_eva_pred(self):
assert test_mse[0].shape == test_data[1].shape[1:]

@skip_onnxrt
@pytest.mark.onnxrt16
def test_tcn_forecaster_fit_loader(self):
train_loader, val_loader, test_loader = create_data(loader=True)
forecaster = TCNForecaster(past_seq_len=24,
Expand Down Expand Up @@ -149,6 +150,7 @@ def test_tcn_forecaster_tune(self):
assert train_loss > 10

@skip_onnxrt
@pytest.mark.onnxrt16
def test_tcn_forecaster_onnx_methods(self):
train_data, val_data, test_data = create_data()
forecaster = TCNForecaster(past_seq_len=24,
Expand Down Expand Up @@ -250,6 +252,7 @@ def test_tcn_forecaster_quantization(self):
np.testing.assert_almost_equal(test_pred_save_q, test_pred_load_q)

@skip_onnxrt
@pytest.mark.onnxrt16
def test_tcn_forecaster_quantization_onnx(self):
train_data, val_data, test_data = create_data()
forecaster = TCNForecaster(past_seq_len=24,
Expand All @@ -266,6 +269,7 @@ def test_tcn_forecaster_quantization_onnx(self):
eval_q = forecaster.evaluate_with_onnx(test_data, quantize=True)

@skip_onnxrt
@pytest.mark.onnxrt16
def test_tcn_forecaster_quantization_onnx_tuning(self):
train_data, val_data, test_data = create_data()
forecaster = TCNForecaster(past_seq_len=24,
Expand Down Expand Up @@ -362,6 +366,7 @@ def transform_to_dict_x(data):
stop_orca_context()

@skip_onnxrt
@pytest.mark.onnxrt16
def test_tcn_forecaster_distributed(self):
from bigdl.orca import init_orca_context, stop_orca_context
train_data, val_data, test_data = create_data()
Expand Down Expand Up @@ -506,6 +511,7 @@ def test_forecaster_from_tsdataset(self):
assert yhat.shape == y_test.shape

@skip_onnxrt
@pytest.mark.onnxrt16
def test_forecaster_from_tsdataset_data_loader_onnx(self):
train, test = create_tsdataset(roll=False)
train.gen_dt_feature(one_hot_features=['WEEK'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@


@pytest.mark.skipif(tf.__version__ > '2.0.0', reason="Run only when tf==1.15.0.")
@pytest.mark.tf1
class TestSeq2Seq(ZooTestCase):

def setup_method(self, method):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def get_x_y(num_samples):
return train_data, val_data, test_data

@pytest.mark.skipif(tf.__version__ > '2.0.0', reason="Run only when tf==1.15.0.")
@pytest.mark.tf1
class TestVanillaLSTM(TestCase):
train_data, val_data, test_data = create_data()
model = VanillaLSTM()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def get_data(num_samples):


@pytest.mark.skipif(tf.__version__ > '2.0.0', reason="Run only when tf==1.15.0.")
@pytest.mark.tf1
class TestMTNetKeras(ZooTestCase):

def setup_method(self, method):
Expand Down

0 comments on commit 6349247

Please sign in to comment.