Skip to content

Commit 9d190ea

Browse files
authored
Add model field to Prediction and Training classes (#199)
Signed-off-by: Mattt Zmuda <[email protected]>
1 parent 4944316 commit 9d190ea

22 files changed

+89778
-30136
lines changed

replicate/prediction.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ class Prediction(Resource):
3131
id: str
3232
"""The unique ID of the prediction."""
3333

34+
model: str
35+
"""An identifier for the model used to create the prediction, in the form `owner/name`."""
36+
3437
version: str
3538
"""An identifier for the version of the model used to create the prediction."""
3639

replicate/training.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ class Training(Resource):
4040
id: str
4141
"""The unique ID of the training."""
4242

43+
model: str
44+
"""An identifier for the model used to create the prediction, in the form `owner/name`."""
45+
4346
version: Union[str, Version]
4447
"""The version of the model used to create the training."""
4548

tests/cassettes/collections-get.yaml

Lines changed: 83 additions & 9247 deletions
Large diffs are not rendered by default.

tests/cassettes/collections-list.yaml

Lines changed: 14 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -1,148 +1,4 @@
11
interactions:
2-
- request:
3-
body: ''
4-
headers:
5-
accept:
6-
- '*/*'
7-
accept-encoding:
8-
- gzip, deflate
9-
connection:
10-
- keep-alive
11-
host:
12-
- api.replicate.com
13-
user-agent:
14-
- replicate-python/0.15.6
15-
method: GET
16-
uri: https://api.replicate.com/collections
17-
response:
18-
content: "response 404 (backend NotFound), service rules for the path non-existent
19-
\n"
20-
headers:
21-
CF-Cache-Status:
22-
- DYNAMIC
23-
CF-RAY:
24-
- 82253fddaa5630b7-SEA
25-
Connection:
26-
- keep-alive
27-
Content-Encoding:
28-
- gzip
29-
Content-Type:
30-
- text/plain; charset=utf-8
31-
Date:
32-
- Tue, 07 Nov 2023 11:31:21 GMT
33-
NEL:
34-
- '{"success_fraction":0,"report_to":"cf-nel","max_age":604800}'
35-
Report-To:
36-
- '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=uQfbIfp7jcTaOeMfw6BHB2jikbc2CC%2Fg96weVmmeYXUm5SblRi9QlWrSJVrVOzpUKMRTMYPJqlqXfeb57%2B19Sp%2BRjAejz94aldajmm3w%2F7dzpOL4rEebSCnushZtGz9ZDRbC"}],"group":"cf-nel","max_age":604800}'
37-
Server:
38-
- cloudflare
39-
Strict-Transport-Security:
40-
- max-age=15552000
41-
Transfer-Encoding:
42-
- chunked
43-
via:
44-
- 1.1 google
45-
http_version: HTTP/1.1
46-
status_code: 404
47-
- request:
48-
body: ''
49-
headers:
50-
accept:
51-
- '*/*'
52-
accept-encoding:
53-
- gzip, deflate
54-
connection:
55-
- keep-alive
56-
host:
57-
- api.replicate.com
58-
user-agent:
59-
- replicate-python/0.15.6
60-
method: GET
61-
uri: https://api.replicate.com/v1/collections
62-
response:
63-
content: '{"next":null,"previous":null,"results":[{"name":"Halloween","slug":"halloween","description":"Spooky,
64-
scary, frightful models."},{"name":"Vision models","slug":"vision-models","description":"Multimodal
65-
large language models with vision capabilities like object detection and optical
66-
character recognition (OCR)"},{"name":"T2I-Adapter","slug":"t2i-adapter","description":"T2I-Adapter
67-
models to modify images"},{"name":"Language models with support for grammars
68-
and jsonschema","slug":"language-models-with-grammar","description":"Language
69-
models that support grammar-based decoding as well as jsonschema constraints."},{"name":"SDXL
70-
fine-tunes","slug":"sdxl-fine-tunes","description":"Some of our favorite SDXL
71-
fine-tunes."},{"name":"Streaming language models","slug":"streaming-language-models","description":"Language
72-
models that support streaming responses. See https://replicate.com/docs/streaming"},{"name":"Image
73-
editing","slug":"image-editing","description":"Tools for manipulating images."},{"name":"Embedding
74-
models","slug":"embedding-models","description":"Models that generate embeddings
75-
from inputs"},{"name":"Trainable language models","slug":"trainable-language-models","description":"Language
76-
models that you can fine-tune using Replicate''s training API."},{"name":"Language
77-
models","slug":"language-models","description":"Models that can understand and
78-
generate text"},{"name":"ControlNet","slug":"control-net","description":"Control
79-
diffusion models"},{"name":"Audio generation","slug":"audio-generation","description":"Models
80-
to generate and modify audio"},{"name":"Diffusion models","slug":"diffusion-models","description":"Image
81-
and video generation models trained with diffusion processes"},{"name":"Videos","slug":"text-to-video","description":"Models
82-
that create and edit videos"},{"name":"Image to text","slug":"image-to-text","description":"Models
83-
that generate text prompts and captions from images"},{"name":"Super resolution","slug":"super-resolution","description":"Upscaling
84-
models that create high-quality images from low-quality images"},{"name":"Style
85-
transfer","slug":"style-transfer","description":"Models that take a content
86-
image and a style reference to produce a new image"},{"name":"ML makeovers","slug":"ml-makeovers","description":"Models
87-
that let you change facial features"},{"name":"Image restoration","slug":"image-restoration","description":"Models
88-
that improve or restore images by deblurring, colorization, and removing noise"},{"name":"Text
89-
to image","slug":"text-to-image","description":"Models that generate images
90-
from text prompts"}]}'
91-
headers:
92-
CF-Cache-Status:
93-
- DYNAMIC
94-
CF-RAY:
95-
- 822540d7cb34c36c-SEA
96-
Connection:
97-
- keep-alive
98-
Content-Encoding:
99-
- gzip
100-
Content-Type:
101-
- application/json
102-
Date:
103-
- Tue, 07 Nov 2023 11:32:02 GMT
104-
Server:
105-
- cloudflare
106-
Strict-Transport-Security:
107-
- max-age=15552000
108-
Transfer-Encoding:
109-
- chunked
110-
allow:
111-
- GET, HEAD, OPTIONS
112-
content-security-policy-report-only:
113-
- 'style-src ''report-sample'' ''self'' ''unsafe-inline''; img-src ''report-sample''
114-
''self'' data: https://replicate.delivery https://*.replicate.delivery https://*.githubusercontent.com
115-
https://github.com; default-src ''self''; media-src ''report-sample'' ''self''
116-
https://replicate.delivery https://*.replicate.delivery https://*.mux.com
117-
https://*.sentry.io; font-src ''report-sample'' ''self'' data:; connect-src
118-
''report-sample'' ''self'' https://replicate.delivery https://*.replicate.delivery
119-
https://*.rudderlabs.com https://*.rudderstack.com https://*.mux.com https://*.sentry.io;
120-
script-src ''report-sample'' ''self'' https://cdn.rudderlabs.com/v1.1/rudder-analytics.min.js;
121-
worker-src ''none''; report-uri'
122-
cross-origin-opener-policy:
123-
- same-origin
124-
nel:
125-
- '{"report_to":"heroku-nel","max_age":3600,"success_fraction":0.005,"failure_fraction":0.05,"response_headers":["Via"]}'
126-
ratelimit-remaining:
127-
- '2999'
128-
ratelimit-reset:
129-
- '1'
130-
referrer-policy:
131-
- same-origin
132-
report-to:
133-
- '{"group":"heroku-nel","max_age":3600,"endpoints":[{"url":"https://nel.heroku.com/reports?ts=1699356722&sid=1b10b0ff-8a76-4548-befa-353fc6c6c045&s=0z31nJbfdkKAzOcUMFWyBfoSPkxX%2ByLKhN0THsH1yz0%3D"}]}'
134-
reporting-endpoints:
135-
- heroku-nel=https://nel.heroku.com/reports?ts=1699356722&sid=1b10b0ff-8a76-4548-befa-353fc6c6c045&s=0z31nJbfdkKAzOcUMFWyBfoSPkxX%2ByLKhN0THsH1yz0%3D
136-
vary:
137-
- Cookie, origin
138-
via:
139-
- 1.1 vegur, 1.1 google
140-
x-content-type-options:
141-
- nosniff
142-
x-frame-options:
143-
- DENY
144-
http_version: HTTP/1.1
145-
status_code: 200
1462
- request:
1473
body: ''
1484
headers:
@@ -159,8 +15,7 @@ interactions:
15915
method: GET
16016
uri: https://api.replicate.com/v1/collections
16117
response:
162-
content: '{"next":null,"previous":null,"results":[{"name":"Halloween","slug":"halloween","description":"Spooky,
163-
scary, frightful models."},{"name":"Vision models","slug":"vision-models","description":"Multimodal
18+
content: '{"next":null,"previous":null,"results":[{"name":"Vision models","slug":"vision-models","description":"Multimodal
16419
large language models with vision capabilities like object detection and optical
16520
character recognition (OCR)"},{"name":"T2I-Adapter","slug":"t2i-adapter","description":"T2I-Adapter
16621
models to modify images"},{"name":"Language models with support for grammars
@@ -191,15 +46,15 @@ interactions:
19146
CF-Cache-Status:
19247
- DYNAMIC
19348
CF-RAY:
194-
- 822541955c92680f-SEA
49+
- 827025392eae200a-IAD
19550
Connection:
19651
- keep-alive
19752
Content-Encoding:
19853
- gzip
19954
Content-Type:
20055
- application/json
20156
Date:
202-
- Tue, 07 Nov 2023 11:32:32 GMT
57+
- Thu, 16 Nov 2023 13:40:22 GMT
20358
Server:
20459
- cloudflare
20560
Strict-Transport-Security:
@@ -209,15 +64,15 @@ interactions:
20964
allow:
21065
- GET, HEAD, OPTIONS
21166
content-security-policy-report-only:
212-
- 'style-src ''report-sample'' ''self'' ''unsafe-inline''; script-src ''report-sample''
213-
''self'' https://cdn.rudderlabs.com/v1.1/rudder-analytics.min.js; worker-src
214-
''none''; font-src ''report-sample'' ''self'' data:; media-src ''report-sample''
215-
''self'' https://replicate.delivery https://*.replicate.delivery https://*.mux.com
216-
https://*.sentry.io; default-src ''self''; connect-src ''report-sample'' ''self''
217-
https://replicate.delivery https://*.replicate.delivery https://*.rudderlabs.com
218-
https://*.rudderstack.com https://*.mux.com https://*.sentry.io; img-src ''report-sample''
219-
''self'' data: https://replicate.delivery https://*.replicate.delivery https://*.githubusercontent.com
220-
https://github.com; report-uri'
67+
- 'media-src ''report-sample'' ''self'' https://replicate.delivery https://*.replicate.delivery
68+
https://*.mux.com https://*.sentry.io; default-src ''self''; script-src ''report-sample''
69+
''self'' https://cdn.rudderlabs.com/v1.1/rudder-analytics.min.js; img-src
70+
''report-sample'' ''self'' data: https://replicate.delivery https://*.replicate.delivery
71+
https://*.githubusercontent.com https://github.com; worker-src ''none''; style-src
72+
''report-sample'' ''self'' ''unsafe-inline''; connect-src ''report-sample''
73+
''self'' https://replicate.delivery https://*.replicate.delivery https://*.rudderlabs.com
74+
https://*.rudderstack.com https://*.mux.com https://*.sentry.io; font-src
75+
''report-sample'' ''self'' data:; report-uri'
22176
cross-origin-opener-policy:
22277
- same-origin
22378
nel:
@@ -229,9 +84,9 @@ interactions:
22984
referrer-policy:
23085
- same-origin
23186
report-to:
232-
- '{"group":"heroku-nel","max_age":3600,"endpoints":[{"url":"https://nel.heroku.com/reports?ts=1699356752&sid=1b10b0ff-8a76-4548-befa-353fc6c6c045&s=WiktulKoNTILUBzFp2puv8yuZR7cPZG%2BdC77SDgv8Gw%3D"}]}'
87+
- '{"group":"heroku-nel","max_age":3600,"endpoints":[{"url":"https://nel.heroku.com/reports?ts=1700142022&sid=1b10b0ff-8a76-4548-befa-353fc6c6c045&s=AUQIFO072WbZjKq785Xqd67vUUwGAhLFqu5%2BlLug%2BWE%3D"}]}'
23388
reporting-endpoints:
234-
- heroku-nel=https://nel.heroku.com/reports?ts=1699356752&sid=1b10b0ff-8a76-4548-befa-353fc6c6c045&s=WiktulKoNTILUBzFp2puv8yuZR7cPZG%2BdC77SDgv8Gw%3D
89+
- heroku-nel=https://nel.heroku.com/reports?ts=1700142022&sid=1b10b0ff-8a76-4548-befa-353fc6c6c045&s=AUQIFO072WbZjKq785Xqd67vUUwGAhLFqu5%2BlLug%2BWE%3D
23590
vary:
23691
- Cookie, origin
23792
via:

tests/cassettes/models-get.yaml

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ interactions:
1919
"name": "sdxl", "description": "A text-to-image generative AI model that creates
2020
beautiful images", "visibility": "public", "github_url": "https://github.com/replicate/cog-sdxl",
2121
"paper_url": "https://arxiv.org/abs/2307.01952", "license_url": "https://github.com/Stability-AI/generative-models/blob/main/model_licenses/LICENSE-SDXL1.0",
22-
"run_count": 16656495, "cover_image_url": "https://tjzk.replicate.delivery/models_models_cover_image/61004930-fb88-4e09-9bd4-74fd8b4aa677/sdxl_cover.png",
22+
"run_count": 19361490, "cover_image_url": "https://tjzk.replicate.delivery/models_models_cover_image/61004930-fb88-4e09-9bd4-74fd8b4aa677/sdxl_cover.png",
2323
"default_example": {"completed_at": "2023-10-12T17:10:12.909279Z", "created_at":
2424
"2023-10-12T17:10:07.956869Z", "error": null, "id": "dzsqmb3bg4lqpjkz2iptjqgccm",
2525
"input": {"width": 768, "height": 768, "prompt": "An astronaut riding a rainbow
@@ -52,7 +52,7 @@ interactions:
5252
"started_at": "2023-10-12T17:10:07.927942Z", "status": "succeeded", "urls":
5353
{"get": "https://api.replicate.com/v1/predictions/dzsqmb3bg4lqpjkz2iptjqgccm",
5454
"cancel": "https://api.replicate.com/v1/predictions/dzsqmb3bg4lqpjkz2iptjqgccm/cancel"},
55-
"version": "c221b2b8ef527988fb59bf24a8b97c4561f1c671f73bd389f866bfb27c061316",
55+
"model": "stability-ai/sdxl", "version": "c221b2b8ef527988fb59bf24a8b97c4561f1c671f73bd389f866bfb27c061316",
5656
"webhook_completed": null}, "latest_version": {"id": "39ed52f2a78e934b3ba6e2a89f5b1c712de7dfea535525255b1aa35c5565e08b",
5757
"created_at": "2023-11-06T23:13:07.906314Z", "cog_version": "0.8.6", "openapi_schema":
5858
{"info": {"title": "Cog", "version": "0.1.0"}, "paths": {"/": {"get": {"summary":
@@ -170,15 +170,15 @@ interactions:
170170
CF-Cache-Status:
171171
- DYNAMIC
172172
CF-RAY:
173-
- 8225cc4959f1c382-SEA
173+
- 82702682c85e3afa-IAD
174174
Connection:
175175
- keep-alive
176176
Content-Encoding:
177177
- gzip
178178
Content-Type:
179179
- application/json
180180
Date:
181-
- Tue, 07 Nov 2023 13:07:13 GMT
181+
- Thu, 16 Nov 2023 13:41:15 GMT
182182
Server:
183183
- cloudflare
184184
Strict-Transport-Security:
@@ -188,14 +188,15 @@ interactions:
188188
allow:
189189
- GET, HEAD, OPTIONS
190190
content-security-policy-report-only:
191-
- 'style-src ''report-sample'' ''self'' ''unsafe-inline''; connect-src ''report-sample''
192-
''self'' https://replicate.delivery https://*.replicate.delivery https://*.rudderlabs.com
193-
https://*.rudderstack.com https://*.mux.com https://*.sentry.io; font-src
194-
''report-sample'' ''self'' data:; script-src ''report-sample'' ''self'' https://cdn.rudderlabs.com/v1.1/rudder-analytics.min.js;
195-
worker-src ''none''; img-src ''report-sample'' ''self'' data: https://replicate.delivery
196-
https://*.replicate.delivery https://*.githubusercontent.com https://github.com;
197-
default-src ''self''; media-src ''report-sample'' ''self'' https://replicate.delivery
198-
https://*.replicate.delivery https://*.mux.com https://*.sentry.io; report-uri'
191+
- 'img-src ''report-sample'' ''self'' data: https://replicate.delivery https://*.replicate.delivery
192+
https://*.githubusercontent.com https://github.com; style-src ''report-sample''
193+
''self'' ''unsafe-inline''; font-src ''report-sample'' ''self'' data:; worker-src
194+
''none''; connect-src ''report-sample'' ''self'' https://replicate.delivery
195+
https://*.replicate.delivery https://*.rudderlabs.com https://*.rudderstack.com
196+
https://*.mux.com https://*.sentry.io; default-src ''self''; media-src ''report-sample''
197+
''self'' https://replicate.delivery https://*.replicate.delivery https://*.mux.com
198+
https://*.sentry.io; script-src ''report-sample'' ''self'' https://cdn.rudderlabs.com/v1.1/rudder-analytics.min.js;
199+
report-uri'
199200
cross-origin-opener-policy:
200201
- same-origin
201202
nel:
@@ -207,9 +208,9 @@ interactions:
207208
referrer-policy:
208209
- same-origin
209210
report-to:
210-
- '{"group":"heroku-nel","max_age":3600,"endpoints":[{"url":"https://nel.heroku.com/reports?ts=1699362433&sid=1b10b0ff-8a76-4548-befa-353fc6c6c045&s=zH5RNbbfmwMdjyaSsKchIOr55KExVjfjhKt6gPsWVzI%3D"}]}'
211+
- '{"group":"heroku-nel","max_age":3600,"endpoints":[{"url":"https://nel.heroku.com/reports?ts=1700142075&sid=1b10b0ff-8a76-4548-befa-353fc6c6c045&s=6G1BMZHhXTEFBJa1qOIwI2LAhE2J3ob6Pd87SpjKM5w%3D"}]}'
211212
reporting-endpoints:
212-
- heroku-nel=https://nel.heroku.com/reports?ts=1699362433&sid=1b10b0ff-8a76-4548-befa-353fc6c6c045&s=zH5RNbbfmwMdjyaSsKchIOr55KExVjfjhKt6gPsWVzI%3D
213+
- heroku-nel=https://nel.heroku.com/reports?ts=1700142075&sid=1b10b0ff-8a76-4548-befa-353fc6c6c045&s=6G1BMZHhXTEFBJa1qOIwI2LAhE2J3ob6Pd87SpjKM5w%3D
213214
vary:
214215
- Cookie, origin
215216
via:
@@ -244,19 +245,15 @@ interactions:
244245
CF-Cache-Status:
245246
- DYNAMIC
246247
CF-RAY:
247-
- 8225cc4b0b64c382-SEA
248+
- 82702683c99c3afa-IAD
248249
Connection:
249250
- keep-alive
250251
Content-Encoding:
251252
- gzip
252253
Content-Type:
253254
- application/json
254255
Date:
255-
- Tue, 07 Nov 2023 13:07:13 GMT
256-
NEL:
257-
- '{"success_fraction":0,"report_to":"cf-nel","max_age":604800}'
258-
Report-To:
259-
- '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=cY2nl%2FrK5utZBgfjK1IykTazkguXz8LHTFFt9E8eHHnk6RqonDn2KHLyZYVxBTMJkyUMtdWMrR48N0MqqF20iMqcZWpeQ0gnvSZnKnmoGQe2xJECyJcKRanwdFJy29fBHigz"}],"group":"cf-nel","max_age":604800}'
256+
- Thu, 16 Nov 2023 13:41:15 GMT
260257
Server:
261258
- cloudflare
262259
Strict-Transport-Security:
@@ -266,23 +263,29 @@ interactions:
266263
allow:
267264
- GET, HEAD, OPTIONS
268265
content-security-policy-report-only:
269-
- 'script-src ''report-sample'' ''self'' https://cdn.rudderlabs.com/v1.1/rudder-analytics.min.js;
270-
style-src ''report-sample'' ''self'' ''unsafe-inline''; default-src ''self'';
271-
font-src ''report-sample'' ''self'' data:; img-src ''report-sample'' ''self''
272-
data: https://replicate.delivery https://*.replicate.delivery https://*.githubusercontent.com
273-
https://github.com; connect-src ''report-sample'' ''self'' https://replicate.delivery
274-
https://*.replicate.delivery https://*.rudderlabs.com https://*.rudderstack.com
275-
https://*.mux.com https://*.sentry.io; media-src ''report-sample'' ''self''
276-
https://replicate.delivery https://*.replicate.delivery https://*.mux.com
277-
https://*.sentry.io; worker-src ''none''; report-uri'
266+
- 'media-src ''report-sample'' ''self'' https://replicate.delivery https://*.replicate.delivery
267+
https://*.mux.com https://*.sentry.io; default-src ''self''; script-src ''report-sample''
268+
''self'' https://cdn.rudderlabs.com/v1.1/rudder-analytics.min.js; img-src
269+
''report-sample'' ''self'' data: https://replicate.delivery https://*.replicate.delivery
270+
https://*.githubusercontent.com https://github.com; worker-src ''none''; style-src
271+
''report-sample'' ''self'' ''unsafe-inline''; connect-src ''report-sample''
272+
''self'' https://replicate.delivery https://*.replicate.delivery https://*.rudderlabs.com
273+
https://*.rudderstack.com https://*.mux.com https://*.sentry.io; font-src
274+
''report-sample'' ''self'' data:; report-uri'
278275
cross-origin-opener-policy:
279276
- same-origin
277+
nel:
278+
- '{"report_to":"heroku-nel","max_age":3600,"success_fraction":0.005,"failure_fraction":0.05,"response_headers":["Via"]}'
280279
ratelimit-remaining:
281280
- '2999'
282281
ratelimit-reset:
283282
- '1'
284283
referrer-policy:
285284
- same-origin
285+
report-to:
286+
- '{"group":"heroku-nel","max_age":3600,"endpoints":[{"url":"https://nel.heroku.com/reports?ts=1700142075&sid=1b10b0ff-8a76-4548-befa-353fc6c6c045&s=6G1BMZHhXTEFBJa1qOIwI2LAhE2J3ob6Pd87SpjKM5w%3D"}]}'
287+
reporting-endpoints:
288+
- heroku-nel=https://nel.heroku.com/reports?ts=1700142075&sid=1b10b0ff-8a76-4548-befa-353fc6c6c045&s=6G1BMZHhXTEFBJa1qOIwI2LAhE2J3ob6Pd87SpjKM5w%3D
286289
vary:
287290
- Cookie, origin
288291
via:

0 commit comments

Comments
 (0)