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

Fix recursion error upon assersion error #242

Merged
merged 1 commit into from
Jan 22, 2025

Conversation

nabenabe0928
Copy link
Contributor

@nabenabe0928 nabenabe0928 commented Jan 21, 2025

Contributor Agreements

Please read the contributor agreements and if you agree, please click the checkbox below.

  • I agree to the contributor agreements.

When we input an invalid set of arguments to the bbob family, we get the recursion error like this:

bbob function_id must be in [1, 24]
Exception ignored in: <function Problem.__del__ at 0x7fd73e0ddd00>
Traceback (most recent call last):
  File "/home/shuhei/pfn-work/optuna-dev/optunahub-registry/./package/benchmarks/bbob/_bbob.py", line 107, in __del__
    self._problem.free()
    ^^^^^^^^^^^^^
  File "/home/shuhei/pfn-work/optuna-dev/optunahub-registry/./package/benchmarks/bbob/_bbob.py", line 101, in __getattr__
    return getattr(self._problem, name)
                   ^^^^^^^^^^^^^
  File "/home/shuhei/pfn-work/optuna-dev/optunahub-registry/./package/benchmarks/bbob/_bbob.py", line 101, in __getattr__
    return getattr(self._problem, name)
                   ^^^^^^^^^^^^^
  File "/home/shuhei/pfn-work/optuna-dev/optunahub-registry/./package/benchmarks/bbob/_bbob.py", line 101, in __getattr__
    return getattr(self._problem, name)
                   ^^^^^^^^^^^^^
  [Previous line repeated 995 more times]
RecursionError: maximum recursion depth exceeded

However, this is not really friendly and can be confusing as well.
This PR aims to resolve this issue.
Here is a simple code to verify the new version:

import optuna
import optunahub


names = [
    "bbob", "bbob_biobj", "bbob_biobj_mixint", "bbob_constrained", "bbob_largescale", "bbob_mixint", "bbob_noisy"
]
for name in names:
    try:
        problem = optunahub.load_local_module(f"benchmarks/{name}", registry_root="./package").Problem(
            function_id=0, dimension=2, instance_id=1
        )
    except Exception as e:
        print(name, e)

@nabenabe0928 nabenabe0928 added the bug Something isn't working label Jan 21, 2025
Copy link
Member

@y0z y0z left a comment

Choose a reason for hiding this comment

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

LGTM

@y0z
Copy link
Member

y0z commented Jan 22, 2025

I've confirmed the change works.
image

@y0z y0z merged commit 2bc157f into optuna:main Jan 22, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants