feat: add debug script for testing ipv6 resolve
This commit is contained in:
parent
27ff1c5636
commit
3cae025242
58
test.py
58
test.py
@ -1,34 +1,40 @@
|
||||
from web3 import Web3
|
||||
from src.scheduler import Scheduler
|
||||
import docker
|
||||
import os
|
||||
|
||||
SCHEDULER_ADDR = "0x544eAe853EA3774A8857573C6423E6Db95b79258"
|
||||
SCHEDULER_ABI_FILE = "../gpu-contract/abi/Scheduler.abi"
|
||||
|
||||
PROVIDER1_KEY = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
|
||||
PROVIDER2_KEY = "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"
|
||||
PROVIDER3_KEY = "0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a"
|
||||
if not os.path.isdir('./dataset_dir'):
|
||||
os.mkdir('./dataset_dir')
|
||||
|
||||
CLIENT_KEY = "0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6"
|
||||
docker_client = docker.from_env()
|
||||
container = docker_client.containers.run(
|
||||
'snsd0805/cifar100-train:v3',
|
||||
volumes={
|
||||
'dataset_dir': {'bind': '/dataset', 'mode': 'rw'},
|
||||
'output': {'bind': '/output', 'mode': 'rw'},
|
||||
},
|
||||
network='train-net',
|
||||
runtime='nvidia',
|
||||
device_requests=[
|
||||
docker.types.DeviceRequest(count=-1, capabilities=[['gpu']])
|
||||
],
|
||||
name='train-0',
|
||||
environment={
|
||||
'GPU_NUM': 1,
|
||||
'NODE_NUM': 1,
|
||||
'NODE_RANK': 0,
|
||||
'MASTER_IP': 'train-0',
|
||||
'MASTER_PORT': 21046,
|
||||
},
|
||||
detach=True
|
||||
)
|
||||
|
||||
w3 = Web3(Web3.HTTPProvider('http://127.0.0.1:8545'))
|
||||
|
||||
if __name__ == '__main__':
|
||||
if w3.is_connected():
|
||||
scheduler = Scheduler(w3, SCHEDULER_ADDR, SCHEDULER_ABI_FILE)
|
||||
print(container.short_id)
|
||||
for line in container.logs(stream=True):
|
||||
print(line.strip().decode())
|
||||
|
||||
provider1 = w3.eth.account.from_key(PROVIDER1_KEY)
|
||||
provider2 = w3.eth.account.from_key(PROVIDER2_KEY)
|
||||
provider3 = w3.eth.account.from_key(PROVIDER3_KEY)
|
||||
client = w3.eth.account.from_key(CLIENT_KEY)
|
||||
result = container.wait()
|
||||
status_code = result['StatusCode']
|
||||
print(status_code, type(status_code))
|
||||
|
||||
print(scheduler.getClusters())
|
||||
scheduler.registerCluster(provider1, 1, 4)
|
||||
scheduler.registerCluster(provider2, 2, 2)
|
||||
scheduler.registerCluster(provider3, 3, 1)
|
||||
scheduler.registerTaskWithConditions(client, "https://data.com", "http://train.tw", 3, 1)
|
||||
print(scheduler.getClusters())
|
||||
print(scheduler.getTasks())
|
||||
|
||||
else:
|
||||
print("cannot connected to the chain")
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user