Skip to content
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

Orca: fix np 1.24 type deprecations #7591

Merged
merged 13 commits into from
Feb 22, 2023

Conversation

hamham223
Copy link
Contributor

@hamham223 hamham223 commented Feb 16, 2023

Description

1. Why the change?

See #7548

3. Summary of the change

fix numpy deprecations:

  • np.int -> np.int32
  • np.float -> np.float32
  • np.str -> str

4. How to test?

The following Orca unit test:

  • Orca-Pytest-Ray-Py38-Spark3
  • Orca-Pytest-Tf1-Py38-Spark3

@@ -45,7 +45,8 @@ python -m pytest -v test/bigdl/orca/learn/ray \
--ignore=test/bigdl/orca/learn/ray/pytorch/test_estimator_horovod_backend.py \
--ignore=test/bigdl/orca/learn/ray/pytorch/test_estimator_ray_runtime.py \
--ignore=test/bigdl/orca/learn/ray/pytorch/test_estimator_ray_dataset.py \
--ignore=test/bigdl/orca/learn/ray/tf/
--ignore=test/bigdl/orca/learn/ray/tf/ \
--ignore=test/bigdl/orca/learn/ray/mxnet/
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WIP: need to add mxnet elsewhere

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refer to other jobs to add if condition for py37; we can only run mxnet for py37

@@ -94,7 +94,7 @@ def group_index(iter):
def transform_predict(predictions):
# list of np array
if isinstance(predictions[0], list):
predictions = np.array(predictions).T.tolist()
predictions = np.array(predictions, dtype=object).T.tolist()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

np 1.24 requires array to have homogenous shape

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not correct to be here; we can't treat everything to be object.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

python 3.7 test already gives the warning:

/home/yinchen/BigDL/python/orca/src/bigdl/orca/learn/utils.py:97: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.
  predictions = np.array(predictions).T.tolist()

Command

cd python/orca
python -m pytest --show-capture=all --full-trace -r P -v test/bigdl/orca/learn/test_utils.py::TestUtil::test_convert_predict_rdd_to_xshard_multi_output

Copy link
Contributor

@hkvision hkvision Feb 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sgwhat We can fix this issue by avoiding directly setting all predictions to np?

predictions = np.array(predictions).T.tolist()

@hamham223 hamham223 changed the title Orca: fix np 1.24+ deprecations Orca: fix np 1.24 type deprecations Feb 17, 2023
@@ -94,7 +94,7 @@ def group_index(iter):
def transform_predict(predictions):
# list of np array
if isinstance(predictions[0], list):
predictions = np.array(predictions).T.tolist()
predictions = [[item[i] for item in predictions] for i in range(len(predictions[0]))]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will predictions return as shape [[1, 2, 3], [4, 5, 6], [7, 8]] ?

Copy link
Contributor Author

@hamham223 hamham223 Feb 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before running Line 97:
predictions = [[[1, 1], [1, 1, 1]], [[2, 2], [2, 2, 2]]]
After Line 97:
predictions = [[[1, 1], [2, 2]], [[1, 1, 1], [2, 2, 2]]]

Test scripts: https://github.com/intel-analytics/BigDL/blob/main/python/orca/test/bigdl/orca/learn/test_utils.py#L97

@hkvision
Copy link
Contributor

Merge this first, one ray ctx job is irrelevant.

@hkvision hkvision merged commit 7bd93ea into intel-analytics:main Feb 22, 2023
@hamham223 hamham223 deleted the fix-np-deprecated branch February 22, 2023 04:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants