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

[py312] Fix or skip tests+examples for Tune dependencies that do not support py312 #46761

Merged
merged 31 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
3c5ae23
upgrade comet-ml
justinvyu Jul 15, 2024
abf3fc2
remove tune-sklearn
justinvyu Jul 15, 2024
ef60ffe
skip hebo tests in >=py312
justinvyu Jul 15, 2024
f5cd5bc
remove aim usage in tests
justinvyu Jul 15, 2024
7105dfa
update bohb requirements
justinvyu Jul 15, 2024
fe80ba1
skip bohb tests
justinvyu Jul 15, 2024
6c0f0c9
reenable bohb example for py<312
justinvyu Jul 15, 2024
a632997
fix lint
justinvyu Jul 16, 2024
a35e78a
add failif fixture
justinvyu Jul 16, 2024
ec27ff3
update rich to satisfy comet-ml dep
justinvyu Jul 16, 2024
ba1a0b2
[TEMP] force jupytext version bump
justinvyu Jul 19, 2024
1a76370
update requirements compiled
justinvyu Jul 22, 2024
80aa4dd
skipif -> failif on py312 w/ reason
justinvyu Jul 22, 2024
54dfae2
failif back to skipif
justinvyu Jul 23, 2024
5402dec
remove hebo (p2 dep) since it enforces a np (p0 dep) version cap
justinvyu Jul 23, 2024
5fce55d
py312 has new stack trace formatting with more newlines
justinvyu Jul 23, 2024
bb1a201
fix keras callback test
justinvyu Jul 23, 2024
6cda64f
bump jupytext version
justinvyu Jul 23, 2024
6595b7d
fix req
justinvyu Jul 23, 2024
bd1f652
remove failif fixture
justinvyu Jul 23, 2024
487ec15
remove failif fixture 2
justinvyu Jul 23, 2024
2a6314f
fail -> skip for bohb
justinvyu Jul 23, 2024
844aa80
remove pip compile pipeline dep
justinvyu Jul 24, 2024
48c500e
update
justinvyu Jul 24, 2024
fa3f408
update compiled requirements
justinvyu Jul 24, 2024
00e4479
Merge branch 'master' of https://github.com/ray-project/ray into py31…
justinvyu Jul 24, 2024
f591825
add back ray unpin
justinvyu Jul 24, 2024
5da6cf6
update req compiled
justinvyu Jul 24, 2024
c06df76
Merge branch 'master' of https://github.com/ray-project/ray into py31…
justinvyu Jul 24, 2024
24cf931
Merge branch 'master' of https://github.com/ray-project/ray into py31…
justinvyu Jul 24, 2024
ac31d46
add back dep
justinvyu Jul 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .buildkite/others.rayci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
group: others
depends_on:
- oss-ci-base_build
- forge
- oss-ci-base_build
steps:
#build
- name: doctestbuild
Expand Down
5 changes: 2 additions & 3 deletions ci/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,8 @@ compile_pip_dependencies() {
"${WORKSPACE_DIR}/python/requirements/ml/tune-test-requirements.txt" \
"${WORKSPACE_DIR}/python/requirements/security-requirements.txt"

# Remove some pins from upstream dependencies:
# ray, xgboost-ray, lightgbm-ray, tune-sklearn
sed -i "/^ray==/d;/^xgboost-ray==/d;/^lightgbm-ray==/d;/^tune-sklearn==/d" "${WORKSPACE_DIR}/python/$TARGET"
# Remove some pins from upstream dependencies: ray
sed -i "/^ray==/d" "${WORKSPACE_DIR}/python/$TARGET"

# Delete local installation
sed -i "/@ file/d" "${WORKSPACE_DIR}/python/$TARGET"
Expand Down
1 change: 0 additions & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ def __init__(self, version: str):
"https://mvnrepository.com/artifact/*", # working but somehow not with linkcheck
# This should be fixed -- is temporal the successor of cadence? Do the examples need to be updated?
"https://github.com/serverlessworkflow/specification/blob/main/comparisons/comparison-cadence.md",
# TODO(richardliaw): The following probably needs to be fixed in the tune_sklearn package
"https://www.oracle.com/java/technologies/javase-jdk15-downloads.html", # forbidden for client
"https://speakerdeck.com/*", # forbidden for bots
r"https://huggingface.co/*", # seems to be flaky
Expand Down
2 changes: 2 additions & 0 deletions doc/source/tune/examples/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ py_test_run_all_notebooks(
"tune-xgboost.ipynb",
"pbt_transformers.ipynb", # Transformers uses legacy Tune APIs.
"horovod_simple.ipynb", # CI do not have Horovod
"tune-aim.ipynb", # CI does not have `aim`
"bohb_example.ipynb", # CI does not have bohb requirements
],
tags = [
"exclusive",
Expand Down
3 changes: 0 additions & 3 deletions python/ray/air/tests/test_air_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from ray.tune.callback import Callback
from ray.tune.experiment.experiment import Experiment
from ray.tune.logger import LoggerCallback
from ray.tune.logger.aim import AimLoggerCallback
from ray.tune.utils.callback import DEFAULT_CALLBACK_CLASSES


Expand Down Expand Up @@ -113,7 +112,6 @@ class _CustomCallback(Callback):
wandb.WandbLoggerCallback,
mlflow.MLflowLoggerCallback,
comet.CometLoggerCallback,
AimLoggerCallback,
_CustomLoggerCallback,
_CustomLoggerCallback,
_CustomCallback,
Expand Down Expand Up @@ -152,7 +150,6 @@ def test_tag_setup_mlflow(mock_record, monkeypatch):
"WandbLoggerCallback": 1,
"MLflowLoggerCallback": 1,
"CometLoggerCallback": 1,
"AimLoggerCallback": 1,
"CustomLoggerCallback": 2,
"CustomCallback": 1,
},
Expand Down
2 changes: 1 addition & 1 deletion python/ray/air/tests/test_keras_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def test_report_with_default_arguments(self, mock_report, model):
# simulates the end of an epoch, and asserts that a metric and checkpoint are
# reported.
callback = ReportCheckpointCallback()
callback.model = model
callback.set_model(model)

callback.on_epoch_end(0, {"loss": 0})

Expand Down
2 changes: 1 addition & 1 deletion python/ray/air/tests/test_tracebacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def failing(config):

tuner = Tuner(failing)
results = tuner.fit()
assert len(str(results[0].error).split("\n")) <= 12
assert len(str(results[0].error).split("\n")) <= 20
Copy link
Contributor

Choose a reason for hiding this comment

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

what happened here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

py312 adds a bunch of new lines + formatting to stack traces 😆



def test_traceback_trainer(ray_start_2_cpus):
Expand Down
7 changes: 7 additions & 0 deletions python/ray/tune/examples/bohb_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ def load_checkpoint(self, checkpoint_dir):


if __name__ == "__main__":
import sys

import pytest

if sys.version_info >= (3, 12):
pytest.skip("TuneBOHB is not compatible with Python 3.12")

ray.init(num_cpus=8)

config = {
Expand Down
6 changes: 4 additions & 2 deletions python/ray/tune/tests/test_convergence.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import math
import sys
import unittest

import numpy as np
Expand Down Expand Up @@ -79,6 +80,9 @@ def testConvergenceBayesOpt(self):
assert len(analysis.trials) < 50
assert math.isclose(analysis.best_config["x"], 0, abs_tol=1e-5)

@pytest.mark.skipif(
sys.version_info >= (3, 12), reason="HEBO doesn't support py312"
)
def testConvergenceHEBO(self):
from ray.tune.search.hebo import HEBOSearch

Expand Down Expand Up @@ -137,6 +141,4 @@ def testConvergenceZoopt(self):


if __name__ == "__main__":
import sys

sys.exit(pytest.main(["-v", __file__]))
3 changes: 3 additions & 0 deletions python/ray/tune/tests/test_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
import json
import os
import shutil
import sys
import tempfile
import unittest
from dataclasses import dataclass
from pathlib import Path
from typing import Optional

import numpy as np
import pytest

import ray
from ray.air.constants import (
Expand Down Expand Up @@ -295,6 +297,7 @@ def testBadTBX(self):
assert "INFO" in cm.output[0]


@pytest.mark.skipif(sys.version_info >= (3, 12), reason="Aim doesn't support py312")
class AimLoggerSuite(unittest.TestCase):
"""Test Aim integration."""

Expand Down
12 changes: 8 additions & 4 deletions python/ray/tune/tests/test_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
change your pytest running directory to ray/python/ray/tune/tests/
"""

import sys
import unittest
from collections import defaultdict
from unittest.mock import patch

import numpy as np
import pytest

import ray
import ray.tune.search.sample
Expand Down Expand Up @@ -768,6 +770,9 @@ def config_generator():

self._testTuneSampleAPI(config_generator(), ignore=ignore)

@pytest.mark.skipif(
sys.version_info >= (3, 12), reason="HEBO doesn't support py312"
)
def testConvertHEBO(self):
import torch
from hebo.design_space.design_space import DesignSpace
Expand Down Expand Up @@ -824,6 +829,9 @@ def testConvertHEBO(self):

# Mixed configs are not supported

@pytest.mark.skipif(
sys.version_info >= (3, 12), reason="HEBO doesn't support py312"
)
def testSampleBoundsHEBO(self):
from ray.tune.search.hebo import HEBOSearch

Expand Down Expand Up @@ -1864,8 +1872,4 @@ def set_search_properties(self, metric, mode, config):


if __name__ == "__main__":
import sys

import pytest

sys.exit(pytest.main(["-v", __file__] + sys.argv[1:]))
10 changes: 10 additions & 0 deletions python/ray/tune/tests/test_searchers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import contextlib
import os
import shutil
import sys
import tempfile
import unittest
from copy import deepcopy
Expand Down Expand Up @@ -162,6 +163,9 @@ def testBOHB(self):
)
self.assertCorrectExperimentOutput(out)

@pytest.mark.skipif(
sys.version_info >= (3, 12), reason="HEBO doesn't support py312"
)
def testHEBO(self):
if Version(pandas.__version__) >= Version("2.0.0"):
pytest.skip("HEBO does not support pandas>=2.0.0")
Expand Down Expand Up @@ -415,6 +419,9 @@ def dbr_space(trial):
with self.assertRaises(TypeError):
dbr_searcher.add_evaluated_point(point, 1.0)

@pytest.mark.skipif(
sys.version_info >= (3, 12), reason="HEBO doesn't support py312"
)
def testHEBO(self):
if Version(pandas.__version__) >= Version("2.0.0"):
pytest.skip("HEBO does not support pandas>=2.0.0")
Expand Down Expand Up @@ -541,6 +548,9 @@ def testBOHB(self):

assert "not_completed" in searcher.trial_to_params

@pytest.mark.skipif(
sys.version_info >= (3, 12), reason="HEBO doesn't support py312"
)
def testHEBO(self):
if Version(pandas.__version__) >= Version("2.0.0"):
pytest.skip("HEBO does not support pandas>=2.0.0")
Expand Down
6 changes: 6 additions & 0 deletions python/ray/tune/tests/test_trial_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,9 @@ def result(score, ts):
[t.status for t in trials], [Trial.PAUSED, Trial.PAUSED, Trial.PAUSED]
)

@pytest.mark.skipif(
sys.version_info >= (3, 12), reason="BOHB doesn't support py312"
)
def testNonstopBOHB(self):
from ray.tune.search.bohb import TuneBOHB

Expand Down Expand Up @@ -2551,6 +2554,9 @@ def testAnonymousMetricEndToEndFIFO(self):
def testAnonymousMetricEndToEndASHA(self):
self._testAnonymousMetricEndToEnd(AsyncHyperBandScheduler)

@pytest.mark.skipif(
sys.version_info >= (3, 12), reason="BOHB doesn't support py312"
)
def testAnonymousMetricEndToEndBOHB(self):
from ray.tune.search.bohb import TuneBOHB

Expand Down
7 changes: 4 additions & 3 deletions python/ray/tune/tests/test_tune_restore_warm_start.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# coding: utf-8
import os
import shutil
import sys
import tempfile
import unittest

import numpy as np
import pandas
import pytest
from hebo.design_space.design_space import DesignSpace as HEBODesignSpace
from hyperopt import hp
from nevergrad.optimization import optimizerlib
from packaging.version import Version
Expand Down Expand Up @@ -251,11 +251,14 @@ def cost(param):
return search_alg, cost


@pytest.mark.skipif(sys.version_info >= (3, 12), reason="HEBO doesn't support py312")
class HEBOWarmStartTest(AbstractWarmStartTest, unittest.TestCase):
def set_basic_conf(self):
if Version(pandas.__version__) >= Version("2.0.0"):
pytest.skip("HEBO does not support pandas>=2.0.0")

from hebo.design_space.design_space import DesignSpace as HEBODesignSpace

space_config = [
{"name": "width", "type": "num", "lb": 0, "ub": 20},
{"name": "height", "type": "num", "lb": -100, "ub": 100},
Expand Down Expand Up @@ -345,6 +348,4 @@ def get_scheduler(self):


if __name__ == "__main__":
import sys

sys.exit(pytest.main(["-v", __file__] + sys.argv[1:]))
2 changes: 1 addition & 1 deletion python/requirements/ml/core-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ML tracking integrations
comet-ml==3.31.9
comet-ml==3.44.1
mlflow==2.9.2
wandb==0.17.0

Expand Down
2 changes: 1 addition & 1 deletion python/requirements/ml/rllib-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ imageio-ffmpeg==0.4.5
onnx==1.15.0; sys_platform != 'darwin' or platform_machine != 'arm64'
onnxruntime==1.18.0; sys_platform != 'darwin' or platform_machine != 'arm64'
tf2onnx==1.15.1; sys_platform != 'darwin' or platform_machine != 'arm64'
rich==12.6.0
rich==13.3.2
# Msgpack checkpoint stuff.
msgpack
msgpack_numpy
6 changes: 2 additions & 4 deletions python/requirements/ml/tune-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ ax-platform[mysql]==0.3.2
bayesian-optimization==1.4.3

# BOHB
ConfigSpace==0.7.1
hpbandster==0.7.4
ConfigSpace==0.7.1; python_version < "3.12"
hpbandster==0.7.4; python_version < "3.12"

hyperopt==0.2.7
nevergrad==0.4.3.post7
optuna==3.2.0

tune-sklearn==0.4.6; python_version < "3.12"
4 changes: 2 additions & 2 deletions python/requirements/test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ colorama
myst-parser==1.0.0
myst-nb==1.1.0
sphinx==6.2.1
jupytext==1.13.6
jupytext>1.13.6
jinja2==3.1.2
pytest-docker-tools==3.1.3
pytest-forked==1.4.0
Expand All @@ -97,7 +97,7 @@ tensorboardX
tensorboard
tensorboard-data-server==0.7.2
h11==0.12.0
markdown-it-py==1.1.0
markdown-it-py
attrs==21.4.0
pytz==2022.7.1
# Compatibility with spacy 3.5 (model en_core_web_sm)
Expand Down
Loading