-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy path04_distributed_workloads.py
More file actions
43 lines (31 loc) · 1.02 KB
/
04_distributed_workloads.py
File metadata and controls
43 lines (31 loc) · 1.02 KB
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
#!/usr/bin/env python
from qiskit_serverless import ServerlessClient
import os
serverless = ServerlessClient(
token=os.environ.get("GATEWAY_TOKEN", "awesome_token"),
host=os.environ.get("GATEWAY_HOST", "http://localhost:8000"),
instance=os.environ.get("GATEWAY_INSTANCE", "an_awesome_crn"),
)
print(serverless)
from qiskit.circuit.random import random_circuit
circuits = [random_circuit(2, 2) for _ in range(3)]
[circuit.measure_all() for circuit in circuits]
print(circuits)
from qiskit_serverless import QiskitFunction
function = QiskitFunction(
title="pattern-with-parallel-workflow",
entrypoint="pattern_with_parallel_workflow.py",
working_dir="./source_files/",
)
serverless.upload(function)
functions = {f.title: f for f in serverless.list()}
my_pattern_function = functions.get("pattern-with-parallel-workflow")
my_pattern_function
job = my_pattern_function.run(circuits=circuits)
print(job)
try:
print(job.result())
except:
print(job.error_message())
print(job.status())
print(job.logs())