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

make trial import lazy to avoid cyclic dependencies #316

Merged
merged 1 commit into from
Nov 12, 2019

Conversation

Delaunay
Copy link
Collaborator

Storage factory implicitly import backends when importing orion/storage/base which cause a cyclic dependency

Solution is to break the cycle by importing Trial lazily in the backends

Traceback (most recent call last):
  File "/home/setepenre/work/olympus/olympus/report/dashboard.py", line 13, in <module>
    from orion.storage.base import Storage
  File "/home/setepenre/work/orion/src/orion/storage/base.py", line 213, in <module>
    class Storage(BaseStorageProtocol, metaclass=SingletonFactory):
  File "/home/setepenre/work/orion/src/orion/core/utils/__init__.py", line 57, in __init__
    super(SingletonType, cls).__init__(name, bases, dictionary)
  File "/home/setepenre/work/orion/src/orion/core/utils/__init__.py", line 112, in __init__
    entry_point.load()
  File "/opt/anaconda3/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2443, in load
    return self.resolve()
  File "/opt/anaconda3/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2449, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/home/setepenre/work/orion/src/orion/storage/legacy.py", line 18, in <module>
    from orion.core.worker.trial import Trial
  File "/home/setepenre/work/orion/src/orion/core/worker/__init__.py", line 17, in <module>
    from orion.core.worker.consumer import Consumer
  File "/home/setepenre/work/orion/src/orion/core/worker/consumer.py", line 20, in <module>
    from orion.core.worker.trial_pacemaker import TrialPacemaker
  File "/home/setepenre/work/orion/src/orion/core/worker/trial_pacemaker.py", line 12, in <module>
    from orion.storage.base import get_storage
ImportError: cannot import name 'get_storage' from 'orion.storage.base' (/home/setepenre/work/orion/src/orion/storage/base.py

@Delaunay Delaunay merged commit ad1beb0 into develop Nov 12, 2019
@Delaunay Delaunay deleted the fix_extern_import branch November 12, 2019 05:37
@bouthilx bouthilx mentioned this pull request Jun 23, 2020
@bouthilx bouthilx mentioned this pull request Jun 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants