Skip to content

Add documentation for prefect sdk generate CLI#27

Open
tomerqodo wants to merge 8 commits into
coderabbit_full_base_add_documentation_for_prefect_sdk_generate_cli_pr1from
coderabbit_full_head_add_documentation_for_prefect_sdk_generate_cli_pr1
Open

Add documentation for prefect sdk generate CLI#27
tomerqodo wants to merge 8 commits into
coderabbit_full_base_add_documentation_for_prefect_sdk_generate_cli_pr1from
coderabbit_full_head_add_documentation_for_prefect_sdk_generate_cli_pr1

Conversation

@tomerqodo

@tomerqodo tomerqodo commented Jan 29, 2026

Copy link
Copy Markdown

Benchmark PR from agentic-review-benchmarks#1

Summary by CodeRabbit

  • New Features

    • Added ability to generate typed Python SDKs for Prefect deployments via CLI with IDE autocomplete and type checking support.
  • Documentation

    • New guide on generating and using custom SDKs with deployment examples and configuration options.
    • Added CLI reference documentation for the new prefect sdk generate command with available flags and usage examples.
    • Reorganized documentation navigation to better organize deployment-related content.

✏️ Tip: You can customize this high-level summary in your review settings.

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
@coderabbitai

coderabbitai Bot commented Jan 29, 2026

Copy link
Copy Markdown

Walkthrough

This PR adds documentation and implementation for a new CLI feature enabling users to generate custom Python SDKs from Prefect deployments. The change includes two new documentation pages, navigation restructuring, and modifications to the SDK fetcher module to support deployment filtering by short name.

Changes

Cohort / File(s) Summary
Documentation Structure
docs/docs.json
Navigation reorganization: moved form-building to new Deployments group alongside generate-custom-sdk, and added CLI Reference entry for sdk page.
CLI SDK Documentation
docs/v3/advanced/generate-custom-sdk.mdx, docs/v3/api-ref/cli/sdk.mdx
Two new documentation pages explaining SDK generation feature, CLI usage, configuration options, and examples.
SDK Fetcher Implementation
src/prefect/_sdk/fetcher.py
Added module logging, simplified job template variable extraction, removed strict zip behavior, and modified deployment filtering logic to use short name (dep.name) instead of full_name for filter matching.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A custom SDK spring to life,
With CLI commands, no more strife,
Deployments now deploy with pride,
Generated code, your trusted guide,
From fetcher's wisdom, filters shine! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is minimal and only references a benchmark PR source without providing substantive information about changes, objectives, or checklist items as required by the template. Expand the description with an overview of proposed changes and complete the checklist items to indicate testing, documentation, and other compliance requirements.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding documentation for the prefect sdk generate CLI command, which is reflected across the new documentation files and CLI reference updates.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/prefect/_sdk/fetcher.py (2)

178-182: Guard against non-dict base_job_template["variables"].

Line 182 can raise if base_job_template isn’t a mapping or if variables isn’t a dict. A defensive guard avoids unexpected TypeErrors from API changes.

🛡️ Suggested hardening
-        if base_job_template and "variables" in base_job_template:
-            job_vars_schema = base_job_template["variables"]
+        if (
+            isinstance(base_job_template, dict)
+            and isinstance(base_job_template.get("variables"), dict)
+        ):
+            job_vars_schema = base_job_template["variables"]

395-421: Record ambiguity warnings when short-name filters are used.

Line 397 skips the match block when a short name is provided (e.g., --deployment my-deploy), so short_name_matches never gets populated and ambiguity warnings are lost.

✅ Minimal fix
         # If filtering by deployment name, check the full name matches
         full_name = f"{flow_name}/{dep.name}"
+        if deployment_names and dep.name in deployment_names:
+            # Track short-name matches even when no further filtering is needed
+            short_name_matches.setdefault(dep.name, []).append(full_name)
         if deployment_names and dep.name not in deployment_names:
             # Only include if the full name matches (filter was by name parts)
             # Skip if user specified full names and this doesn't match
             found_match = False
-            matched_short_name: str | None = None
             for dn in deployment_names:
                 if "/" not in dn:
                     # User gave just deployment name, check against dep.name
                     if dep.name == dn:
                         found_match = True
-                        matched_short_name = dn
                         break
                 else:
                     # User gave full name, must match exactly
                     if full_name == dn:
                         found_match = True
                         break
             if not found_match:
                 continue
-            # Track short name matches for ambiguity warning
-            if matched_short_name:
-                if matched_short_name not in short_name_matches:
-                    short_name_matches[matched_short_name] = []
-                short_name_matches[matched_short_name].append(full_name)
🤖 Fix all issues with AI agents
In `@docs/v3/api-ref/cli/sdk.mdx`:
- Line 44: Remove the stray hidden control character found at Line 44 in
docs/v3/api-ref/cli/sdk.mdx by deleting the non-printable/backspace character so
the file contains only valid text; confirm the character is gone by opening the
file in a hex-aware editor or running a lint that highlights non-printable
characters.
- Around line 1-4: The frontmatter has an empty title field; replace the blank
title value with a meaningful, SEO-friendly string (e.g., "Prefect SDK" or a
concise descriptive title) by updating the title frontmatter key while
preserving other keys like sidebarTitle so the page metadata and header render
correctly.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0ee3553 and 37e272d.

📒 Files selected for processing (4)
  • docs/docs.json
  • docs/v3/advanced/generate-custom-sdk.mdx
  • docs/v3/api-ref/cli/sdk.mdx
  • src/prefect/_sdk/fetcher.py
