File tree Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,12 @@ export default class Model extends ReplicateObject {
40
40
return `GET /v1/models/${ this . owner } /${ this . name } /versions/${ this . version } ` ;
41
41
}
42
42
43
+ async deleteVersion ( ) {
44
+ await this . client . request (
45
+ `DELETE /v1/models/${ this . owner } /${ this . name } /versions/${ this . version } `
46
+ ) ;
47
+ }
48
+
43
49
async predict (
44
50
input ,
45
51
{ onUpdate, onTemporaryError } = { } ,
Original file line number Diff line number Diff line change @@ -69,6 +69,18 @@ describe("load()", () => {
69
69
} ) ;
70
70
} ) ;
71
71
72
+ describe ( "deleteVersion()" , ( ) => {
73
+ it ( "makes request to delete model version" , async ( ) => {
74
+ jest . spyOn ( client , "request" ) . mockResolvedValue ( ) ;
75
+
76
+ await model . deleteVersion ( ) ;
77
+
78
+ expect ( client . request ) . toHaveBeenCalledWith (
79
+ "DELETE /v1/models/test-owner/test-name/versions/testversion"
80
+ ) ;
81
+ } ) ;
82
+ } ) ;
83
+
72
84
describe ( "predict()" , ( ) => {
73
85
it ( "makes request to create prediction" , async ( ) => {
74
86
jest . spyOn ( model , "createPrediction" ) . mockResolvedValue (
Original file line number Diff line number Diff line change @@ -147,7 +147,7 @@ export default class ReplicateClient {
147
147
}
148
148
149
149
#parseAction( action ) {
150
- const result = / ^ ( G E T | P O S T ) ( \/ [ ^ \s ] + ) $ / . exec ( action ) ;
150
+ const result = / ^ ( G E T | P O S T | D E L E T E ) ( \/ [ ^ \s ] + ) $ / . exec ( action ) ;
151
151
152
152
if ( ! result ) {
153
153
throw new ReplicateError ( `Invalid action: ${ action } ` ) ;
You can’t perform that action at this time.
0 commit comments