Skip to content

Commit 8f2d7a9

Browse files
The Mavikharitamar
andauthored
fix: wire --config-dir CLI flag to Config initialization (#2121)
Fixes #2037 The --config-dir flag was parsed but never passed to Config(), which always used the default ~/.edr. This wires the CLI argument through so the custom config directory is actually used. - Remove premature directory creation from Config._load_configuration that ran at import time (logo/upgrade) and created ~/.edr before CLI parsing - Create config_dir in anonymous_tracking when writing user id file - Add --config-dir to debug and dbt_init commands for consistency - Use keyword args for Config() in report command for clarity Co-authored-by: Itamar Hartstein <haritamar@gmail.com>
1 parent 780b2d9 commit 8f2d7a9

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

elementary/config/config.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,6 @@ def __init__(
224224
)
225225

226226
def _load_configuration(self) -> dict:
227-
if not os.path.exists(self.config_dir):
228-
os.makedirs(self.config_dir)
229227
config_file_path = os.path.join(self.config_dir, self._CONFIG_FILE_NAME)
230228
if not os.path.exists(config_file_path):
231229
return {}

elementary/tracking/anonymous_tracking.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def __init__(self, config: Config) -> None:
2424
self._run_id = str(uuid.uuid4())
2525

2626
# Exceptions that occurred during the run of the CLI, but don't fail the entire run.
27-
# We want to avoid sending an event for each one of these (as there might be many of them), so we will send
27+
# We want to avoid sending an event for each one of these (as there might be many), so we will send
2828
# them as a part of the cli-end event.
2929
self.internal_exceptions: List[dict] = []
3030
self.internal_exceptions_count = 0
@@ -49,6 +49,7 @@ def _get_anonymous_user_id(self):
4949
pass
5050
user_id = str(uuid.uuid4())
5151
try:
52+
user_id_path.parent.mkdir(parents=True, exist_ok=True)
5253
user_id_path.write_text(user_id)
5354
except OSError:
5455
pass
@@ -74,7 +75,7 @@ def _send_anonymous_event(
7475
},
7576
)
7677
except Exception:
77-
logger.debug("Unable to send tracking event.", exc_info=True)
78+
logger.debug("Unable to send anonymous event.", exc_info=True)
7879

7980
def record_internal_exception(self, exc: Exception):
8081
self.internal_exceptions_count += 1

0 commit comments

Comments
 (0)