ray
ray copied to clipboard
TypeError: Descriptors cannot not be created directly.
I was running your example code after upgrading to ray 2.5.0, but now I get the following error.
TypeError: Descriptors cannot not be created directly. If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0. If you cannot immediately regenerate your protos, some other possible workarounds are:
- Downgrade the protobuf package to 3.20.x or lower.
- Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
I don't understand why I have to downgrade protobuf ti much older versions. Any suggestion? This error disappear if I use older versions of Ray
Versions / Dependencies
ray = {extras = ["tune"], version = "^2.5.0"} python = "^3.10"
Reproduction script
from ray import tune
def objective(config): # ① score = config["a"] ** 2 + config["b"] return {"score": score}
search_space = { # ② "a": tune.grid_search([0.001, 0.01, 0.1, 1.0]), "b": tune.choice([1, 2, 3]), }
tuner = tune.Tuner(objective, param_space=search_space) # ③
results = tuner.fit() print(results.get_best_result(metric="score", mode="min").config)
Issue Severity
Medium: It is a significant difficulty but I can work around it.
Update: It seems that with new versions of proto every Ray version have the same problem.
Can you share the full stack trace? This might be due to other dependencies (perhaps getting pulled in as extras).
@FrancescoMandru do you still see this error with latest Ray?