-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbatch.py
45 lines (38 loc) · 1.08 KB
/
batch.py
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
import os
import requests
from dotenv import load_dotenv
from protein_utils import generate_random_protein_sequences
load_dotenv()
# Define your API endpoint and API key
url = 'https://api.ginkgobioworks.ai/v1/batches/transforms/run'
api_key = os.getenv('GINKGO_API_KEY')
transform = [{'type': 'FILL_MASK'}]
model = 'ginkgo-aa0-650M'
# Protein Sequence
seq_number = 5
seq_length = 400
add_mask = True
# Generate N masked sequences
protein_sequences = generate_random_protein_sequences(
seq_number, seq_length, add_mask)
# Prepare the list of requests for the batch
requests_list = []
for seq in protein_sequences:
transforms = transform
# transforms = [{'type': 'EMBEDDING'}]
requests_list.append({
'model': model,
'text': seq,
'transforms': transforms
})
# Send sequences to batch request
response = requests.post(
url,
headers={'x-api-key': api_key, 'Content-Type': 'application/json'},
json={'requests': requests_list}
)
if response.ok:
data = response.json()
print(f"Batch response: {data}")
else:
print(f"Error: {response.text}")