Conversation
- Cleaned up whitespace and formatting in blob_service.py, cosmos_service.py, search_service.py, and settings.py. - Ensured consistent spacing and indentation throughout the codebase. - Enhanced code clarity by removing unnecessary blank lines and aligning comments. - No functional changes were made; this commit focuses solely on code style improvements.
There was a problem hiding this comment.
Pull request overview
This PR adds CI automation for Python linting and Markdown link validation, introduces a repo-wide Flake8 config, and applies small backend cleanups (formatting/refactors and more specific exception handling) in the content generation backend.
Changes:
- Added GitHub Actions workflows for Python linting and Markdown broken-link checking.
- Added a root
.flake8configuration and updated Python backend files for formatting/cleanup. - Minor refactors in backend orchestration logic (constants placement, exception handling) and endpoint selection readability.
Reviewed changes
Copilot reviewed 6 out of 12 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
content-gen/src/backend/settings.py |
Whitespace/formatting tweaks and minor prompt text formatting cleanup. |
content-gen/src/backend/services/search_service.py |
Formatting changes; search client usage remains synchronous inside async methods. |
content-gen/src/backend/services/cosmos_service.py |
Formatting/whitespace changes only. |
content-gen/src/backend/services/blob_service.py |
Formatting/whitespace changes only. |
content-gen/src/backend/orchestrator.py |
Moves TOKEN_ENDPOINT, tightens exception handling, and applies formatting cleanups. |
content-gen/src/backend/models.py |
Formatting/whitespace changes only. |
content-gen/src/backend/app.py |
Removes unnecessary global statements and applies formatting cleanups. |
content-gen/src/backend/api/admin.py |
Formatting/whitespace changes only. |
content-gen/src/backend/agents/image_content_agent.py |
Readability/formatting tweaks (no functional changes expected). |
.github/workflows/pylint.yml |
Adds Python lint workflow (currently runs flake8 only). |
.github/workflows/broken-links-checker.yml |
Adds Markdown link checking workflow via Lychee. |
.flake8 |
Introduces shared Flake8 configuration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| search_text=query, | ||
| filter=filter_str, | ||
| top=top, | ||
| select=["id", "product_name", "sku", "model", "category", "sub_category", | ||
| "marketing_description", "detailed_spec_description", "image_description"] | ||
| "marketing_description", "detailed_spec_description", "image_description"] |
There was a problem hiding this comment.
This is an async method but uses the synchronous Azure SearchClient and synchronous client.search(...), which can block the event loop under load. Consider switching to azure.search.documents.aio.SearchClient (and its async iteration) or running the sync call in a thread executor.
| filter=filter_str, | ||
| top=top, | ||
| select=["id", "name", "filename", "primary_color", "secondary_color", | ||
| "color_family", "mood", "style", "description", "use_cases", | ||
| "blob_url", "keywords"] | ||
| "color_family", "mood", "style", "description", "use_cases", | ||
| "blob_url", "keywords"] |
There was a problem hiding this comment.
Same concern here: synchronous SearchClient.search(...) is called inside an async method, which can block the event loop. Consider using the aio SearchClient or offloading to a thread executor.
| @@ -0,0 +1,5 @@ | |||
| [flake8] | |||
| max-line-length = 88 | |||
| extend-ignore = E501 | |||
There was a problem hiding this comment.
With E501 ignored, max-line-length won’t be enforced by flake8, which can be surprising to readers. Consider either removing max-line-length (if intentionally ignoring line length) or stop ignoring E501 and rely on the configured length.
| extend-ignore = E501 |
| pip install flake8 # Ensure flake8 is installed explicitly | ||
|
|
||
| - name: Run flake8 and pylint | ||
| run: | | ||
| flake8 --config=.flake8 content-gen/src/backend # Specify the directory to lint |
There was a problem hiding this comment.
The workflow name/filename suggests PyLint, but the job only installs and runs flake8. Either add pylint installation + execution, or rename the workflow/step to reflect flake8 to avoid confusion and false expectations in CI.
| pip install flake8 # Ensure flake8 is installed explicitly | |
| - name: Run flake8 and pylint | |
| run: | | |
| flake8 --config=.flake8 content-gen/src/backend # Specify the directory to lint | |
| pip install flake8 # Ensure flake8 is installed explicitly | |
| pip install pylint # Ensure pylint is installed explicitly | |
| - name: Run flake8 and pylint | |
| run: | | |
| flake8 --config=.flake8 content-gen/src/backend # Specify the directory to lint | |
| pylint content-gen/src/backend |
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
There was a problem hiding this comment.
This workflow uses actions/checkout@v6, while other workflows in this repo pin to v4/v5. If v6 isn’t available (or behaves differently), this will break CI; consider aligning to the same major version used elsewhere in .github/workflows.
| - name: Checkout Repo | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 |
There was a problem hiding this comment.
This workflow uses actions/checkout@v6, while other workflows in this repo pin to v4/v5. If v6 isn’t available (or behaves differently), this will break CI; consider aligning to the same major version used elsewhere in .github/workflows.
| args: > | ||
| --verbose --no-progress --exclude ^https?:// | ||
| ${{ steps.changed-markdown-files.outputs.all_changed_files }} |
There was a problem hiding this comment.
The lychee args exclude all http/https URLs (--exclude ^https?://), which effectively skips checking external links. If the goal is to catch broken external references, remove/relax this exclude; if the goal is "internal links only", consider documenting that in the workflow name/description.
| self._credential = DefaultAzureCredential() | ||
| return self._credential | ||
| except Exception: | ||
| pass | ||
|
|
There was a problem hiding this comment.
DefaultAzureCredential() construction typically doesn’t validate credentials; it will succeed even when no auth method is configured. Because of that, this try/except will almost never fall back to the API key path—failures will occur later on token acquisition. Consider explicitly attempting a token request here (or prefer API key when configured) so the fallback behavior works as intended.
| except Exception: | ||
| pass |
There was a problem hiding this comment.
'except' clause does nothing but pass and there is no explanatory comment.
| except Exception: | |
| pass | |
| except Exception as parse_error: | |
| # If JSON extraction from markdown fails, fall back to original prompt_text | |
| logger.debug("Failed to parse JSON prompt from markdown code block: %s", parse_error) |
| except Exception: | ||
| pass |
There was a problem hiding this comment.
'except' clause does nothing but pass and there is no explanatory comment.
| except Exception: | |
| pass | |
| except (json.JSONDecodeError, TypeError, ValueError) as parse_error: | |
| logger.debug("Failed to parse JSON prompt from code block: %s", parse_error) |
…emetry template validation, and backend testing
…emetry template validation, and backend testing
…d improve Docker image handling
…etup documentation
…cripts for quota verification
… parsing failures
…orchestrator.py; add model availability check in quota_check_params.sh
…ve unused fallback logic
…te and pagination for better accuracy
… and update documentation for login command
Purpose
This pull request introduces several improvements and workflow enhancements, primarily focused on code quality enforcement and CI automation. It adds new GitHub Actions workflows for linting and Markdown link checking, introduces a project-wide Flake8 configuration, and makes a few minor code cleanups and refactorings.
CI/CD and Linting Enhancements:
.github/workflows/pylint.ymlworkflow to run Flake8 linting on backend Python code during pushes, ensuring code quality and style consistency..flake8configuration file to standardize linting rules across the project, specifying line length, ignored rules, and excluded directories.Documentation Quality Automation:
.github/workflows/broken-links-checker.ymlworkflow to automatically check for broken links in Markdown files on pull requests and manual workflow triggers, helping maintain documentation quality.Code Cleanups and Minor Refactors:
content-gen/src/backend/app.pyto remove unnecessaryglobalstatements, as they were not needed for variable access. [1] [2]TOKEN_ENDPOINTconstant to a more appropriate location incontent-gen/src/backend/orchestrator.pyand improved exception handling by catching specific exceptions instead of using bareexcept. [1] [2] [3] [4]image_content_agent.pyfor improved readability.