-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimple_cpu.py
52 lines (41 loc) · 1.21 KB
/
simple_cpu.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
46
47
48
49
50
51
52
import os
import pprint
from dotenv import load_dotenv
from nunet import CONSTRAINTS_LOW
from nunet import ImageId
from nunet import JobParams
from nunet import JobRequest
from nunet import MachineType
from nunet import NuNetAdapter
from nunet import ServiceType
# Load the environment file
load_dotenv()
# Get your seed phrase from the environment
seed = os.environ["SEED"]
# Create a NuNet adapter
adapter = NuNetAdapter(seed)
# Get a list of peers
print("Peers:")
peer_list = adapter.peer_list()
pprint.pprint(peer_list.model_dump(), indent=2)
print()
print("CONSTRAINTS_LOW:")
pprint.pprint(CONSTRAINTS_LOW.model_dump(), indent=2)
print()
params = JobParams(
machine_type=MachineType.GPU,
image_id=ImageId.ML_ON_CPU_REGISTRY,
model_url="https://gitlab.com/nunet/ml-on-gpu/ml-on-cpu-service/-/raw/develop/examples/cpu-ml-test-scikit-learn.py",
packages=[],
)
job_request: JobRequest = JobRequest(
address_user=adapter.address.encode(),
max_ntx=10,
service_type=ServiceType.CPU,
params=params,
constraints=CONSTRAINTS_LOW,
)
job_request = adapter.request_service(job_request=job_request)
txid = adapter.pay(job_request)
for msg_type, msg in adapter.job(txid):
print(msg, flush=True)