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

creating Config without path raises unhandled TypeError #197

Closed
btel opened this issue Dec 1, 2020 · 3 comments · Fixed by #214
Closed

creating Config without path raises unhandled TypeError #197

btel opened this issue Dec 1, 2020 · 3 comments · Fixed by #214

Comments

@btel
Copy link
Collaborator

btel commented Dec 1, 2020

this only happens if QUETZ_CONFIG_FILE is not defined

import os; os.listdir()
from quetz import config
config.Config()

gives this error

['channels', 'quetz.sqlite', 'quetz.log', 'config.toml']

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/bartosz/repos/libraries/mamba-org/quetz/quetz/config.py", line 140, in __new__
    path = os.path.abspath(cls.find_file(deployment_config))
  File "/home/bartosz/.pyenv/versions/micromamba/envs/quetz/lib/python3.8/posixpath.py", line 374, in abspath
    path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not NoneType

but this works:

>>> os.environ['QUETZ_CONFIG_FILE'] = 'config.toml'
>>> config.Config()
<quetz.config.Config object at 0x7f8885b89610>

What needs to be done

catch the exception and ask user to provide the name or path of config file using env var

Remarks

quetz run/start configures the QUETZ_CONFIG_FILE automatically

@madhur-tandon
Copy link
Member

Should we put the call to config.Config() in a try block in all places?
Ideally this should be done only once right? And then propagated to all other places where it's needed.

@btel
Copy link
Collaborator Author

btel commented Dec 3, 2020

no it should be done in Config class, about here:

File "/home/bartosz/repos/libraries/mamba-org/quetz/quetz/config.py", line 140, in __new__
    path = os.path.abspath(cls.find_file(deployment_config))

@madhur-tandon
Copy link
Member

yeah, thanks. This is exactly what I meant by doing it at one place - which is propagated to everywhere we call Config().
I am picking this up. Will send a PR soon.

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

Successfully merging a pull request may close this issue.

2 participants