Repository navigation
Fix config path handling. Use absolute paths for scheduled tasks. - #46
Conversation
…g directory might not be the same as for the script that created the task.
There was a problem hiding this comment.
Pull request overview
This PR standardizes configuration file handling across the wizard, config loader, and scheduler, and improves scheduled task reliability by using an explicit (resolved) config path and invoking the package via python -m jira_backup so jobs don’t depend on the current working directory.
Changes:
- Default config path is now
config.yaml, passed explicitly through wizard/config loading/scheduling. - Scheduled tasks now run
python -m jira_backup ... -C <resolved config path>(cron + Windows Task Scheduler). - Config loading switches to
yaml.safe_load.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/jira_backup/_wizard.py |
Wizard now writes to a caller-provided Path instead of a hard-coded module-relative path. |
src/jira_backup/_config.py |
Config loader now takes an explicit Path and uses yaml.safe_load. |
src/jira_backup/_backup.py |
CLI default config path updated; scheduling now uses python -m jira_backup and passes resolved config path. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def read_config(*, config_path: Path) -> Config: | ||
| # TODO: Validate the loaded config before returning. | ||
| return yaml.safe_load(config_path.read_text()) # type: ignore[no-any-return] |
There was a problem hiding this comment.
I plan to introduce proper validation using Pydantic 2.x in another PR soon.
| service_flag = "-j" if service_type == "jira" else "-c" | ||
|
|
||
| cron_command = f"{time_minute} {time_hour} */{frequency_days} * * cd {script_dir} && {python_path} {script_path} {service_flag}" | ||
| backup_command = shlex.join( | ||
| [ | ||
| sys.executable, | ||
| "-m", | ||
| "jira_backup", | ||
| service_flag, | ||
| "-C", | ||
| config_path.as_posix(), | ||
| ] | ||
| ) | ||
| cron_command = f"{time_minute} {time_hour} */{frequency_days} * * {backup_command}" |
There was a problem hiding this comment.
This is a deliberate change. We should not depend on the working directory at all, since the module can be installed pretty much anywhere.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
__file__).config.yamlfrom the current working directory.python -m jira_backup ... -C <resolved config path>, so they work from any working directory.yaml.safe_load.