Add documentation for prefect sdk generate CLI#1
Conversation
- 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>
📝 WalkthroughWalkthroughNew documentation pages describe custom Python SDK generation functionality for Prefect deployments via CLI. Documentation structure reorganized to include SDK references. Core SDK fetcher implementation refined with logging, simplified extraction logic, relaxed iteration constraints, and adjusted deployment filtering to support both short and full names. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
|
@coderabbitai review |
1 similar comment
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
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 (1)
src/prefect/_sdk/fetcher.py (1)
396-421:⚠️ Potential issue | 🟡 MinorShort-name ambiguity warnings can be skipped for direct matches.
Whendep.nameis indeployment_names, the block is bypassed andshort_name_matchesisn’t populated, so ambiguity warnings won’t fire for short-name filters. Consider tracking short-name matches even when the name is directly listed.🔧 Suggested adjustment
- if deployment_names and dep.name not in deployment_names: + if 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 dep.name in deployment_names: + found_match = True + matched_short_name = dep.name + else: + 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`:
- Around line 37-45: Remove the stray control character line inside the Info
block in the docs/v3/api-ref/cli/sdk.mdx file — locate the "Info" block
containing "(beta) Generate a typed Python SDK..." and delete the lone
control-character-only line between the PREFECT_API_URL sentence and the
"Examples:" heading so the Info block contains only valid text lines.
In `@src/prefect/_sdk/fetcher.py`:
- Around line 219-221: The zip over pool_names_list and results should use
strict=True to satisfy Ruff B905 and ensure lengths match; update the zip(...)
call where pool_names_list and results are iterated (the loop that populates
work_pools) to zip(pool_names_list, results, strict=True) so mismatched lengths
raise immediately—modify the for loop that currently reads for name, result in
zip(pool_names_list, results): to include the strict parameter.
| <Info> | ||
| (beta) Generate a typed Python SDK from workspace deployments. | ||
|
|
||
| The generated SDK provides IDE autocomplete and type checking for your deployments. | ||
| Requires an active Prefect API connection (use `prefect cloud login` or configure | ||
| PREFECT_API_URL). | ||
|
|
||
| Examples: |
There was a problem hiding this comment.
Remove the stray control character in the Info block.
The lone control character line can render as a broken glyph or fail linting; please delete it.
🔧 Proposed removal
-�🤖 Prompt for AI Agents
In `@docs/v3/api-ref/cli/sdk.mdx` around lines 37 - 45, Remove the stray control
character line inside the Info block in the docs/v3/api-ref/cli/sdk.mdx file —
locate the "Info" block containing "(beta) Generate a typed Python SDK..." and
delete the lone control-character-only line between the PREFECT_API_URL sentence
and the "Examples:" heading so the Info block contains only valid text lines.
| work_pools: dict[str, WorkPoolInfo] = {} | ||
| for name, result in zip(pool_names_list, results, strict=True): | ||
| for name, result in zip(pool_names_list, results): | ||
| if isinstance(result, BaseException): |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check Python version requirements and Ruff configuration
rg -n --no-heading "requires-python|python_requires|target-version|tool\.ruff|B905" pyproject.toml setup.cfg setup.py 2>/dev/nullRepository: agentic-review-benchmarks/prefect-combined-coderabbit
Length of output: 309
🏁 Script executed:
#!/bin/bash
# Read the Ruff configuration section from pyproject.toml
sed -n '314,335p' pyproject.tomlRepository: agentic-review-benchmarks/prefect-combined-coderabbit
Length of output: 570
🏁 Script executed:
#!/bin/bash
# Read the code context around lines 219-221
sed -n '210,230p' src/prefect/_sdk/fetcher.pyRepository: agentic-review-benchmarks/prefect-combined-coderabbit
Length of output: 953
Add strict=True to the zip() call to resolve Ruff B905.
Since the project requires Python ≥3.10, the strict parameter is available. Both pool_names_list and results are guaranteed to have equal lengths (created from the same source list via list comprehension and asyncio.gather()), so strict=True is semantically correct:
🔧 Fix
- for name, result in zip(pool_names_list, results):
+ for name, result in zip(pool_names_list, results, strict=True):🧰 Tools
🪛 Ruff (0.14.14)
[warning] 220-220: zip() without an explicit strict= parameter
Add explicit value for parameter strict=
(B905)
🤖 Prompt for AI Agents
In `@src/prefect/_sdk/fetcher.py` around lines 219 - 221, The zip over
pool_names_list and results should use strict=True to satisfy Ruff B905 and
ensure lengths match; update the zip(...) call where pool_names_list and results
are iterated (the loop that populates work_pools) to zip(pool_names_list,
results, strict=True) so mismatched lengths raise immediately—modify the for
loop that currently reads for name, result in zip(pool_names_list, results): to
include the strict parameter.
Benchmark PR from agentic-review-benchmarks#1
Summary by CodeRabbit
New Features
prefect sdk generatecommand to create typed Python SDKs from workspace deployments with filtering by flow and deployment names.Documentation