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

try ... catch can break telemetry #24

Open
edublancas opened this issue Dec 24, 2022 · 2 comments
Open

try ... catch can break telemetry #24

edublancas opened this issue Dec 24, 2022 · 2 comments

Comments

@edublancas
Copy link
Contributor

edublancas commented Dec 24, 2022

there is a try catch statement at the end of this file

I'm assuming the purpose is to initialize the configuration at import time to prevent race conditions. However, if this fails, this will cause the internal not to exist; hence, all the calls to it will fail.

I'm still trying to figure out what the best solution here is.

I think we could have some initialization logic and if this fails, make the telemetry module do not work (make the calls do nothing). Example:

class Telemetry:
    def __init__(...):
         # if initialization went wrong, set some variable that makes all methods do nothing...
@yafimvo
Copy link
Collaborator

yafimvo commented Dec 25, 2022

This was a fast fix for AWS. Since AWS doesn't allow writing out of the tmp folder, this initialization failed with this error

[ERROR] OSError: [Errno 30] Read-only file system: '/home/sbx_user1051'
Traceback (most recent call last):
  File "/var/lang/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/var/task/app.py", line 8, in <module>
    from ploombertools.execute import execute
  File "/var/task/ploombertools/execute/execute.py", line 44, in <module>
    import k2s
  File "/var/task/k2s/__init__.py", line 1, in <module>
    from k2s.parse import bootstrap_env
  File "/var/task/k2s/parse.py", line 12, in <module>
    from k2s.env import install
  File "/var/task/k2s/env.py", line 4, in <module>
    from k2s.conda import CondaManager
  File "/var/task/k2s/conda.py", line 10, in <module>
    from ploomber_core.telemetry.telemetry import Telemetry
  File "/var/task/ploomber_core/telemetry/telemetry.py", line 573, in <module>
    internal = Internal()
  File "/var/task/ploomber_core/config.py", line 18, in __init__
    self._init_values()
  File "/var/task/ploomber_core/config.py", line 96, in _init_values
    value = getattr(self, name)()
  File "/var/task/ploomber_core/telemetry/telemetry.py", line 86, in uid_default
    config = self.load_config()
  File "/var/task/ploomber_core/config.py", line 117, in load_config
    path = self.path()
  File "/var/task/ploomber_core/telemetry/telemetry.py", line 83, in path
    return Path(check_dir_exist(CONF_DIR), DEFAULT_PLOOMBER_CONF)
  File "/var/task/ploomber_core/telemetry/telemetry.py", line 269, in check_dir_exist
    p.mkdir(parents=True)
  File "/var/lang/lib/python3.9/pathlib.py", line 1327, in mkdir
    self.parent.mkdir(parents=True, exist_ok=True)
  File "/var/lang/lib/python3.9/pathlib.py", line 1327, in mkdir
    self.parent.mkdir(parents=True, exist_ok=True)
  File "/var/lang/lib/python3.9/pathlib.py", line 1323, in mkdir
    self._accessor.mkdir(self, mode)

@edublancas
Copy link
Contributor Author

yeah, makes sense. Let's work on a long-term solution. Not urgent, so let's tackle it next week.

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