Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for result validation; Error in usage example #7

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/ibmq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,23 @@ end

@option mutable struct JobInfo
kind::String
backend::Dict{String, String}
backend::Dict{String,String}
userId::String
status::String
id::String
# optional
timePerStep::Maybe{Dict{String, String}} = nothing
timePerStep::Maybe{Dict{String,String}} = nothing
name::Maybe{String} = nothing
share_level::Maybe{Int}=nothing
tags::Maybe{Vector{String}}=nothing
share_level::Maybe{Int} = nothing
tags::Maybe{Vector{String}} = nothing
qobj::Maybe{Schema.Qobj} = nothing
allowObjectStorage::Maybe{Bool} = nothing
objectStorageInfo::Maybe{StorageInfo} = nothing
deleted::Maybe{Bool} = nothing
runMode::Maybe{String} = nothing
creationDate::Maybe{DateTime} = nothing
endDate::Maybe{DateTime} = nothing
hubInfo::Maybe{Dict{String, Any}} = nothing
hubInfo::Maybe{Dict{String,Any}} = nothing
end

function update_job_info(info::JobInfo, new::AbstractDict)
Expand All @@ -108,9 +108,9 @@ end

@option struct RemoteJob
dev::String
name::Maybe{String}=nothing
share_level::Maybe{Int}=nothing
tags::Maybe{Vector{String}}=nothing
name::Maybe{String} = nothing
share_level::Maybe{Int} = nothing
tags::Maybe{Vector{String}} = nothing
end

function RemoteJob(dev::Schema.DeviceInfo, name, share_level, tags)
Expand Down Expand Up @@ -175,7 +175,7 @@ end

Download the results of given `job`, return `nothing` if the job status is not `COMPLETED`.
"""
function results(account::AccountInfo, job::JobInfo; use_object_storage::Bool = true)
function results(account::AccountInfo, job::JobInfo; use_object_storage::Bool=true)
response = status(account, job)
response.status == "COMPLETED" || return

Expand Down
46 changes: 24 additions & 22 deletions src/schema.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@ end
id::String
username::String
email::String
urls::Dict{String, Any}
userType::String="Standard"
urls::Dict{String,Any}
userType::String = "Standard"
firstName::Maybe{String} = nothing
lastName::Maybe{String} = nothing
institution::Maybe{String} = nothing
applications::Vector{String} = String[]
subscriptions::Subscription = Subscription()
readOnly::Bool=false
needsRefill::Bool=false
iqxPreferences::Dict{String, Any} = Dict{String, Any}()
readOnly::Bool = false
needsRefill::Bool = false
iqxPreferences::Dict{String,Any} = Dict{String,Any}()
loginAccounts::Vector{Any} = []
ibmQNetwork::Bool=true
ibmQNetwork::Bool = true
qNetworkRoles::Vector{String} = []
roles::Vector{Any} = []
emailVerified::Bool=false
terms::Dict{String, Any} = Dict{String, Any}()
canScheduleBackends::Bool=true
servicesRoles::Vector{String}=[]
emailVerified::Bool = false
terms::Dict{String,Any} = Dict{String,Any}()
canScheduleBackends::Bool = true
servicesRoles::Vector{String} = []
end

UserInfo(d::AbstractDict{String}) = from_dict(UserInfo, d)
Expand Down Expand Up @@ -139,7 +139,7 @@ the property is false and new tags can be added.
configurable::Bool = false
credits_required::Bool = false
allow_q_object::Bool = false
allow_object_storage::Bool=false
allow_object_storage::Bool = false
n_registers::Maybe{Int} = nothing
open_pulse::Bool = false
quantum_volume::Maybe{Int} = nothing
Expand Down Expand Up @@ -292,11 +292,11 @@ The types of snapshots offered are defined in a separate specification document
for simulators.
"""
@option struct ExpData <: IBMQSchema
counts::Dict{String, Int}
counts::Dict{String,Int}
memory::Maybe{Vector{String}} = nothing
statevector::Maybe{Matrix{ComplexF64}} = nothing
unitary::Maybe{Matrix{ComplexF64}} = nothing
snapshots::Maybe{Dict{String, Any}} = nothing
snapshots::Maybe{Dict{String,Any}} = nothing
end

"""
Expand All @@ -322,11 +322,13 @@ the type of experiment (`"QASM"` or `"PULSE"`) and/or the type of backend (e.g.
simulator data). See below.
"""
@option struct ExpResult <: IBMQSchema
metadata::Maybe{Dict{String, Any}} = nothing
header::Maybe{Dict{String, Any}} = nothing
shots::Union{Int, Vector{Int}}
metadata::Maybe{Dict{String,Any}} = nothing
header::Maybe{Dict{String,Any}} = nothing
shots::Union{Int,Vector{Int}}
status::String
success::Bool
meas_level::Int
circ_id::Int
time_taken::Float64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to understand the change better cuz there are a lot format changes, is this the main update of the result schema?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, correct. Sorry for the formatting...

seed_simulator::Maybe{Int} = nothing
seed::Maybe{Int} = nothing
Expand All @@ -347,8 +349,8 @@ The results data structure from Job.result().
- `results`: List of `m` (number of experiments) exp result data structures (defined below).
"""
@option struct Result <: IBMQSchema
header::Maybe{Dict{String, Any}} = nothing
metadata::Maybe{Dict{String, Any}} = nothing
header::Maybe{Dict{String,Any}} = nothing
metadata::Maybe{Dict{String,Any}} = nothing
time_taken::Maybe{Float64} = nothing
qobj_id::String
job_id::String
Expand Down Expand Up @@ -395,7 +397,7 @@ Abstract type for Qobj schema instructions.
"""
abstract type Instruction <: IBMQSchema end

Configurations.is_option(::Type{T}) where {T <: Instruction} = true
Configurations.is_option(::Type{T}) where {T<:Instruction} = true

"""
struct BooleanFunction <: Instruction
Expand Down Expand Up @@ -517,7 +519,7 @@ experiment. These will override the configuration settings of the whole job. See
- `instructions`: List of sequence commands that define the experiment. See [`Instruction`](@ref).
"""
@option struct Experiment <: IBMQSchema
header::Maybe{Dict{String, Any}} = nothing
header::Maybe{Dict{String,Any}} = nothing
# NOTE: the schema specification didn't mention
# but this can be optional
config::Maybe{ExpConfig} = nothing
Expand Down Expand Up @@ -548,10 +550,10 @@ the backend that the experiments were compiled for.
type::String = "QASM"
schema_version::VersionNumber = v"1.3"
experiments::Vector{Experiment} = Experiment[]
header::Maybe{Dict{String, Any}} = nothing
header::Maybe{Dict{String,Any}} = nothing
config::ExpConfig
end

Configurations.to_dict(::Type{T}, x::VersionNumber) where {T <: IBMQSchema} = string(x)
Configurations.to_dict(::Type{T}, x::VersionNumber) where {T<:IBMQSchema} = string(x)

end
Loading