🧰 Additional context used
🧬 Code graph analysis (1)
src/prefect/_sdk/fetcher.py (1)
src/prefect/_sdk/models.py (1)
  • deployment_names (120-129)
🪛 Ruff (0.14.14)
src/prefect/_sdk/fetcher.py

220-220: zip() without an explicit strict= parameter

Add explicit value for parameter strict=

(B905)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (37)
  • GitHub Check: Runner, Worker, Settings, Input, and CLI Tests - python:3.10, postgres:14
  • GitHub Check: Database and Orchestration Tests - python:3.11, sqlite
  • GitHub Check: Server Tests - python:3.14, sqlite
  • GitHub Check: Runner, Worker, Settings, Input, and CLI Tests - python:3.11, postgres:14
  • GitHub Check: Database and Orchestration Tests - python:3.13, postgres:14
  • GitHub Check: Client Tests - python:3.14, postgres:14
  • GitHub Check: Runner, Worker, Settings, Input, and CLI Tests - python:3.13, postgres:14
  • GitHub Check: Database and Orchestration Tests - python:3.14, postgres:14
  • GitHub Check: Client Tests - python:3.13, postgres:14
  • GitHub Check: Runner, Worker, Settings, Input, and CLI Tests - python:3.12, postgres:14
  • GitHub Check: Database and Orchestration Tests - python:3.13, sqlite
  • GitHub Check: Database and Orchestration Tests - python:3.14, sqlite
  • GitHub Check: Runner, Worker, Settings, Input, and CLI Tests - python:3.14, postgres:14
  • GitHub Check: Client Tests - python:3.12, postgres:14
  • GitHub Check: Database and Orchestration Tests - python:3.12, postgres:14
  • GitHub Check: Server Tests - python:3.10, sqlite
  • GitHub Check: Client Tests - python:3.10, postgres:14
  • GitHub Check: Database and Orchestration Tests - python:3.10, sqlite
  • GitHub Check: Database and Orchestration Tests - python:3.12, sqlite
  • GitHub Check: Client Tests - python:3.11, postgres:14
  • GitHub Check: Database and Orchestration Tests - python:3.11, postgres:14
  • GitHub Check: Server Tests - python:3.14, postgres:14
  • GitHub Check: Server Tests - python:3.11, postgres:14
  • GitHub Check: Server Tests - python:3.10, postgres:14
  • GitHub Check: Server Tests - python:3.12, sqlite
  • GitHub Check: Server Tests - python:3.11, sqlite
  • GitHub Check: Database and Orchestration Tests - python:3.10, postgres:14
  • GitHub Check: Server Tests - python:3.13, postgres:14
  • GitHub Check: Server Tests - python:3.12, postgres:14
  • GitHub Check: Server Tests - python:3.13, sqlite
  • GitHub Check: Benchmark
  • GitHub Check: typesafety
  • GitHub Check: Benchmark
  • GitHub Check: Integration tests @main
  • GitHub Check: Prefect Client Compatibility Tests
  • GitHub Check: Test SQLite 3.31.1 Compatibility
  • GitHub Check: Test SQLite 3.24.0 Compatibility
🔇 Additional comments (7)
docs/v3/api-ref/cli/sdk.mdx (1)

61-78: LGTM: options accordion is clear and concise.

Nice, consistent flag descriptions and guidance.

src/prefect/_sdk/fetcher.py (3)

10-21: LGTM: module logger setup for SDK fetcher.

Clear and consistent logging initialization.


212-234: LGTM: deterministic pairing of pool names to results.

pool_names_list and results are derived from the same source, so pairing via zip is safe here.


320-322: LGTM: debug log before auth check is useful.

Helpful for tracing connection/auth issues.

docs/v3/advanced/generate-custom-sdk.mdx (1)

7-174: Great step‑by‑step guide and examples.

The CLI, filtering, and Python usage sections are clear and actionable.

docs/docs.json (2)

262-268: LGTM: Advanced > Deployments grouping.

Navigation placement looks appropriate.


809-809: LGTM: CLI SDK reference added to navigation.

Makes the new CLI page discoverable.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Comment on lines +1 to +4
---
title: " "
sidebarTitle: prefect sdk
---

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Add a descriptive title in frontmatter.

Line 2 is a blank title; this yields empty page metadata. Consider a meaningful title for SEO and page headers.

🛠 Proposed fix
-title: " "
+title: "Prefect SDK CLI"
📝 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.

Suggested change
---
title: " "
sidebarTitle: prefect sdk
---
---
title: "Prefect SDK CLI"
sidebarTitle: prefect sdk
---
🤖 Prompt for AI Agents
In `@docs/v3/api-ref/cli/sdk.mdx` around lines 1 - 4, The frontmatter has an empty
title field; replace the blank title value with a meaningful, SEO-friendly
string (e.g., "Prefect SDK" or a concise descriptive title) by updating the
title frontmatter key while preserving other keys like sidebarTitle so the page
metadata and header render correctly.

Requires an active Prefect API connection (use `prefect cloud login` or configure
PREFECT_API_URL).



Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove the stray control character near Line 44.

Line 44 contains a hidden control character (looks like a backspace). It can cause render or lint issues; please delete it.

🤖 Prompt for AI Agents
In `@docs/v3/api-ref/cli/sdk.mdx` at line 44, Remove the stray hidden control
character found at Line 44 in docs/v3/api-ref/cli/sdk.mdx by deleting the
non-printable/backspace character so the file contains only valid text; confirm
the character is gone by opening the file in a hex-aware editor or running a
lint that highlights non-printable characters.

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