Skip to content

Commit 1fef018

Browse files
committed
Use VCR recordings for tests
Signed-off-by: Mattt Zmuda <[email protected]>
1 parent 0beaf07 commit 1fef018

17 files changed

+2514
-1179
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tests/cassettes/** binary
Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
Accept:
6+
- '*/*'
7+
Accept-Encoding:
8+
- gzip, deflate
9+
Connection:
10+
- keep-alive
11+
User-Agent:
12+
- replicate-python/0.11.0
13+
method: GET
14+
uri: https://api.replicate.com/v1/models/stability-ai/sdxl/versions/a00d0b7dcbb9c3fbb34ba87d2d5b46c56969c84a628bf778a7fdaec30b1b99c5
15+
response:
16+
body:
17+
string: '{"id":"a00d0b7dcbb9c3fbb34ba87d2d5b46c56969c84a628bf778a7fdaec30b1b99c5","created_at":"2023-08-11T17:00:23.916379Z","cog_version":"0.8.5","openapi_schema":{"info":{"title":"Cog","version":"0.1.0"},"paths":{"/":{"get":{"summary":"Root","responses":{"200":{"content":{"application/json":{"schema":{"title":"Response
18+
Root Get"}}},"description":"Successful Response"}},"operationId":"root__get"}},"/shutdown":{"post":{"summary":"Start
19+
Shutdown","responses":{"200":{"content":{"application/json":{"schema":{"title":"Response
20+
Start Shutdown Shutdown Post"}}},"description":"Successful Response"}},"operationId":"start_shutdown_shutdown_post"}},"/predictions":{"post":{"summary":"Predict","responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PredictionResponse"}}},"description":"Successful
21+
Response"},"422":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}},"description":"Validation
22+
Error"}},"parameters":[{"in":"header","name":"prefer","schema":{"type":"string","title":"Prefer"},"required":false}],"description":"Run
23+
a single prediction on the model","operationId":"predict_predictions_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PredictionRequest"}}}}}},"/health-check":{"get":{"summary":"Healthcheck","responses":{"200":{"content":{"application/json":{"schema":{"title":"Response
24+
Healthcheck Health Check Get"}}},"description":"Successful Response"}},"operationId":"healthcheck_health_check_get"}},"/predictions/{prediction_id}":{"put":{"summary":"Predict
25+
Idempotent","responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PredictionResponse"}}},"description":"Successful
26+
Response"},"422":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}},"description":"Validation
27+
Error"}},"parameters":[{"in":"path","name":"prediction_id","schema":{"type":"string","title":"Prediction
28+
ID"},"required":true},{"in":"header","name":"prefer","schema":{"type":"string","title":"Prefer"},"required":false}],"description":"Run
29+
a single prediction on the model (idempotent creation).","operationId":"predict_idempotent_predictions__prediction_id__put","requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/PredictionRequest"}],"title":"Prediction
30+
Request"}}},"required":true}}},"/predictions/{prediction_id}/cancel":{"post":{"summary":"Cancel","responses":{"200":{"content":{"application/json":{"schema":{"title":"Response
31+
Cancel Predictions Prediction Id Cancel Post"}}},"description":"Successful
32+
Response"},"422":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}},"description":"Validation
33+
Error"}},"parameters":[{"in":"path","name":"prediction_id","schema":{"type":"string","title":"Prediction
34+
ID"},"required":true}],"description":"Cancel a running prediction","operationId":"cancel_predictions__prediction_id__cancel_post"}}},"openapi":"3.0.2","components":{"schemas":{"Input":{"type":"object","title":"Input","properties":{"mask":{"type":"string","title":"Mask","format":"uri","x-order":3,"description":"Input
35+
mask for inpaint mode. Black areas will be preserved, white areas will be
36+
inpainted."},"seed":{"type":"integer","title":"Seed","x-order":11,"description":"Random
37+
seed. Leave blank to randomize the seed"},"image":{"type":"string","title":"Image","format":"uri","x-order":2,"description":"Input
38+
image for img2img or inpaint mode"},"width":{"type":"integer","title":"Width","default":1024,"x-order":4,"description":"Width
39+
of output image"},"height":{"type":"integer","title":"Height","default":1024,"x-order":5,"description":"Height
40+
of output image"},"prompt":{"type":"string","title":"Prompt","default":"An
41+
astronaut riding a rainbow unicorn","x-order":0,"description":"Input prompt"},"refine":{"allOf":[{"$ref":"#/components/schemas/refine"}],"default":"no_refiner","x-order":12,"description":"Which
42+
refine style to use"},"scheduler":{"allOf":[{"$ref":"#/components/schemas/scheduler"}],"default":"K_EULER","x-order":7,"description":"scheduler"},"lora_scale":{"type":"number","title":"Lora
43+
Scale","default":0.6,"maximum":1,"minimum":0,"x-order":16,"description":"LoRA
44+
additive scale. Only applicable on trained models."},"num_outputs":{"type":"integer","title":"Num
45+
Outputs","default":1,"maximum":4,"minimum":1,"x-order":6,"description":"Number
46+
of images to output."},"refine_steps":{"type":"integer","title":"Refine Steps","x-order":14,"description":"For
47+
base_image_refiner, the number of steps to refine, defaults to num_inference_steps"},"guidance_scale":{"type":"number","title":"Guidance
48+
Scale","default":7.5,"maximum":50,"minimum":1,"x-order":9,"description":"Scale
49+
for classifier-free guidance"},"apply_watermark":{"type":"boolean","title":"Apply
50+
Watermark","default":true,"x-order":15,"description":"Applies a watermark
51+
to enable determining if an image is generated in downstream applications.
52+
If you have other provisions for generating or deploying images safely, you
53+
can use this to disable watermarking."},"high_noise_frac":{"type":"number","title":"High
54+
Noise Frac","default":0.8,"maximum":1,"minimum":0,"x-order":13,"description":"For
55+
expert_ensemble_refiner, the fraction of noise to use"},"negative_prompt":{"type":"string","title":"Negative
56+
Prompt","default":"","x-order":1,"description":"Input Negative Prompt"},"prompt_strength":{"type":"number","title":"Prompt
57+
Strength","default":0.8,"maximum":1,"minimum":0,"x-order":10,"description":"Prompt
58+
strength when using img2img / inpaint. 1.0 corresponds to full destruction
59+
of information in image"},"num_inference_steps":{"type":"integer","title":"Num
60+
Inference Steps","default":50,"maximum":500,"minimum":1,"x-order":8,"description":"Number
61+
of denoising steps"}}},"Output":{"type":"array","items":{"type":"string","format":"uri"},"title":"Output"},"Status":{"enum":["starting","processing","succeeded","canceled","failed"],"type":"string","title":"Status","description":"An
62+
enumeration."},"refine":{"enum":["no_refiner","expert_ensemble_refiner","base_image_refiner"],"type":"string","title":"refine","description":"An
63+
enumeration."},"scheduler":{"enum":["DDIM","DPMSolverMultistep","HeunDiscrete","KarrasDPM","K_EULER_ANCESTRAL","K_EULER","PNDM"],"type":"string","title":"scheduler","description":"An
64+
enumeration."},"WebhookEvent":{"enum":["start","output","logs","completed"],"type":"string","title":"WebhookEvent","description":"An
65+
enumeration."},"ValidationError":{"type":"object","title":"ValidationError","required":["loc","msg","type"],"properties":{"loc":{"type":"array","items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error
66+
Type"}}},"PredictionRequest":{"type":"object","title":"PredictionRequest","properties":{"id":{"type":"string","title":"Id"},"input":{"$ref":"#/components/schemas/Input"},"webhook":{"type":"string","title":"Webhook","format":"uri","maxLength":65536,"minLength":1},"created_at":{"type":"string","title":"Created
67+
At","format":"date-time"},"output_file_prefix":{"type":"string","title":"Output
68+
File Prefix"},"webhook_events_filter":{"type":"array","items":{"$ref":"#/components/schemas/WebhookEvent"},"default":["start","completed","logs","output"],"uniqueItems":true}}},"PredictionResponse":{"type":"object","title":"PredictionResponse","properties":{"id":{"type":"string","title":"Id"},"logs":{"type":"string","title":"Logs","default":""},"error":{"type":"string","title":"Error"},"input":{"$ref":"#/components/schemas/Input"},"output":{"$ref":"#/components/schemas/Output"},"status":{"$ref":"#/components/schemas/Status"},"metrics":{"type":"object","title":"Metrics"},"version":{"type":"string","title":"Version"},"created_at":{"type":"string","title":"Created
69+
At","format":"date-time"},"started_at":{"type":"string","title":"Started At","format":"date-time"},"completed_at":{"type":"string","title":"Completed
70+
At","format":"date-time"}}},"HTTPValidationError":{"type":"object","title":"HTTPValidationError","properties":{"detail":{"type":"array","items":{"$ref":"#/components/schemas/ValidationError"},"title":"Detail"}}}}}}}'
71+
headers:
72+
CF-Cache-Status:
73+
- DYNAMIC
74+
CF-RAY:
75+
- 7fdbf06afe2ec38e-SEA
76+
Connection:
77+
- keep-alive
78+
Content-Encoding:
79+
- gzip
80+
Content-Type:
81+
- application/json
82+
Date:
83+
- Mon, 28 Aug 2023 10:40:58 GMT
84+
NEL:
85+
- '{"success_fraction":0,"report_to":"cf-nel","max_age":604800}'
86+
Report-To:
87+
- '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=lqn6vZtiIEuD6ah43djQbwFcdhqmKZXq1T3A%2Bep1EXRg60x7ti4mgtoXcXd8wvjbi65JeGhwqeW%2B2tMRKx%2B0i0tJRtYcZylABbnBdtYNkp4lTeuq5BY9r7TOIYehrRHx192O"}],"group":"cf-nel","max_age":604800}'
88+
Server:
89+
- cloudflare
90+
Strict-Transport-Security:
91+
- max-age=15552000
92+
Transfer-Encoding:
93+
- chunked
94+
allow:
95+
- GET, DELETE, HEAD, OPTIONS
96+
content-security-policy-report-only:
97+
- 'media-src ''report-sample'' ''self'' https://replicate.delivery https://*.replicate.delivery
98+
https://*.mux.com https://*.gstatic.com https://*.sentry.io; connect-src ''report-sample''
99+
''self'' https://replicate.delivery https://*.replicate.delivery https://*.rudderlabs.com
100+
https://*.rudderstack.com https://*.mux.com https://*.sentry.io; font-src
101+
''report-sample'' ''self'' data: https://fonts.replicate.ai https://fonts.gstatic.com;
102+
script-src ''report-sample'' ''self'' https://cdn.rudderlabs.com/v1.1/rudder-analytics.min.js;
103+
worker-src ''none''; img-src ''report-sample'' ''self'' data: https://replicate.delivery
104+
https://*.replicate.delivery https://*.githubusercontent.com https://github.com;
105+
style-src ''report-sample'' ''self'' ''unsafe-inline'' https://fonts.googleapis.com;
106+
default-src ''self''; report-uri'
107+
cross-origin-opener-policy:
108+
- same-origin
109+
ratelimit-remaining:
110+
- '2999'
111+
ratelimit-reset:
112+
- '1'
113+
referrer-policy:
114+
- same-origin
115+
vary:
116+
- Cookie, origin
117+
via:
118+
- 1.1 vegur, 1.1 google
119+
x-content-type-options:
120+
- nosniff
121+
x-frame-options:
122+
- DENY
123+
status:
124+
code: 200
125+
message: OK
126+
- request:
127+
body: '{"version": "a00d0b7dcbb9c3fbb34ba87d2d5b46c56969c84a628bf778a7fdaec30b1b99c5",
128+
"input": {"prompt": "a studio photo of a rainbow colored corgi", "width": 512,
129+
"height": 512, "seed": 42069}}'
130+
headers:
131+
Accept:
132+
- '*/*'
133+
Accept-Encoding:
134+
- gzip, deflate
135+
Connection:
136+
- keep-alive
137+
Content-Length:
138+
- '189'
139+
Content-Type:
140+
- application/json
141+
User-Agent:
142+
- replicate-python/0.11.0
143+
method: POST
144+
uri: https://api.replicate.com/v1/predictions
145+
response:
146+
body:
147+
string: '{"id":"dj2xhz3b6iihe2ewh3d3fdtram","version":"a00d0b7dcbb9c3fbb34ba87d2d5b46c56969c84a628bf778a7fdaec30b1b99c5","input":{"height":512,"prompt":"a
148+
studio photo of a rainbow colored corgi","seed":42069,"width":512},"logs":"","error":null,"status":"starting","created_at":"2023-08-28T10:40:58.313900179Z","urls":{"cancel":"https://api.replicate.com/v1/predictions/dj2xhz3b6iihe2ewh3d3fdtram/cancel","get":"https://api.replicate.com/v1/predictions/dj2xhz3b6iihe2ewh3d3fdtram"}}
149+
150+
'
151+
headers:
152+
CF-Cache-Status:
153+
- DYNAMIC
154+
CF-RAY:
155+
- 7fdbf06bef6aeb53-SEA
156+
Connection:
157+
- keep-alive
158+
Content-Length:
159+
- '474'
160+
Content-Type:
161+
- application/json
162+
Date:
163+
- Mon, 28 Aug 2023 10:40:58 GMT
164+
NEL:
165+
- '{"success_fraction":0,"report_to":"cf-nel","max_age":604800}'
166+
Report-To:
167+
- '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=%2BvAgJlOECQToRU65Zaf3t3e27iqz%2Fyt3cIYchCouUpOy%2FXvjIiIe%2BDAC4DYVSBKV6OznfDoLuOTF%2BzC9XodVLtQ6NQcTC1jB5sTHLgUf4n5w%2FknHpcXlYPI23jyU9eD72cUt"}],"group":"cf-nel","max_age":604800}'
168+
Server:
169+
- cloudflare
170+
Strict-Transport-Security:
171+
- max-age=15552000
172+
ratelimit-remaining:
173+
- '599'
174+
ratelimit-reset:
175+
- '1'
176+
via:
177+
- 1.1 google
178+
status:
179+
code: 201
180+
message: Created
181+
- request:
182+
body: null
183+
headers:
184+
Accept:
185+
- '*/*'
186+
Accept-Encoding:
187+
- gzip, deflate
188+
Connection:
189+
- keep-alive
190+
Content-Length:
191+
- '0'
192+
User-Agent:
193+
- replicate-python/0.11.0
194+
method: POST
195+
uri: https://api.replicate.com/v1/predictions/dj2xhz3b6iihe2ewh3d3fdtram/cancel
196+
response:
197+
body:
198+
string: '{"completed_at":"2023-08-28T10:40:58.480860Z","created_at":"2023-08-28T10:40:58.385013Z","error":null,"id":"dj2xhz3b6iihe2ewh3d3fdtram","input":{"seed":42069,"width":512,"height":512,"prompt":"a
199+
studio photo of a rainbow colored corgi"},"logs":null,"metrics":{"predict_time":2e-06},"output":null,"started_at":"2023-08-28T10:40:58.480858Z","status":"canceled","urls":{"get":"https://api.replicate.com/v1/predictions/dj2xhz3b6iihe2ewh3d3fdtram","cancel":"https://api.replicate.com/v1/predictions/dj2xhz3b6iihe2ewh3d3fdtram/cancel"},"version":"a00d0b7dcbb9c3fbb34ba87d2d5b46c56969c84a628bf778a7fdaec30b1b99c5","webhook_completed":null}'
200+
headers:
201+
CF-Cache-Status:
202+
- DYNAMIC
203+
CF-RAY:
204+
- 7fdbf06d0deac766-SEA
205+
Connection:
206+
- keep-alive
207+
Content-Encoding:
208+
- gzip
209+
Content-Type:
210+
- application/json
211+
Date:
212+
- Mon, 28 Aug 2023 10:40:58 GMT
213+
NEL:
214+
- '{"success_fraction":0,"report_to":"cf-nel","max_age":604800}'
215+
Report-To:
216+
- '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=jeEQzHBiX9tZ4IdkiEgJjenWYtZvy3CafnOWdp%2BQZDH7ox2wiTLTfB57ya0p%2BwCYVTB0ITeL5DAfZBsnpGv9D1zctc%2FkSID7QL9f4QikvyILNB%2BPSvRf8jLYjWN7UfJ2l9g7"}],"group":"cf-nel","max_age":604800}'
217+
Server:
218+
- cloudflare
219+
Strict-Transport-Security:
220+
- max-age=15552000
221+
Transfer-Encoding:
222+
- chunked
223+
ratelimit-remaining:
224+
- '2999'
225+
ratelimit-reset:
226+
- '1'
227+
via:
228+
- 1.1 google
229+
status:
230+
code: 200
231+
message: OK
232+
version: 1

0 commit comments

Comments
 (0)