Skip to content

Add documentation for prefect sdk generate CLI#155

Open
tomerqodo wants to merge 8 commits intoqodo_action_req_1_base_add_documentation_for_prefect_sdk_generate_cli_pr1from
qodo_action_req_1_head_add_documentation_for_prefect_sdk_generate_cli_pr1
Open

Add documentation for prefect sdk generate CLI#155
tomerqodo wants to merge 8 commits intoqodo_action_req_1_base_add_documentation_for_prefect_sdk_generate_cli_pr1from
qodo_action_req_1_head_add_documentation_for_prefect_sdk_generate_cli_pr1

Conversation

@tomerqodo
Copy link
Copy Markdown

Benchmark PR from agentic-review-benchmarks#1

desertaxle and others added 8 commits January 25, 2026 12:09
- Add auto-generated CLI reference for `prefect sdk` command
- Add how-to guide for generating typed SDKs from deployments
- Update navigation in docs.json for both new pages
- Regenerate CLI docs to include new --output options

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Keep only sdk.mdx from the CLI docs regeneration.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The code examples reference a hypothetical my_sdk module that
doesn't exist, so they can't be executed as tests.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove marketing-style "before/after" section
- Use sentence case headers
- Task-oriented organization (CLI then Python)
- Add opening context and further reading links
- Direct, instructional tone throughout

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove marketing-style "before/after" section
- Use sentence case headers
- Task-oriented organization (CLI then Python)
- Add opening context and further reading links
- Direct, instructional tone throughout

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Move generate-custom-sdk.mdx to docs/v3/advanced/
- Create new "Deployments" group in Advanced section
- Move form-building guide to new Deployments group
- Both guides relate to deployment configuration

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the docs label Jan 29, 2026
@qodo-code-review
Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (2) 📎 Requirement gaps (0)

Grey Divider


Action required

1. Nonstandard logger initialization 📘 Rule violation ✧ Quality
Description
src/prefect/_sdk/fetcher.py initializes logger via logging.getLogger(__name__) without the
  required get_logger(...) pattern and without the required type annotation.
• This breaks the standardized logging configuration/type-safety requirement and can lead to
  inconsistent logging behavior across modules.
• It directly violates the compliance rule that mandates `logger: "logging.Logger" =
  get_logger("module_name")` for all logger instances.
Code

src/prefect/_sdk/fetcher.py[R11-21]

+import logging
from dataclasses import dataclass, field
from datetime import datetime, timezone
from typing import TYPE_CHECKING, Any
from uuid import UUID

