@@ -25,12 +25,57 @@ function parse_device_info(d)
25
25
return from_dict_validate (Schema. DeviceInfo, d):: Schema.DeviceInfo
26
26
end
27
27
28
+ const DOC_AWS_CONFIG = """
29
+ # AWS Service Configuration
30
+
31
+ You can specify custom configuration via `aws_config` keyword argument,
32
+ to select another regions or use a different account, default
33
+ is `AWS.global_aws_config()`, e.g you can choose a different region in
34
+ this config
35
+
36
+ ```julia
37
+ using AWS
38
+ config = AWSConfig(;region="us-west-1")
39
+ ```
40
+
41
+ See the [AWS Julia Interface](https://github.com/JuliaCloud/AWS.jl) documentation
42
+ for more advanced usage.
43
+ """
44
+
45
+ """
46
+ get_device(arn::String; aws_config=AWS.global_aws_config())
47
+
48
+ Retrieves the devices available in Amazon Braket.
49
+
50
+ # Arguments
51
+
52
+ - `arn`: The ARN of the device to retrieve.
53
+
54
+ $(DOC_AWS_CONFIG)
55
+ """
28
56
function get_device (arn:: String ; aws_config= AWS. global_aws_config ())
29
57
# NOTE: the AWS dev docs
30
58
d = Braket. get_device (HTTP. escapeuri (arn); aws_config)
31
59
return parse_device_info (d)
32
60
end
33
61
62
+ """
63
+ search_devices(filters=[]; max_results::Maybe{Int}=nothing, next_token::Maybe{String}=nothing, aws_config=AWS.global_aws_config())
64
+
65
+ Searches for devices using the specified filters.
66
+
67
+ # Arguments
68
+
69
+ - `filters`: The filter values to use to search for a device.
70
+
71
+ # Keyword Arguments (Optional)
72
+
73
+ - `max_results`: The maximum number of results to return in the response.
74
+ - `next_token`: A token used for pagination of results returned in the response. Use the token returned from
75
+ the previous request continue results where the previous request ended.
76
+
77
+ $(DOC_AWS_CONFIG)
78
+ """
34
79
function search_devices (filters= []; max_results:: Maybe{Int} = nothing , next_token:: Maybe{String} = nothing , aws_config= AWS. global_aws_config ())
35
80
params = Dict {String, Any} ()
36
81
max_results === nothing || (params[" maxResults" ] = max_results)
@@ -40,6 +85,11 @@ function search_devices(filters=[]; max_results::Maybe{Int}=nothing, next_token:
40
85
return map (parse_device_info, d[" devices" ]), get (d, " nextToken" , nothing )
41
86
end
42
87
88
+ """
89
+ make_device_parameters(program::Schema.Program, arn::String, disable_qubit_rewiring::Bool)
90
+
91
+ Create device parameters from given `program`, device `arn` and `disable_qubit_rewiring` option.
92
+ """
43
93
function make_device_parameters (program:: Schema.Program , arn:: String , disable_qubit_rewiring:: Bool )
44
94
paradigm_parameters = Schema. GateModelParameters (
45
95
qubitCount= Schema. count_qubits (program),
@@ -63,6 +113,29 @@ function make_device_parameters(program::Schema.Program, arn::String, disable_qu
63
113
return device_parameters
64
114
end
65
115
116
+ """
117
+ create_quantum_task(;kw...)
118
+
119
+ Create a quantum task in braket service.
120
+
121
+ # Required Keyword Arguments
122
+
123
+ - `program::Schema.Program`: the program one wants to execute.
124
+ - `device_arn::String`: device arn.
125
+ - `bucket::String`: S3 bucket to store the results in.
126
+ - `folder::String`: S3 bucket folder.
127
+
128
+ # Optional Keyword Arguments
129
+
130
+ - `disable_qubit_rewiring::Bool`: disable qubit rewiring in braket service, default is `false`.
131
+ - `device_parameters`: device parameters, such as [`Schema.IonqDeviceParameters`](@ref),
132
+ [`Schema.RigettiDeviceParameters`](@ref), default is inferred from previous arguments.
133
+ - `nshots`: number of shots, default is `100`.
134
+ - `client_token`: a `UUID` for the client token, will generate one by default.
135
+ - `tags::Dict{String, String}`: a list of tags you would to attach to this task.
136
+
137
+ $(DOC_AWS_CONFIG)
138
+ """
66
139
function create_quantum_task (;
67
140
program:: Schema.Program ,
68
141
device_arn:: String ,
@@ -73,6 +146,7 @@ function create_quantum_task(;
73
146
nshots:: Int = 100 ,
74
147
client_token:: UUID = uuid1 (),
75
148
tags:: Dict{String, String} = Dict {String, String} (),
149
+ aws_config= AWS. global_aws_config (),
76
150
)
77
151
78
152
response = Braket. create_quantum_task (
@@ -85,17 +159,39 @@ function create_quantum_task(;
85
159
Dict (
86
160
" deviceParameters" => JSON. json (to_dict (device_parameters; include_defaults= true , exclude_nothing= true )),
87
161
" tags" => tags,
88
- ),
162
+ );
163
+ aws_config
89
164
)
90
165
return response[" quantumTaskArn" ], response[" status" ]
91
166
end
92
167
93
- function get_quantum_task (task_arn:: String )
94
- from_dict (Schema. BraketTaskInfo, Braket. get_quantum_task (HTTP. escapeuri (task_arn)))
168
+ """
169
+ get_quantum_task(task_arn::String)
170
+
171
+ Get the quantum task from `task_arn`.
172
+
173
+ $(DOC_AWS_CONFIG)
174
+ """
175
+ function get_quantum_task (task_arn:: String ; aws_config= AWS. global_aws_config ())
176
+ from_dict (
177
+ Schema. BraketTaskInfo,
178
+ Braket. get_quantum_task (HTTP. escapeuri (task_arn); aws_config)
179
+ )
95
180
end
96
181
97
- function cancel_quantum_task (client_token:: String , task_arn:: String )
98
- Braket. cancel_quantum_task (client_token, HTTP. escapeuri (task_arn))
182
+ """
183
+ cancel_quantum_task(client_token::String, task_arn::String)
184
+
185
+ Cancel quantum task given by `client_token` and its `task_arn`.
186
+
187
+ $(DOC_AWS_CONFIG)
188
+ """
189
+ function cancel_quantum_task (client_token:: String , task_arn:: String ; aws_config= AWS. global_aws_config ())
190
+ Braket. cancel_quantum_task (
191
+ client_token,
192
+ HTTP. escapeuri (task_arn);
193
+ aws_config
194
+ )
99
195
end
100
196
101
197
using Crayons. Box
0 commit comments