-
-
Notifications
You must be signed in to change notification settings - Fork 1
feat:Refactor OpenAPI spec to unify deployment schemas and add training support #86
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
Conversation
WalkthroughThe OpenAPI specification for the Replicate HTTP API was refactored to consolidate multiple inline schema definitions for deployment responses into a single reusable schema, Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant API
participant SchemaComponent
Client->>API: Request deployment or training endpoint
API->>SchemaComponent: Reference reusable schema (deployment or training)
SchemaComponent-->>API: Return structured response object
API-->>Client: Respond with standardized deployment/training object
Poem
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/libs/Replicate/openapi.yaml (1)
788-851: Suggest optional refactor: streamline schema naming and add required fields
The newschemas_deployment_responsedefinition works, but consider renaming it todeployment_response(dropping the redundantschemas_prefix) and adding arequiredarray at the root to enforce presence of critical properties, e.g.:components: schemas: deployment_response: type: object required: - owner - name - current_release properties: owner: { type: string } name: { type: string } current_release: $ref: '#/components/schemas/deployment_current_release'Splitting nested objects into sub-schemas can further improve readability and reuse.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (72)
src/libs/Replicate/Generated/JsonConverters.DeploymentsListResponseResultCurrentReleaseCreatedByType.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/JsonConverters.DeploymentsListResponseResultCurrentReleaseCreatedByTypeNullable.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/JsonConverters.SchemasDeploymentResponseCurrentReleaseCreatedByType.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/JsonConverters.SchemasDeploymentResponseCurrentReleaseCreatedByTypeNullable.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/JsonConverters.SchemasTrainingResponseSource.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/JsonConverters.SchemasTrainingResponseSourceNullable.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/JsonConverters.SchemasTrainingResponseStatus.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/JsonConverters.SchemasTrainingResponseStatusNullable.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/JsonSerializerContext.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/JsonSerializerContextTypes.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.IReplicateApi.DeploymentsCreate.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.IReplicateApi.DeploymentsGet.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.IReplicateApi.DeploymentsUpdate.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.IReplicateApi.TrainingsCancel.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.IReplicateApi.TrainingsCreate.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.IReplicateApi.TrainingsGet.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.IReplicateApi.TrainingsList.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.DeploymentsCreateResponseCurrentRelease.Json.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.DeploymentsCreateResponseCurrentRelease.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.DeploymentsCreateResponseCurrentReleaseConfiguration.Json.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.DeploymentsCreateResponseCurrentReleaseCreatedBy.Json.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.DeploymentsGetResponse.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.DeploymentsGetResponseCurrentRelease.Json.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.DeploymentsGetResponseCurrentRelease.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.DeploymentsGetResponseCurrentReleaseConfiguration.Json.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.DeploymentsGetResponseCurrentReleaseConfiguration.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.DeploymentsGetResponseCurrentReleaseCreatedBy.Json.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.DeploymentsGetResponseCurrentReleaseCreatedBy.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.DeploymentsGetResponseCurrentReleaseCreatedByType.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.DeploymentsListResponse.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.DeploymentsListResponseResult.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.DeploymentsListResponseResultCurrentRelease.Json.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.DeploymentsListResponseResultCurrentRelease.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.DeploymentsListResponseResultCurrentReleaseConfiguration.Json.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.DeploymentsListResponseResultCurrentReleaseConfiguration.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.DeploymentsListResponseResultCurrentReleaseCreatedBy.Json.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.DeploymentsListResponseResultCurrentReleaseCreatedBy.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.DeploymentsListResponseResultCurrentReleaseCreatedByType.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.DeploymentsUpdateResponse.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.DeploymentsUpdateResponseCurrentReleaseConfiguration.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.DeploymentsUpdateResponseCurrentReleaseCreatedBy.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.DeploymentsUpdateResponseCurrentReleaseCreatedByType.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.SchemasDeploymentResponse.Json.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.SchemasDeploymentResponse.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.SchemasDeploymentResponseCurrentRelease.Json.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.SchemasDeploymentResponseCurrentRelease.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.SchemasDeploymentResponseCurrentReleaseConfiguration.Json.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.SchemasDeploymentResponseCurrentReleaseConfiguration.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.SchemasDeploymentResponseCurrentReleaseCreatedBy.Json.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.SchemasDeploymentResponseCurrentReleaseCreatedBy.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.SchemasDeploymentResponseCurrentReleaseCreatedByType.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.SchemasTrainingResponse.Json.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.SchemasTrainingResponse.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.SchemasTrainingResponseInput.Json.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.SchemasTrainingResponseInput.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.SchemasTrainingResponseMetrics.Json.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.SchemasTrainingResponseMetrics.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.SchemasTrainingResponseOutput.Json.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.SchemasTrainingResponseOutput.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.SchemasTrainingResponseSource.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.SchemasTrainingResponseStatus.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.SchemasTrainingResponseUrls.Json.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.SchemasTrainingResponseUrls.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.TrainingsListResponse.Json.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.Models.TrainingsListResponse.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.ReplicateApi.DeploymentsCreate.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.ReplicateApi.DeploymentsGet.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.ReplicateApi.DeploymentsUpdate.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.ReplicateApi.TrainingsCancel.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.ReplicateApi.TrainingsCreate.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.ReplicateApi.TrainingsGet.g.csis excluded by!**/generated/**src/libs/Replicate/Generated/Replicate.ReplicateApi.TrainingsList.g.csis excluded by!**/generated/**
📒 Files selected for processing (1)
src/libs/Replicate/openapi.yaml(10 hunks)
🔇 Additional comments (8)
src/libs/Replicate/openapi.yaml (8)
95-95: Approve reuse of deployment response schema
Replacing the inline schema with$ref: '#/components/schemas/schemas_deployment_response'for the deployments list endpoint is correct and enhances consistency.
143-143: Approve reusable schema for create deployment response
The POST/deploymentsresponse now references the shared deployment schema, which avoids duplication.
188-188: Approve schema reference for get deployment
Using the sharedschemas_deployment_responsehere aligns the GET deployment endpoint with the rest of the spec.
234-234: Approve schema reference for update deployment
PATCH/deployments/{deployment_owner}/{deployment_name}correctly references the centralized deployment schema.
607-610: Approve training create response schema
The POST/models/{model_owner}/{model_name}/versions/{version_id}/trainingsendpoint now returns aschemas_training_response, which is the intended reusable object.
716-732: Approve paginated trainings list schema
GET/trainingsnow uses the newschemas_training_responsefor items inresults, providing consistent typing and pagination structure.
748-751: Approve single training fetch schema
GET/trainings/{training_id}correctly returns the new training response schema reference.
766-769: Approve cancel training response schema
POST/trainings/{training_id}/cancelnow returns the full training object, matching the other training endpoints.
| schemas_training_response: | ||
| type: object | ||
| properties: | ||
| completed_at: | ||
| type: string | ||
| description: The time when the training completed | ||
| format: date-time | ||
| created_at: | ||
| type: string | ||
| description: The time when the training was created | ||
| format: date-time | ||
| error: | ||
| type: string | ||
| description: Error message if the training failed | ||
| nullable: true | ||
| id: | ||
| type: string | ||
| description: The unique ID of the training | ||
| input: | ||
| type: object | ||
| description: The input parameters used for the training | ||
| logs: | ||
| type: string | ||
| description: The logs from the training process | ||
| metrics: | ||
| type: object | ||
| properties: | ||
| predict_time: | ||
| type: number | ||
| description: 'The amount of CPU or GPU time, in seconds, that the training used while running' | ||
| description: Metrics about the training process | ||
| model: | ||
| type: string | ||
| description: The name of the model in the format owner/name | ||
| output: | ||
| type: object | ||
| properties: | ||
| version: | ||
| type: string | ||
| description: The version of the model created by the training | ||
| weights: | ||
| type: string | ||
| description: The weights of the trained model | ||
| description: The output of the training process | ||
| source: | ||
| enum: | ||
| - web | ||
| - api | ||
| type: string | ||
| description: How the training was created | ||
| started_at: | ||
| type: string | ||
| description: The time when the training started | ||
| format: date-time | ||
| status: | ||
| enum: | ||
| - starting | ||
| - processing | ||
| - succeeded | ||
| - failed | ||
| - canceled | ||
| type: string | ||
| description: The current status of the training | ||
| urls: | ||
| type: object | ||
| properties: | ||
| cancel: | ||
| type: string | ||
| description: URL to cancel the training | ||
| format: uri | ||
| get: | ||
| type: string | ||
| description: URL to get the training details | ||
| format: uri | ||
| description: URLs for interacting with the training | ||
| version: |
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.
🛠️ Refactor suggestion
Suggest essential refactor: add required fields to training response schema
The new schemas_training_response defines properties but has no required declaration, leading to loose validation. To align with other response schemas (e.g., schemas_prediction_response), add a required list—at minimum including id, status, created_at, input, and urls. For example:
schemas_training_response:
type: object
required:
- id
- status
- created_at
- input
- urls
properties:
id: { type: string }
status:
enum: [starting, processing, succeeded, failed, canceled]
created_at:
type: string
format: date-time
...This ensures clients can rely on these fields being present.
Summary by CodeRabbit
New Features
Refactor