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

python -c 'from fedmsg.config import load_config' crashes depending on your current working directory #410

Open
jeremycline opened this issue May 18, 2017 · 2 comments

Comments

@jeremycline
Copy link
Member

From the fmn development environment, inside ~/.fedmsg.d/:

(fmn) [vagrant@fmn-dev .fedmsg.d]$ python -c 'from fedmsg.config import load_config'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/vagrant/.virtualenvs/fmn/lib/python2.7/site-packages/fedmsg/__init__.py", line 25, in <module>
    import fedmsg.core
  File "/home/vagrant/.virtualenvs/fmn/lib/python2.7/site-packages/fedmsg/core.py", line 35, in <module>
    import fedmsg.encoding
  File "/home/vagrant/.virtualenvs/fmn/lib/python2.7/site-packages/fedmsg/encoding/__init__.py", line 46, in <module>
    import sqlalchemy
  File "/home/vagrant/.virtualenvs/fmn/lib/python2.7/site-packages/sqlalchemy/__init__.py", line 9, in <module>
    from .sql import (
  File "/home/vagrant/.virtualenvs/fmn/lib/python2.7/site-packages/sqlalchemy/sql/__init__.py", line 98, in <module>
    __go(locals())
  File "/home/vagrant/.virtualenvs/fmn/lib/python2.7/site-packages/sqlalchemy/sql/__init__.py", line 96, in __go
    from . import naming
  File "/home/vagrant/.virtualenvs/fmn/lib/python2.7/site-packages/sqlalchemy/sql/naming.py", line 15, in <module>
    from .. import event, events
  File "/home/vagrant/.virtualenvs/fmn/lib/python2.7/site-packages/sqlalchemy/events.py", line 11, in <module>
    from .pool import Pool
  File "/home/vagrant/.virtualenvs/fmn/lib/python2.7/site-packages/sqlalchemy/pool.py", line 24, in <module>
    from . import exc, log, event, interfaces, util
  File "/home/vagrant/.virtualenvs/fmn/lib/python2.7/site-packages/sqlalchemy/log.py", line 27, in <module>
    rootlogger = logging.getLogger('sqlalchemy')
AttributeError: 'module' object has no attribute 'getLogger'

I would expect this to not crash, especially given it's just an import.

@QuLogic
Copy link

QuLogic commented Jun 8, 2017

The fedmsg-base package contains /etc/fedmsg.d/logging.py; I assume that your ~/.fedmsg.d/ also contains logging.py. The current directory is on the search path; that's just how Python works. If you want to fix it, you're going to have to break all configs and rename that file to something that doesn't conflict with the standard library.

@jeremycline
Copy link
Member Author

Thanks for looking into the root cause of this, I was in a hurry when I filed it and never got around to investigating.

Personally I really dislike the current configuration approach. I think it's way more complicated than it should be and I really want to redo it. Things I'd like include:

  • A non-Python configuration format. Options include TOML, YAML, or INI. I personally would prefer TOML.

  • Simplify where the configuration is loaded from and make it very clear where configuration was picked up from. Support loading from /etc/fedmsg/config.toml, ~/.config/fedmsg/config.toml, or from a file specified in the command line interface.

  • I'm not crazy about layering configs on top of configs on top of configs so I'd like to get rid of that, too.

  • Very clearly document all the configuration settings.

  • A nice config module that lazy-loads the configuration as a singleton object that other modules just import.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants