convert cli to debugger of cloud infrastructure - #100
Conversation
WalkthroughThe changes refactor the CLI project’s Python module structure and update its build, test, and deployment workflows. All import paths in the CLI codebase are migrated from the Changes
Sequence Diagram(s)sequenceDiagram
participant Developer
participant GitHub Actions
participant uv Toolchain
participant PyPI
Developer->>GitHub Actions: Push/PR (CLI changes)
GitHub Actions->>uv Toolchain: Install uv, Python 3.13
GitHub Actions->>uv Toolchain: Sync/install dependencies
GitHub Actions->>uv Toolchain: Build package (uv build)
GitHub Actions->>uv Toolchain: Run tests (pytest)
GitHub Actions->>uv Toolchain: Install and run twine check
alt On publish workflow
GitHub Actions->>PyPI: Upload package (twine upload)
end
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 3
🔭 Outside diff range comments (1)
cli/src/infragpt/main.py (1)
88-91: Fix parameter mismatch –verboseis being passed asapi_key.
generate_gcloud_command()expects(prompt, model_type, api_key, *, …).
Passing the booleanverbosein the positionalapi_keyslot makes every call fail authentication.- result = generate_gcloud_command(user_input, model_type, verbose) + result = generate_gcloud_command( + user_input, + model_type, + api_key, + )If you later need
verboseinsidegenerate_gcloud_command, expose it as a keyword arg.
Without this patch interactive mode cannot work whenverbose=True.
🧹 Nitpick comments (14)
cli/src/infragpt/config.py (1)
55-61: Potential duplication / divergence ofvalidate_env_api_keyslogic
init_config()now importsvalidate_env_api_keysfrominfragpt.llm, while a function with the same name also exists ininfragpt.llm_adapter.
Having two sources of truth will drift over time and confuse callers.Action items:
- Consolidate the helper in a single module and re-export if needed.
- Add unit tests ensuring both
config.init_config()andllm_adapter.validate_env_api_keys()stay in sync.cli/src/infragpt/llm_adapter.py (1)
17-29: Imports updated correctly, but reinforce single-source philosophyImports now target the
infragptnamespace—good.
Given the duplication noted inconfig.py, consider importingvalidate_env_api_keysfrom the canonical module instead of maintaining an identical implementation here.No blocking issues, just maintainability advice.
cli/src/infragpt/main.py (1)
22-31: Remove unused imports to satisfy Ruff and avoid dead code.
CONFIG_FILEandvalidate_env_api_keysare never referenced in this module. Keepconsole,generate_gcloud_command, etc., but drop the unused names to silence Ruff-F401 and reduce mental noise.-from infragpt.config import ( - CONFIG_FILE, load_config, init_config, console -) -from infragpt.llm_adapter import ( - generate_gcloud_command, validate_env_api_keys, prompt_credentials -) +from infragpt.config import load_config, init_config, console +from infragpt.llm_adapter import generate_gcloud_command, prompt_credentialscli/src/infragpt/llm/client.py (2)
16-19: Drop unusedValidationErrorimport.
ValidationErroris not referenced anywhere in this file. Remove it to satisfy Ruff-F401.-from infragpt.llm.errors import AuthenticationError, GenerationError, ValidationError +from infragpt.llm.errors import AuthenticationError, GenerationError
198-204: ImportParsingErroronce at module top to avoid duplication insideexceptblocks.Repeated local imports add overhead and obscure stack traces. Move the import to the header and reuse it.
- except json.JSONDecodeError as e: - from infragpt.llm.errors import ParsingError + except json.JSONDecodeError as e: raise ParsingError(f"Failed to parse parameter info: {str(e)}") from e except Exception as e: - # Wrap other errors - from infragpt.llm.errors import ParsingError + # Wrap other errors raise ParsingError(f"Failed to get parameter info: {str(e)}") from eAnd add near the other top-level imports:
from infragpt.llm.errors import ParsingErrorcli/pyproject.toml (1)
22-31: Optional: move dev extras under[project.optional-dependencies]for PEP 621 compliance.
[dependency-groups]is specific to Hatch; if wider tooling (e.g., pip, poetry) is expected, expose dev deps in the standard table:[project.optional-dependencies] dev = [ "pytest>=8.4.1", ].github/workflows/publish.yml (3)
14-18: Trim the trailing whitespace & pin the UV version.
Line 18 has trailing spaces that break YAML-lint, and usingversion: "latest"makes your build non-deterministic.- version: "latest" + # Pin to the latest *major* you know works + version: "0.2.8"
22-26: Cache the build artefacts to speed up CI.
uv buildre-computes wheels every run. Consider caching$HOME/.cache/uvbetween jobs to cut several minutes off the workflow.
27-35: Reuse the existing environment instead of reinstalling Twine.
uv tool install twinecreates a fresh venv each call. You can install Twine once in the build step (or useuv pip install) and reuse it here, saving ~10 s..github/workflows/test.yml (5)
23-23: Remove stray trailing spaces.
Line 23 violates YAML-lint.- +
24-31: Pin UV version & document the install.
Same comments as in the publish workflow: pin a known-good version and avoid breakage whensetup-uvships breaking changes.
32-37: Use a lock-file driven sync.
uv syncwithout a lock file silently installs latest deps, defeating reproducibility. Commituv.lock(orrequirements.lock) and runuv sync --strict.
46-50: Surface skipped-tests as a warning.
Silently skipping tests can mask omissions. Exit with non-zero whentests/is missing or at least emit a workflow warning.
54-57: Avoid redundant wheel builds in test job.
uv build+twine checkis valuable in a separate “package” job but slows the test matrix. Consider splitting into a dedicated build workflow or useneeds.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
cli/uv.lockis excluded by!**/*.lockuv.lockis excluded by!**/*.lock
📒 Files selected for processing (13)
.github/workflows/cli-deploy.yml(2 hunks).github/workflows/publish.yml(1 hunks).github/workflows/test.yml(2 hunks)cli/pyproject.toml(2 hunks)cli/src/infragpt/__main__.py(1 hunks)cli/src/infragpt/config.py(1 hunks)cli/src/infragpt/llm/__init__.py(1 hunks)cli/src/infragpt/llm/auth.py(1 hunks)cli/src/infragpt/llm/client.py(2 hunks)cli/src/infragpt/llm_adapter.py(1 hunks)cli/src/infragpt/main.py(1 hunks)cli/src/infragpt/prompts.py(1 hunks)requirements.txt(0 hunks)
💤 Files with no reviewable changes (1)
- requirements.txt
🧰 Additional context used
🧠 Learnings (3)
.github/workflows/cli-deploy.yml (2)
Learnt from: CR
PR: priyanshujain/infragpt#0
File: services/website/CLAUDE.md:0-0
Timestamp: 2025-06-30T17:03:50.266Z
Learning: Applies to services/website/.github/workflows/**/*.yml : Automated deployment must be configured via GitHub Actions for Netlify deployment
Learnt from: CR
PR: priyanshujain/infragpt#0
File: services/website/CLAUDE.md:0-0
Timestamp: 2025-06-30T17:03:50.266Z
Learning: Applies to services/website/.github/workflows/**/*.yml : npm cache optimization must be used for faster CI builds
.github/workflows/publish.yml (1)
Learnt from: CR
PR: priyanshujain/infragpt#0
File: services/website/CLAUDE.md:0-0
Timestamp: 2025-06-30T17:03:50.266Z
Learning: Applies to services/website/.github/workflows/**/*.yml : Build process must run Astro build and deploy to Netlify on main branch pushes
.github/workflows/test.yml (2)
Learnt from: CR
PR: priyanshujain/infragpt#0
File: services/website/CLAUDE.md:0-0
Timestamp: 2025-06-30T17:03:50.266Z
Learning: Applies to services/website/.github/workflows/**/*.yml : npm cache optimization must be used for faster CI builds
Learnt from: CR
PR: priyanshujain/infragpt#0
File: services/website/CLAUDE.md:0-0
Timestamp: 2025-06-30T17:03:50.266Z
Learning: Applies to services/website/.github/workflows/**/*.yml : Build process must run Astro build and deploy to Netlify on main branch pushes
🧬 Code Graph Analysis (5)
cli/src/infragpt/llm/auth.py (1)
cli/src/infragpt/llm/errors.py (1)
AuthenticationError(11-13)
cli/src/infragpt/__main__.py (1)
cli/src/infragpt/main.py (2)
main(122-159)cli(108-112)
cli/src/infragpt/llm_adapter.py (2)
cli/src/infragpt/config.py (2)
load_config(23-33)save_config(35-44)cli/src/infragpt/history.py (1)
log_interaction(20-41)
cli/src/infragpt/llm/client.py (3)
cli/src/infragpt/llm/errors.py (4)
AuthenticationError(11-13)GenerationError(16-18)ValidationError(26-28)ParsingError(21-23)cli/src/infragpt/llm/auth.py (1)
validate_api_key(15-59)cli/src/infragpt/llm/prompts.py (1)
get_prompt_template(68-85)
cli/src/infragpt/config.py (2)
cli/src/infragpt/history.py (1)
init_history_dir(61-63)cli/src/infragpt/llm_adapter.py (1)
validate_env_api_keys(210-248)
🪛 Ruff (0.11.9)
cli/src/infragpt/llm/auth.py
12-12: infragpt.llm.errors.AuthenticationError imported but unused
Remove unused import: infragpt.llm.errors.AuthenticationError
(F401)
cli/src/infragpt/main.py
23-23: infragpt.config.CONFIG_FILE imported but unused
Remove unused import: infragpt.config.CONFIG_FILE
(F401)
27-27: infragpt.llm_adapter.validate_env_api_keys imported but unused
Remove unused import: infragpt.llm_adapter.validate_env_api_keys
(F401)
cli/src/infragpt/llm/__init__.py
14-14: infragpt.llm.client.get_llm_client imported but unused; consider removing, adding to __all__, or using a redundant alias
(F401)
15-15: infragpt.llm.client.generate_gcloud_command imported but unused; consider removing, adding to __all__, or using a redundant alias
(F401)
16-16: infragpt.llm.client.get_parameter_info imported but unused; consider removing, adding to __all__, or using a redundant alias
(F401)
20-20: infragpt.llm.auth.validate_api_key imported but unused; consider removing, adding to __all__, or using a redundant alias
(F401)
23-23: infragpt.llm.prompts.get_prompt_template imported but unused; consider removing, adding to __all__, or using a redundant alias
(F401)
23-23: infragpt.llm.prompts.format_prompt imported but unused; consider removing, adding to __all__, or using a redundant alias
(F401)
26-26: infragpt.llm.models.MODEL_TYPE imported but unused; consider removing, adding to __all__, or using a redundant alias
(F401)
cli/src/infragpt/llm/client.py
17-17: infragpt.llm.errors.ValidationError imported but unused
Remove unused import: infragpt.llm.errors.ValidationError
(F401)
🪛 YAMLlint (1.37.1)
.github/workflows/publish.yml
[error] 18-18: trailing spaces
(trailing-spaces)
.github/workflows/test.yml
[error] 23-23: trailing spaces
(trailing-spaces)
[error] 28-28: trailing spaces
(trailing-spaces)
🔇 Additional comments (6)
cli/src/infragpt/__main__.py (1)
4-4: Import path update looks goodThe switch to
infragpt.main.clialigns with the new package layout; no further action needed.cli/src/infragpt/prompts.py (1)
15-22: Import realignment looks fineAll references now point to the
infragptnamespace and the symbols are used below—no issues spotted..github/workflows/cli-deploy.yml (1)
26-29: Verify thatactions/setup-python@v5supportspython-version: "3.13".At the time of writing, 3.13 is still pre-release. If the image is unavailable the job will fail. Consider pinning to 3.12 until GA or adding a matrix to fall back.
cli/pyproject.toml (1)
11-12: Confirm ecosystem support for Python ≥ 3.13.Several pinned dependencies (
langchain-*,prompt-toolkit, etc.) may not yet publish wheels for 3.13. Build failures will surface only in CI. Validate compatibility or loosen therequires-pythonconstraint to>=3.10..github/workflows/publish.yml (1)
19-21: Double-check Python 3.13 availability on runners.
uv python install 3.13will fail until 3.13 is published on python.org + cached bysetup-uv. Verify that the release is GA and supported on GHA; otherwise fall back to the latest stable (3.12)..github/workflows/test.yml (1)
6-10: Path filter excludes root-level changes that break the CLI.
Running tests only whencli/**changes means updates to shared libs or GH-Actions files won’t trigger the suite. Ensure this is intentional.
| from infragpt.llm.models import MODEL_TYPE | ||
| from infragpt.llm.errors import AuthenticationError |
There was a problem hiding this comment.
Remove unused AuthenticationError import to satisfy Ruff F401
AuthenticationError isn’t referenced anywhere in this module. Keeping it triggers the Ruff F401 warning and may cause CI to fail if warnings are treated as errors.
-from infragpt.llm.models import MODEL_TYPE
-from infragpt.llm.errors import AuthenticationError
+from infragpt.llm.models import MODEL_TYPE📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| from infragpt.llm.models import MODEL_TYPE | |
| from infragpt.llm.errors import AuthenticationError | |
| from infragpt.llm.models import MODEL_TYPE |
🧰 Tools
🪛 Ruff (0.11.9)
12-12: infragpt.llm.errors.AuthenticationError imported but unused
Remove unused import: infragpt.llm.errors.AuthenticationError
(F401)
🤖 Prompt for AI Agents
In cli/src/infragpt/llm/auth.py at lines 11 to 12, the import statement includes
AuthenticationError which is not used anywhere in the file. Remove the import of
AuthenticationError from the import line to resolve the Ruff F401 unused import
warning and prevent potential CI failures.
| # Public exports from client.py | ||
| from llm.client import ( | ||
| from infragpt.llm.client import ( | ||
| get_llm_client, | ||
| generate_gcloud_command, | ||
| get_parameter_info, | ||
| ) | ||
|
|
||
| # Public exports from auth.py | ||
| from llm.auth import validate_api_key | ||
| from infragpt.llm.auth import validate_api_key | ||
|
|
||
| # Public exports from prompts.py | ||
| from llm.prompts import get_prompt_template, format_prompt | ||
| from infragpt.llm.prompts import get_prompt_template, format_prompt | ||
|
|
||
| # Public exports from models.py | ||
| from llm.models import MODEL_TYPE | ||
| from infragpt.llm.models import MODEL_TYPE | ||
|
|
||
| # Public exports from errors.py | ||
| from llm.errors import ( | ||
| from infragpt.llm.errors import ( | ||
| LLMError, |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Add __all__ to make re-exports explicit and silence F401.
The wildcard re-exports are intentional, but Ruff flags them as unused.
Publish them cleanly and document the public surface by adding __all__.
from infragpt.llm.client import (
get_llm_client,
generate_gcloud_command,
get_parameter_info,
)
...
from infragpt.llm.errors import (
LLMError,
AuthenticationError,
GenerationError,
ParsingError,
ValidationError,
ConfigurationError,
)
+# Public API of infragpt.llm
+__all__ = [
+ "get_llm_client",
+ "generate_gcloud_command",
+ "get_parameter_info",
+ "validate_api_key",
+ "get_prompt_template",
+ "format_prompt",
+ "MODEL_TYPE",
+ # errors
+ "LLMError",
+ "AuthenticationError",
+ "GenerationError",
+ "ParsingError",
+ "ValidationError",
+ "ConfigurationError",
+]📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| # Public exports from client.py | |
| from llm.client import ( | |
| from infragpt.llm.client import ( | |
| get_llm_client, | |
| generate_gcloud_command, | |
| get_parameter_info, | |
| ) | |
| # Public exports from auth.py | |
| from llm.auth import validate_api_key | |
| from infragpt.llm.auth import validate_api_key | |
| # Public exports from prompts.py | |
| from llm.prompts import get_prompt_template, format_prompt | |
| from infragpt.llm.prompts import get_prompt_template, format_prompt | |
| # Public exports from models.py | |
| from llm.models import MODEL_TYPE | |
| from infragpt.llm.models import MODEL_TYPE | |
| # Public exports from errors.py | |
| from llm.errors import ( | |
| from infragpt.llm.errors import ( | |
| LLMError, | |
| # Public exports from client.py | |
| from infragpt.llm.client import ( | |
| get_llm_client, | |
| generate_gcloud_command, | |
| get_parameter_info, | |
| ) | |
| # Public exports from auth.py | |
| from infragpt.llm.auth import validate_api_key | |
| # Public exports from prompts.py | |
| from infragpt.llm.prompts import get_prompt_template, format_prompt | |
| # Public exports from models.py | |
| from infragpt.llm.models import MODEL_TYPE | |
| # Public exports from errors.py | |
| from infragpt.llm.errors import ( | |
| LLMError, | |
| AuthenticationError, | |
| GenerationError, | |
| ParsingError, | |
| ValidationError, | |
| ConfigurationError, | |
| ) | |
| # Public API of infragpt.llm | |
| __all__ = [ | |
| "get_llm_client", | |
| "generate_gcloud_command", | |
| "get_parameter_info", | |
| "validate_api_key", | |
| "get_prompt_template", | |
| "format_prompt", | |
| "MODEL_TYPE", | |
| # errors | |
| "LLMError", | |
| "AuthenticationError", | |
| "GenerationError", | |
| "ParsingError", | |
| "ValidationError", | |
| "ConfigurationError", | |
| ] |
🧰 Tools
🪛 Ruff (0.11.9)
14-14: infragpt.llm.client.get_llm_client imported but unused; consider removing, adding to __all__, or using a redundant alias
(F401)
15-15: infragpt.llm.client.generate_gcloud_command imported but unused; consider removing, adding to __all__, or using a redundant alias
(F401)
16-16: infragpt.llm.client.get_parameter_info imported but unused; consider removing, adding to __all__, or using a redundant alias
(F401)
20-20: infragpt.llm.auth.validate_api_key imported but unused; consider removing, adding to __all__, or using a redundant alias
(F401)
23-23: infragpt.llm.prompts.get_prompt_template imported but unused; consider removing, adding to __all__, or using a redundant alias
(F401)
23-23: infragpt.llm.prompts.format_prompt imported but unused; consider removing, adding to __all__, or using a redundant alias
(F401)
26-26: infragpt.llm.models.MODEL_TYPE imported but unused; consider removing, adding to __all__, or using a redundant alias
(F401)
30-30: infragpt.llm.errors.LLMError imported but unused; consider removing, adding to __all__, or using a redundant alias
(F401)
🤖 Prompt for AI Agents
In cli/src/infragpt/llm/__init__.py around lines 12 to 30, the imported symbols
are re-exported but not explicitly declared, causing linter (Ruff) to flag them
as unused (F401). To fix this, define a __all__ list that includes all the
public symbols you want to export from this module. This will make the
re-exports explicit, document the public API surface, and silence the unused
import warnings.
| strategy: | ||
| matrix: | ||
| python-version: ["3.9", "3.13"] | ||
| python-version: ["3.13"] |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Add at least one released Python version to the matrix.
Limiting the matrix to 3.13 removes test coverage on the versions your users actually run today (3.11/3.12). Keep 3.13 for bleeding-edge plus one LTS.
🤖 Prompt for AI Agents
In .github/workflows/test.yml at line 19, the Python version matrix currently
includes only version 3.13, which excludes testing on stable and widely used
versions like 3.11 and 3.12. Update the python-version array to include at least
one released version such as 3.11 or 3.12 alongside 3.13 to ensure broader test
coverage across commonly used Python versions.
Summary by CodeRabbit
Refactor
Chores