forked from qodo-benchmark/prefect
-
Notifications
You must be signed in to change notification settings - Fork 0
Add Naming & Data Models for Custom Deployment SDK #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tomerqodo
wants to merge
2
commits into
qodo_combined-20260114-qodo-grep-copilot_base_add_naming__data_models_for_custom_deployment_sdk_pr365
Choose a base branch
from
qodo_combined-20260114-qodo-grep-copilot_head_add_naming__data_models_for_custom_deployment_sdk_pr365
base: qodo_combined-20260114-qodo-grep-copilot_base_add_naming__data_models_for_custom_deployment_sdk_pr365
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| """ | ||
| Data models for SDK generation. | ||
|
|
||
| This module contains the internal data models used to represent workspace data | ||
| fetched from the Prefect API, which are then passed to the template renderer. | ||
|
|
||
| Note: These models are internal to SDK generation and not part of the public API. | ||
| """ | ||
|
|
||
| from dataclasses import dataclass, field | ||
| from typing import Any | ||
|
|
||
|
|
||
| @dataclass | ||
| class WorkPoolInfo: | ||
| """Information about a work pool needed for SDK generation. | ||
|
|
||
| Attributes: | ||
| name: The work pool name as it appears in Prefect. | ||
| pool_type: The work pool type (e.g., "kubernetes", "docker", "process"). | ||
| job_variables_schema: JSON Schema dict for the work pool's job variables. | ||
| This is the full schema object (e.g., {"type": "object", "properties": {...}}) | ||
| from base_job_template["variables"]. Can be empty dict if no job | ||
| variables are defined. | ||
| """ | ||
|
|
||
| name: str | ||
| pool_type: str | ||
| job_variables_schema: dict[str, Any] = field(default_factory=dict) | ||
|
|
||
|
|
||
| @dataclass | ||
| class DeploymentInfo: | ||
| """Information about a deployment needed for SDK generation. | ||
|
|
||
| Attributes: | ||
| name: The deployment name (just the deployment part, not flow/deployment). | ||
| flow_name: The name of the flow this deployment belongs to. | ||
| full_name: The full deployment name in "flow-name/deployment-name" format. | ||
| parameter_schema: JSON Schema dict for the flow's parameters. | ||
| This comes from the deployment's parameter_openapi_schema field. | ||
| Can be empty dict or None if the flow has no parameters. | ||
| work_pool_name: Name of the work pool this deployment uses. | ||
| Can be None if the deployment doesn't use a work pool. | ||
| description: Optional deployment description for docstrings. | ||
| """ | ||
|
|
||
| name: str | ||
| flow_name: str | ||
| full_name: str | ||
| parameter_schema: dict[str, Any] | None = None | ||
| work_pool_name: str | None = None | ||
| description: str | None = None | ||
|
|
||
|
|
||
| @dataclass | ||
| class FlowInfo: | ||
| """Information about a flow and its deployments. | ||
|
|
||
| Groups deployments by their parent flow for organized SDK generation. | ||
|
|
||
| Attributes: | ||
| name: The flow name. | ||
| deployments: List of deployments belonging to this flow. | ||
| """ | ||
|
|
||
| name: str | ||
| deployments: list[DeploymentInfo] = field(default_factory=list) | ||
|
|
||
|
|
||
| @dataclass | ||
| class SDKGenerationMetadata: | ||
| """Metadata about the SDK generation process. | ||
|
|
||
| Attributes: | ||
| generation_time: ISO 8601 timestamp of when the SDK was generated. | ||
| prefect_version: Version of Prefect used for generation. | ||
| workspace_name: Name of the workspace (if applicable). | ||
| api_url: The Prefect API URL used. | ||
| """ | ||
|
|
||
| generation_time: str | ||
| prefect_version: str | ||
| workspace_name: str | None = None | ||
| api_url: str | None = None | ||
|
|
||
|
|
||
| @dataclass | ||
| class SDKData: | ||
| """Complete data needed for SDK generation. | ||
|
|
||
| This is the top-level container passed to the template renderer. | ||
|
|
||
| Attributes: | ||
| metadata: Generation metadata (time, version, workspace). | ||
| flows: Dictionary mapping flow names to FlowInfo objects. | ||
| work_pools: Dictionary mapping work pool names to WorkPoolInfo objects. | ||
| """ | ||
|
|
||
| metadata: SDKGenerationMetadata | ||
| flows: dict[str, FlowInfo] = field(default_factory=dict) | ||
| work_pools: dict[str, WorkPoolInfo] = field(default_factory=dict) | ||
|
|
||
| @property | ||
| def deployment_count(self) -> int: | ||
| """Total number of deployments across all flows.""" | ||
| return sum(len(flow.deployments) for flow in self.flows.values()) | ||
|
|
||
| @property | ||
| def flow_count(self) -> int: | ||
| """Number of flows.""" | ||
| return len(self.flows) | ||
|
|
||
| @property | ||
| def work_pool_count(self) -> int: | ||
| """Number of work pools.""" | ||
| return len(self.work_pools) | ||
|
|
||
| @property | ||
| def deployment_names(self) -> list[str]: | ||
| """List of all deployment full names (derived from flows). | ||
|
|
||
| Returns names sorted alphabetically for deterministic code generation. | ||
| """ | ||
| names: list[str] = [] | ||
| for flow in self.flows.values(): | ||
| for deployment in flow.deployments: | ||
| names.append(deployment.name) | ||
| return sorted(names) | ||
|
|
||
| def all_deployments(self) -> list[DeploymentInfo]: | ||
| """Return a flat list of all deployments. | ||
|
|
||
| Returns deployments sorted by full_name for deterministic code generation. | ||
| """ | ||
| deployments: list[DeploymentInfo] = [] | ||
| for flow in self.flows.values(): | ||
| deployments.extend(flow.deployments) | ||
| return sorted(deployments, key=lambda d: d.full_name) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1.
deployment_namesreturns wrong values📘 Rule ViolationAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools