Skip to content

Psl pk pipeline1#1

Open
Pavan-Microsoft wants to merge 25 commits intodevfrom
psl-pk-pipeline1
Open

Psl pk pipeline1#1
Pavan-Microsoft wants to merge 25 commits intodevfrom
psl-pk-pipeline1

Conversation

@Pavan-Microsoft
Copy link
Owner

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:

  • Added a .github/workflows/pylint.yml workflow to run Flake8 linting on backend Python code during pushes, ensuring code quality and style consistency.
  • Introduced a .flake8 configuration file to standardize linting rules across the project, specifying line length, ignored rules, and excluded directories.

Documentation Quality Automation:

  • Added a .github/workflows/broken-links-checker.yml workflow 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:

  • Minor code refactors in content-gen/src/backend/app.py to remove unnecessary global statements, as they were not needed for variable access. [1] [2]
  • Moved the TOKEN_ENDPOINT constant to a more appropriate location in content-gen/src/backend/orchestrator.py and improved exception handling by catching specific exceptions instead of using bare except. [1] [2] [3] [4]
  • Minor formatting update for endpoint selection logic in image_content_agent.py for improved readability.

- 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.
Copy link

Copilot AI left a comment

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 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 .flake8 configuration 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.

Comment on lines 106 to +110
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"]
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines 167 to +171
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"]
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,5 @@
[flake8]
max-line-length = 88
extend-ignore = E501
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
extend-ignore = E501

Copilot uses AI. Check for mistakes.
Comment on lines +33 to +37
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
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
Comment on lines +21 to +23
steps:
- uses: actions/checkout@v6

Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +19 to +22
- name: Checkout Repo
uses: actions/checkout@v6
with:
fetch-depth: 0
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +40 to +42
args: >
--verbose --no-progress --exclude ^https?://
${{ steps.changed-markdown-files.outputs.all_changed_files }}
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines 35 to +39
self._credential = DefaultAzureCredential()
return self._credential
except Exception:
pass

Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines 1514 to 1515
except Exception:
pass
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

'except' clause does nothing but pass and there is no explanatory comment.

Suggested change
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)

Copilot uses AI. Check for mistakes.
Comment on lines 1747 to 1748
except Exception:
pass
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

'except' clause does nothing but pass and there is no explanatory comment.

Suggested change
except Exception:
pass
except (json.JSONDecodeError, TypeError, ValueError) as parse_error:
logger.debug("Failed to parse JSON prompt from code block: %s", parse_error)

Copilot uses AI. Check for mistakes.
…emetry template validation, and backend testing
…emetry template validation, and backend testing
…orchestrator.py; add model availability check in quota_check_params.sh
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.

2 participants