You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Exception thrown including environment if installed via pip #14
I hit this today, will try come up with a patch for this, but if you install this package into a system folder via pip (which I do when using docker) you can't import environment.py (or things that import that), as you get an exception:
>>> import biomassrecovery.utils.unzip
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.10/dist-packages/biomassrecovery/utils/unzip.py", line 10, in <module>
from biomassrecovery.utils import logging_util
File "/usr/local/lib/python3.10/dist-packages/biomassrecovery/utils/logging_util.py", line 7, in <module>
from biomassrecovery.environment import DEFAULT_FORMATTER, DEFAULT_LOG_FILE, DEFAULT_LOG_LEVEL
File "/usr/local/lib/python3.10/dist-packages/biomassrecovery/environment.py", line 20, in <module>
LOG_PATH.mkdir(parents=True, exist_ok=True)
File "/usr/lib/python3.10/pathlib.py", line 1175, in mkdir
self._accessor.mkdir(self, mode)
OSError: [Errno 30] Read-only file system: '/usr/local/lib/python3.10/dist-packages/logs'
In environment.py the LOG_PATH is created (which feels wrong if this code is to be a library, side effects on import considered harmful? but I appreciate the common case isn't to use this as a library). But the path is relative to the module, specifically the module's parent path, hence the path in the last line there.
Unfortunately unlike other things in environment, you can't override this, so this stops us using it outside a python virtualenv.
For now I guess the plan would be to make this path overridable by and environmental variable. Ideally we'd not try create it or at least not fail like this if we can't, but that's a longer term question for you @ameliaholcomb in terms of burdening users with explicit setup.
Ah, I hate all the custom log stuff in this code, so many regrets.
I agree side effects considered harmful, and better to use all default logging style anyway.
Activity
ameliaholcomb commentedon Feb 9, 2024
Ah, I hate all the custom log stuff in this code, so many regrets.
I agree side effects considered harmful, and better to use all default logging style anyway.