Skip to content

Fix config path handling. Use absolute paths for scheduled tasks. - #46

Merged
eyarz merged 3 commits into
datreeio:masterfrom
rudolfbyker:dev/fix-paths
Jun 23, 2026
Merged

eyarz merged 3 commits into
datreeio:masterfrom
rudolfbyker:dev/fix-paths

Conversation

@rudolfbyker

@rudolfbyker rudolfbyker commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor
  • No longer rely on the position of the library code in the file system (i.e., no more __file__).
  • Default config path is now the config.yaml from the current working directory.
  • Wizard, config loading, and scheduling all use the same explicit config path.
  • Scheduled tasks now run python -m jira_backup ... -C <resolved config path>, so they work from any working directory.
  • Config loading now uses yaml.safe_load.

…g directory might not be the same as for the script that created the task.
Copilot AI review requested due to automatic review settings June 19, 2026 14:35
@rudolfbyker
rudolfbyker requested a review from eyarz as a code owner June 19, 2026 14:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +49 to +51
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]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I plan to introduce proper validation using Pydantic 2.x in another PR soon.

Comment thread src/jira_backup/_backup.py
Comment on lines 341 to +352
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}"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a deliberate change. We should not depend on the working directory at all, since the module can be installed pretty much anywhere.

Comment thread src/jira_backup/_wizard.py Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@eyarz
eyarz merged commit 8bc9783 into datreeio:master Jun 23, 2026
4 checks passed
@rudolfbyker
rudolfbyker deleted the dev/fix-paths branch June 25, 2026 20:58
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 this pull request may close these issues.

3 participants