def test_save_load_oss(self): bucket = oss.get_models_bucket() meta = {"model_params": {"n_classes": 3}} m = Model(EstimatorType.XGBOOST, meta) oss_dir = "unknown/model_test_dnn_classifier/" oss_model_path = "oss://%s/%s" % (bucket.bucket_name, oss_dir) oss.delete_oss_dir_recursive(bucket, oss_dir) # save model def save_to_oss(): with temp_file.TemporaryDirectory() as d: m.save_to_oss(oss_model_path, d) # load model def load_from_oss(): with temp_file.TemporaryDirectory() as d: return Model.load_from_oss(oss_model_path, d) with self.assertRaises(Exception): load_from_oss() save_to_oss() m = load_from_oss() self.assertEqual(m._meta, meta)
def clean_oss_model_path(oss_path): bucket = oss.get_models_bucket() oss.delete_oss_dir_recursive(bucket, oss_path)