-
Couldn't load subscription status.
- Fork 240
feat: update types to match OpenAPI schema #363
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| declare module "replicate" { | ||
| type Status = "starting" | "processing" | "succeeded" | "failed" | "canceled" | "aborted"; | ||
| type Status = "starting" | "processing" | "succeeded" | "failed" | "canceled"; | ||
| type Visibility = "public" | "private"; | ||
| type WebhookEventType = "start" | "output" | "logs" | "completed"; | ||
|
|
||
|
|
@@ -19,6 +19,7 @@ declare module "replicate" { | |
| username: string; | ||
| name: string; | ||
| github_url?: string; | ||
| avatar_url?: string; | ||
| } | ||
|
|
||
| export interface Collection { | ||
|
|
@@ -48,11 +49,11 @@ declare module "replicate" { | |
|
|
||
| export interface FileObject { | ||
| id: string; | ||
| name: string; | ||
| content_type: string; | ||
| size: number; | ||
| etag: string; | ||
| checksum: string; | ||
| checksums: { | ||
| sha256: string; | ||
| }; | ||
| metadata: Record<string, unknown>; | ||
| created_at: string; | ||
| expires_at: string | null; | ||
|
|
@@ -85,22 +86,26 @@ declare module "replicate" { | |
| export interface ModelVersion { | ||
| id: string; | ||
| created_at: string; | ||
| cog_version: string; | ||
| openapi_schema: object; | ||
| cog_version: string | null; | ||
| openapi_schema: object | null; | ||
| } | ||
|
|
||
| export interface Prediction { | ||
| id: string; | ||
| status: Status; | ||
| model: string; | ||
| version: string; | ||
| version: string | "hidden"; | ||
| input: object; | ||
| output?: any; // TODO: this should be `unknown` | ||
| source: "api" | "web"; | ||
| error?: unknown; | ||
| logs?: string; | ||
| data_removed: boolean; | ||
| deadline?: string; | ||
| deployment?: string; | ||
| metrics?: { | ||
| predict_time?: number; | ||
| total_time?: number; | ||
| }; | ||
| webhook?: string; | ||
| webhook_events_filter?: WebhookEventType[]; | ||
|
|
@@ -111,10 +116,37 @@ declare module "replicate" { | |
| get: string; | ||
| cancel: string; | ||
| stream?: string; | ||
| web?: string; | ||
| }; | ||
| } | ||
|
|
||
| export type Training = Prediction; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @zeke Do we want to move to training being a standalone type? Currently it mirrors There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Training and Prediction have different fields according to the OpenAPI schema, so I think they should be separate types: Fields in Prediction but NOT in Training:
Type differences:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe these are also just inconsistencies between Training and Prediction in the OpenAPI schema, but I don't actually know. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, fair! I'm not sure. 😔 I wouldn't be surprised if there were inconsistencies there. Good to clean it up. |
||
| export interface Training { | ||
| id: string; | ||
| status: Status; | ||
| model: string; | ||
| version: string; | ||
| input: object; | ||
| output?: { | ||
| version?: string; | ||
| weights?: string; | ||
| }; | ||
| source: "api" | "web"; | ||
| error?: unknown; | ||
| logs?: string; | ||
| metrics?: { | ||
| predict_time?: number; | ||
| total_time?: number; | ||
| }; | ||
| webhook?: string; | ||
| webhook_events_filter?: WebhookEventType[]; | ||
| created_at: string; | ||
| started_at?: string; | ||
| completed_at?: string; | ||
| urls: { | ||
| get: string; | ||
| cancel: string; | ||
| }; | ||
| } | ||
|
|
||
| export type FileEncodingStrategy = "default" | "upload" | "data-uri"; | ||
|
|
||
|
|
||
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.
Are we still using aborted, @erbridge? Just noticed it because we were discussing statuses today.
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.
Looks like it's defined and used in replicate/api, but not yet documented in the OpenAPI schema.
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.
We are using it, so we should probably update the schema.
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.
PR: https://github.com/replicate/api/pull/2069
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.
☝🏼 Shipped.
Uh oh!
There was an error while loading. Please reload this page.
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.
Updated this PR: d702154