Skip to content

Commit 19dc6ea

Browse files
authored
(Re-land) Update ray to 2.7.2 (#2791)
To address numerous CVE that older Ray releases were affected by see https://www.anyscale.com/blog/update-on-ray-cves-cve-2023-6019-cve-2023-6020-cve-2023-6021-cve-2023-48022-cve-2023-48023 Use legacy APIs by setting RAY_AIR_NEW_PERSISTENCE_MODE environment variable to zero. Move logic of adding fake properties to `sys.stdout` from `main` to top level imports, as `ray.tune` will expect `sys.stdout` to have an `encoding`, which is missing in sphinx Please note, that this increases tutorial runtime from 4 to 10 min
1 parent abe11e2 commit 19dc6ea

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

beginner_source/hyperparameter_tuning_tutorial.py

+11-7
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,21 @@
4848
from torch.utils.data import random_split
4949
import torchvision
5050
import torchvision.transforms as transforms
51+
# sphinx_gallery_start_ignore
52+
# Fixes ``AttributeError: '_LoggingTee' object has no attribute 'fileno'``.
53+
# This is only needed to run with sphinx-build.
54+
import sys
55+
if not hasattr(sys.stdout, "encoding"):
56+
sys.stdout.encoding = "latin1"
57+
sys.stdout.fileno = lambda: 0
58+
# sphinx_gallery_end_ignore
5159
from ray import tune
5260
from ray.air import Checkpoint, session
5361
from ray.tune.schedulers import ASHAScheduler
5462

63+
# TODO: Migrate to ray.train.Checkpoint and remove following line
64+
os.environ["RAY_AIR_NEW_PERSISTENCE_MODE"]="0"
65+
5566
######################################################################
5667
# Most of the imports are needed for building the PyTorch model. Only the last three
5768
# imports are for Ray Tune.
@@ -448,13 +459,6 @@ def main(num_samples=10, max_num_epochs=10, gpus_per_trial=2):
448459

449460

450461
if __name__ == "__main__":
451-
# sphinx_gallery_start_ignore
452-
# Fixes ``AttributeError: '_LoggingTee' object has no attribute 'fileno'``.
453-
# This is only needed to run with sphinx-build.
454-
import sys
455-
456-
sys.stdout.fileno = lambda: False
457-
# sphinx_gallery_end_ignore
458462
# You can change the number of GPUs per trial here:
459463
main(num_samples=10, max_num_epochs=10, gpus_per_trial=0)
460464

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ bs4
2020
awscliv2==2.1.1
2121
flask
2222
spacy==3.4.1
23-
ray[tune]==2.4.0
23+
ray[tune]==2.7.2
2424
tensorboard
2525
jinja2==3.1.3
2626
pytorch-lightning

0 commit comments

Comments
 (0)