Skip to content

Commit

Permalink
add an handler for sampler submit
Browse files Browse the repository at this point in the history
  • Loading branch information
dakk committed May 15, 2024
1 parent 7025c6b commit b715444
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
6 changes: 5 additions & 1 deletion dqpu/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"clear-jobs",
"add-verifier",
"remove-verifier",
"is-a-verifier"
]


Expand Down Expand Up @@ -143,7 +144,7 @@ def cli(): # noqa: C901
job_file = ipfs.upload(circuit_file)
print(f"Circuit file is {job_file}")

shots = random.choice([32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384])
shots = random.choice([256, 512, 1024, 2048, 4096, 8192, 16384])
sh_fact = int(round((shots + 1024) / 1024))
reward = random.randint(1 * nq * sh_fact, 10 * nq * sh_fact) / 30000.0

Expand Down Expand Up @@ -195,5 +196,8 @@ def cli(): # noqa: C901

elif args.action == "remove-verifier":
print(nb.add_verifier(args.verifier))

elif args.action == "is-a-verifier":
print(nb.is_a_verifier(args.verifier))

# stop_ipfs_daemon(ipfs_process)
21 changes: 12 additions & 9 deletions dqpu/samplernode.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,18 @@ def sampler_node():
print("\t", "Result file uploaded", jf_result)

# Submit the result with the deposit
print(
"\t",
nb.submit_job_result(
j["id"],
jf_result,
deposit=from_near(j["reward_amount"]) / 10 + 0.00001,
),
)
n_sampled += 1
try:
print(
"\t",
nb.submit_job_result(
j["id"],
jf_result,
deposit=from_near(j["reward_amount"]) / 10 + 0.00001,
),
)
n_sampled += 1
except Exception as e:
print('Failed to submit:', e)

current_limit = 48
print(f"Account balance is {nb.balance():0.5f} N, sampled jobs {n_sampled}")
Expand Down

0 comments on commit b715444

Please sign in to comment.