FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
replicate-python/tests/test_model.py at main · hatgit/replicate-python · GitHub
hatgit
/
replicate-python
Public
forked from
replicate/replicate-python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
replicate-python
/
tests
/
test_model.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
132 lines (110 loc) · 3.76 KB
Breadcrumbs
replicate-python
/
tests
/
test_model.py
Copy path
File metadata and controls
132 lines (110 loc) · 3.76 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import
pytest
import
replicate
@
pytest
.
mark
.
vcr
(
"models-get.yaml"
)
@
pytest
.
mark
.
asyncio
@
pytest
.
mark
.
parametrize
(
"async_flag"
, [
True
,
False
])
async
def
test_models_get
(
async_flag
):
if
async_flag
:
sdxl
=
await
replicate
.
models
.
async_get
(
"stability-ai/sdxl"
)
else
:
sdxl
=
replicate
.
models
.
get
(
"stability-ai/sdxl"
)
assert
sdxl
is
not
None
assert
sdxl
.
owner
==
"stability-ai"
assert
sdxl
.
name
==
"sdxl"
assert
sdxl
.
visibility
==
"public"
if
async_flag
:
empty
=
await
replicate
.
models
.
async_get
(
"mattt/empty"
)
else
:
empty
=
replicate
.
models
.
get
(
"mattt/empty"
)
assert
empty
.
default_example
is
None
@
pytest
.
mark
.
vcr
(
"models-list.yaml"
)
@
pytest
.
mark
.
asyncio
@
pytest
.
mark
.
parametrize
(
"async_flag"
, [
True
,
False
])
async
def
test_models_list
(
async_flag
):
if
async_flag
:
models
=
await
replicate
.
models
.
async_list
()
else
:
models
=
replicate
.
models
.
list
()
assert
len
(
models
)
>
0
assert
models
[
0
].
owner
is
not
None
assert
models
[
0
].
name
is
not
None
assert
models
[
0
].
visibility
==
"public"
@
pytest
.
mark
.
vcr
(
"models-list__pagination.yaml"
)
@
pytest
.
mark
.
asyncio
@
pytest
.
mark
.
parametrize
(
"async_flag"
, [
True
,
False
])
async
def
test_models_list_pagination
(
async_flag
):
if
async_flag
:
page1
=
await
replicate
.
models
.
async_list
()
else
:
page1
=
replicate
.
models
.
list
()
assert
len
(
page1
)
>
0
assert
page1
.
next
is
not
None
if
async_flag
:
page2
=
await
replicate
.
models
.
async_list
(
cursor
=
page1
.
next
)
else
:
page2
=
replicate
.
models
.
list
(
cursor
=
page1
.
next
)
assert
len
(
page2
)
>
0
assert
page2
.
previous
is
not
None
@
pytest
.
mark
.
vcr
(
"models-create.yaml"
)
@
pytest
.
mark
.
asyncio
@
pytest
.
mark
.
parametrize
(
"async_flag"
, [
True
,
False
])
async
def
test_models_create
(
async_flag
):
if
async_flag
:
model
=
await
replicate
.
models
.
async_create
(
owner
=
"test"
,
name
=
"python-example"
,
visibility
=
"private"
,
hardware
=
"cpu"
,
description
=
"An example model"
,
)
else
:
model
=
replicate
.
models
.
create
(
owner
=
"test"
,
name
=
"python-example"
,
visibility
=
"private"
,
hardware
=
"cpu"
,
description
=
"An example model"
,
)
assert
model
.
owner
==
"test"
assert
model
.
name
==
"python-example"
assert
model
.
visibility
==
"private"
@
pytest
.
mark
.
vcr
(
"models-create.yaml"
)
@
pytest
.
mark
.
asyncio
@
pytest
.
mark
.
parametrize
(
"async_flag"
, [
True
,
False
])
async
def
test_models_create_with_positional_arguments
(
async_flag
):
if
async_flag
:
model
=
await
replicate
.
models
.
async_create
(
"test"
,
"python-example"
,
visibility
=
"private"
,
hardware
=
"cpu"
,
)
else
:
model
=
replicate
.
models
.
create
(
"test"
,
"python-example"
,
visibility
=
"private"
,
hardware
=
"cpu"
,
)
assert
model
.
owner
==
"test"
assert
model
.
name
==
"python-example"
assert
model
.
visibility
==
"private"
@
pytest
.
mark
.
vcr
(
"models-predictions-create.yaml"
)
@
pytest
.
mark
.
asyncio
@
pytest
.
mark
.
parametrize
(
"async_flag"
, [
True
,
False
])
async
def
test_models_predictions_create
(
async_flag
):
input
=
{
"prompt"
:
"Please write a haiku about llamas."
,
}
if
async_flag
:
prediction
=
await
replicate
.
models
.
predictions
.
async_create
(
"meta/llama-2-70b-chat"
,
input
=
input
)
else
:
prediction
=
replicate
.
models
.
predictions
.
create
(
"meta/llama-2-70b-chat"
,
input
=
input
)
assert
prediction
.
id
is
not
None
# assert prediction.model == "meta/llama-2-70b-chat"
assert
prediction
.
model
==
"replicate/lifeboat-70b"
# FIXME: this is temporary
assert
prediction
.
status
==
"starting"
Back
|
FazBrowse Home
|
New Git URL