Skip to content

swagger.json file should be saved to user's local config dir, not next to the code#119

Open
shreyb wants to merge 13 commits into
fermitools:masterfrom
shreyb:issue-113
Open

swagger.json file should be saved to user's local config dir, not next to the code#119
shreyb wants to merge 13 commits into
fermitools:masterfrom
shreyb:issue-113

Conversation

@shreyb

@shreyb shreyb commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

This PR updates Ferry CLI’s swagger caching behavior so swagger.json is stored in a user-owned location ($XDG_CONFIG_DIR/ferry-cli when available, otherwise $HOME/.config/ferry-cli, else a temp directory) rather than alongside the installed source, addressing #113.

Changes:

  • Add get_configfile_dir() and refactor config path helpers to separate “config dir” vs “config.ini path”. Also added a function that computes a per-server swagger filename
  • Update FerryAPI to use the per-swagger filename and use it to store swagger file under the user config dir (or temp dir), fetching it when missing.

(Edited from Copilot-generated summary)

All unit and integration tests pass.

Closes #113

@shreyb
shreyb force-pushed the issue-113 branch 4 times, most recently from a7793ac to 2cd89f1 Compare June 15, 2026 21:48
@shreyb
shreyb requested a review from Copilot June 15, 2026 21:55

Copilot AI left a comment

Copy link
Copy Markdown

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 updates Ferry CLI’s swagger caching behavior so swagger.json is stored in a user-owned location (XDG config dir when available, otherwise a temp directory) rather than alongside the installed source, addressing #113.

Changes:

  • Add get_configfile_dir() and refactor config path helpers to separate “config dir” vs “config.ini path”.
  • Update FerryAPI to compute a per-server swagger filename and store it under the user config dir (or temp dir), fetching it when missing.
  • Refactor DebugLevel into its own module and update affected imports; expand/update tests and CI/pre-commit config accordingly.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
src/ferry_cli/helpers/api.py Implements new swagger file location + hashed filename and fetch-on-missing behavior.
src/ferry_cli/config/config.py Adds get_configfile_dir() and adjusts config path derivation.
src/ferry_cli/ferry_cli.py Updates swagger loading to use FerryAPI.swagger_file and introduces setup_FerryAPI().
src/ferry_cli/helpers/auth.py Moves DebugLevel import to new module and removes old enum definition.
src/ferry_cli/helpers/debug_level.py New DebugLevel enum module.
src/ferry_cli/helpers/supported_workflows/* Updates DebugLevel imports to new module.
tests/test_api.py Adds unit/integration coverage for swagger file selection and fetching.
tests/test_config.py Updates tests for new config dir/path helpers.
tests/test_main.py Updates swagger fixture to use FerryAPI.swagger_file and adjusts server-flag test.
tests/conftest.py Adds a test auth stub class used by new tests.
.pre-commit-config.yaml Attempts to add validators for pylint hook (currently invalid YAML).
.github/workflows/Ferry-CLI.yml Splits CI into pre-commit + unit-test jobs (currently invalid YAML indentation).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ferry_cli/config/config.py Outdated
Comment thread src/ferry_cli/config/config.py Outdated
Comment thread src/ferry_cli/helpers/api.py
Comment thread src/ferry_cli/helpers/api.py Outdated
Comment thread src/ferry_cli/helpers/api.py Outdated
Comment thread tests/conftest.py
Comment thread .pre-commit-config.yaml Outdated
Comment thread .github/workflows/Ferry-CLI.yml
Comment thread .github/workflows/Ferry-CLI.yml
Comment thread src/ferry_cli/config/config.py
@shreyb
shreyb force-pushed the issue-113 branch 2 times, most recently from eaedacf to 8a567f0 Compare June 16, 2026 16:47
…th import it without causing an import cycle

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 18 comments.

Comment thread src/ferry_cli/config/config.py Outdated
Comment thread src/ferry_cli/config/config.py Outdated
Comment thread src/ferry_cli/config/config.py
Comment thread src/ferry_cli/version.py
Comment thread src/ferry_cli/ferry_cli.py
Comment thread tests/test_main.py Outdated
Comment thread tests/test_main.py Outdated
Comment thread tests/test_main.py Outdated
Comment thread tests/test_api.py Outdated
Comment thread .pre-commit-config.yaml Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Comment thread src/ferry_cli/version.py
Comment thread tests/test_main.py Outdated
Comment thread src/ferry_cli/helpers/api.py Outdated
@shreyb
shreyb requested a review from Copilot June 16, 2026 19:59
@shreyb shreyb added this to the 1.3.0 milestone Jun 16, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 5 comments.

Comment thread src/ferry_cli/ferry_cli.py Outdated
Comment thread src/ferry_cli/ferry_cli.py
Comment thread src/ferry_cli/ferry_cli.py
Comment thread src/ferry_cli/version.py
Comment thread src/ferry_cli/version.py

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 6 comments.

Comments suppressed due to low confidence (1)

.github/workflows/Ferry-CLI.yml:17

  • The steps: lists are not indented under steps: (e.g. - uses: ... is aligned with steps:). This makes the workflow YAML invalid and will prevent GitHub Actions from running the job.
    steps:
    - uses: actions/checkout@v4
    - name: setup Python

Comment thread src/ferry_cli/helpers/api.py
Comment thread src/ferry_cli/helpers/api.py Outdated
Comment thread src/ferry_cli/helpers/api.py
Comment thread tests/test_main.py
Comment thread .pre-commit-config.yaml
Comment thread .github/workflows/Ferry-CLI.yml
@shreyb
shreyb marked this pull request as ready for review June 16, 2026 21:54
@shreyb
shreyb requested a review from LTrestka June 16, 2026 21:54
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.

swagger.json should be a config file in user's .config dir

2 participants