fix deser python operation error

This commit is contained in:
zetongzhao 2021-09-20 13:50:10 -04:00
parent d2df9652ca
commit a0c203df23
2 changed files with 6 additions and 4 deletions

View File

@ -234,7 +234,7 @@ Status Serdes::ConstructTensorOps(nlohmann::json json_obj, std::vector<std::shar
std::vector<std::shared_ptr<TensorOperation>> output;
for (nlohmann::json item : json_obj) {
if (item.find("python_module") != item.end()) {
if (Py_IsInitialized()) {
if (Py_IsInitialized() != 0) {
RETURN_IF_NOT_OK(PyFuncOp::from_json(item, result));
} else {
RETURN_STATUS_SYNTAX_ERROR("Python module is not initialized or Pyfunction is not supported on this platform.");

View File

@ -530,7 +530,9 @@ TEST_F(MindDataTestDeserialize, TestDeserializeConcatAlbumFlickr) {
TEST_F(MindDataTestDeserialize, TestDeserializePyFunc) {
MS_LOG(INFO) << "Doing MindDataTestDeserialize-PyFunc.";
std::shared_ptr<DatasetNode> ds1;
ASSERT_OK(Serdes::Deserialize("./data/dataset/tf_file_dataset/pyvision_dataset_pipeline.json", &ds1));
EXPECT_NE(ds1, nullptr);
if (Py_IsInitialized() != 0) {
std::shared_ptr<DatasetNode> ds1;
ASSERT_OK(Serdes::Deserialize("./data/dataset/tf_file_dataset/pyvision_dataset_pipeline.json", &ds1));
EXPECT_NE(ds1, nullptr);
}
}