import prefect
+
+# Logger for SDK fetcher operations
+logger = logging.getLogger(__name__)
from prefect._sdk.models import (
Evidence
PR Compliance ID 9 requires a standardized get_logger initialization with a logging.Logger type
annotation. The PR introduces a module-level logger created with logging.getLogger(__name__) and
no type annotation in fetcher.py.

AGENTS.md
src/prefect/_sdk/fetcher.py[11-21]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`src/prefect/_sdk/fetcher.py` creates a module logger using `logging.getLogger(__name__)` and without the required `logger: &quot;logging.Logger&quot; = get_logger(...)` annotation/pattern.

## Issue Context
Compliance requires consistent logger instantiation across the codebase using Prefect’s `get_logger` helper to ensure standardized configuration and type safety.

## Fix Focus Areas
- src/prefect/_sdk/fetcher.py[11-21]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Unchecked base_job_template variables 📘 Rule violation ⛯ Reliability
Description
_fetch_work_pool() assigns job_vars_schema = base_job_template["variables"] without validating
  the value is a dict, even though job_vars_schema is typed as dict[str, Any].
• If base_job_template["variables"] is missing expected shape (e.g., None/list/str), later code
  that assumes a dict (e.g., calling .get(...)) can raise runtime exceptions instead of degrading
  gracefully.
• This violates the requirement to explicitly handle null/empty/boundary cases and potential failure
  points for robust behavior.
Code

src/prefect/_sdk/fetcher.py[R179-182]

        job_vars_schema: dict[str, Any] = {}
        base_job_template = work_pool.base_job_template
        if base_job_template and "variables" in base_job_template:
-            variables = base_job_template["variables"]
-            if isinstance(variables, dict):
-                job_vars_schema = variables
+            job_vars_schema = base_job_template["variables"]
Evidence
PR Compliance ID 3 requires explicit handling of edge cases and failure points. The new code stores
base_job_template["variables"] into a dict-typed variable without validating it’s a dict, while
downstream processing calls .get on work_pool.job_variables_schema, which will crash if it is
not a dict.

Rule 3: Generic: Robust Error Handling and Edge Case Management
src/prefect/_sdk/fetcher.py[179-183]
src/prefect/_sdk/renderer.py[270-273]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`_fetch_work_pool()` assigns `base_job_template[&quot;variables&quot;]` into `job_vars_schema` without verifying it is a dict, which can cause runtime errors later when code assumes dict methods like `.get()`.

## Issue Context
This value originates from API/server-provided metadata and should be treated as an external/variable-shape input. Robust handling should validate shape and degrade gracefully.

## Fix Focus Areas
- src/prefect/_sdk/fetcher.py[176-188]
- src/prefect/_sdk/renderer.py[270-276]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



ⓘ The new review experience is currently in Beta. Learn more

Qodo Logo

Comment on lines +11 to 21
import logging
from dataclasses import dataclass, field
from datetime import datetime, timezone
from typing import TYPE_CHECKING, Any
from uuid import UUID

import prefect

# Logger for SDK fetcher operations
logger = logging.getLogger(__name__)
from prefect._sdk.models import (
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. Nonstandard logger initialization 📘 Rule violation ✧ Quality

src/prefect/_sdk/fetcher.py initializes logger via logging.getLogger(__name__) without the
  required get_logger(...) pattern and without the required type annotation.
• This breaks the standardized logging configuration/type-safety requirement and can lead to
  inconsistent logging behavior across modules.
• It directly violates the compliance rule that mandates `logger: "logging.Logger" =
  get_logger("module_name")` for all logger instances.
Agent prompt
## Issue description
`src/prefect/_sdk/fetcher.py` creates a module logger using `logging.getLogger(__name__)` and without the required `logger: "logging.Logger" = get_logger(...)` annotation/pattern.

## Issue Context
Compliance requires consistent logger instantiation across the codebase using Prefect’s `get_logger` helper to ensure standardized configuration and type safety.

## Fix Focus Areas
- src/prefect/_sdk/fetcher.py[11-21]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines 179 to +182
job_vars_schema: dict[str, Any] = {}
base_job_template = work_pool.base_job_template
if base_job_template and "variables" in base_job_template:
variables = base_job_template["variables"]
if isinstance(variables, dict):
job_vars_schema = variables
job_vars_schema = base_job_template["variables"]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

2. Unchecked base_job_template variables 📘 Rule violation ⛯ Reliability

_fetch_work_pool() assigns job_vars_schema = base_job_template["variables"] without validating
  the value is a dict, even though job_vars_schema is typed as dict[str, Any].
• If base_job_template["variables"] is missing expected shape (e.g., None/list/str), later code
  that assumes a dict (e.g., calling .get(...)) can raise runtime exceptions instead of degrading
  gracefully.
• This violates the requirement to explicitly handle null/empty/boundary cases and potential failure
  points for robust behavior.
Agent prompt
## Issue description
`_fetch_work_pool()` assigns `base_job_template["variables"]` into `job_vars_schema` without verifying it is a dict, which can cause runtime errors later when code assumes dict methods like `.get()`.

## Issue Context
This value originates from API/server-provided metadata and should be treated as an external/variable-shape input. Robust handling should validate shape and degrade gracefully.

## Fix Focus Areas
- src/prefect/_sdk/fetcher.py[176-188]
- src/prefect/_sdk/renderer.py[270-276]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants