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

Remove pulse defaults required parameters #2101

Merged

Conversation

taalexander
Copy link
Contributor

Summary

Makes defaults parameters non-required. This is to not break the defaults endpoint for non-pulse backends and simulators.

Details and comments

Makes all parameters non-required. For cmd_def and pulse_library default missing values are lists, for other parameters they are set to None.

@taalexander taalexander self-assigned this Apr 8, 2019
@taalexander taalexander added the bug Something isn't working label Apr 8, 2019
@taalexander taalexander added this to the 0.8 milestone Apr 8, 2019
@ajavadia ajavadia added type: specs Issues and PRs that involve modifications to the open specs and removed bug Something isn't working labels Apr 9, 2019
meas_kernel = Nested(MeasurementKernelSchema, required=True)
discriminator = Nested(DiscriminatorSchema, required=True)
qubit_freq_est = List(Number(), required=False,
validate=Length(min=1), missing=None)
Copy link
Member

Choose a reason for hiding this comment

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

As discussed in private, can we avoid having missing=, and instead either encourage the backends to provide sensible values for the attributes, or handle them somewhere in the pulse layers in terra? The rationale is that having a "default" blurs the separation between models (acting as "dummy containers") and logic a bit, and requires consumers to not only take into account the models, but the defaults - and if they reach that point, they are probably better off handling that in a different layer altogether, closer to the one that implements the functionality that uses those parameters or similar.

buffer = Integer(required=False, validate=Range(min=0), missing=0)
pulse_library = Nested(PulseLibraryItemSchema, required=True, many=True, missing=lambda: [])
meas_kernel = Nested(MeasurementKernelSchema, required=False, missing=None)
discriminator = Nested(DiscriminatorSchema, required=False, missing=None)

# Optional properties.
Copy link
Member

Choose a reason for hiding this comment

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

For consistency with rest of the codebase, can you remove required=False from the optional parameters and place them under:

# Optional properties.

@@ -140,13 +140,4 @@ class PulseDefaults(BaseModel):
discriminator (Discriminator): Default discriminator.
"""

def __init__(self, qubit_freq_est, meas_freq_est, buffer, pulse_library,
Copy link
Member

Choose a reason for hiding this comment

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

Also for consistency with the rest of the codebase - if some of the parameters end up being required=True, can you make sure they are included in the constructor parameters and set inside it?

@@ -140,13 +140,5 @@
"type": "array"
}
},
"required": [
Copy link
Member

Choose a reason for hiding this comment

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

Also a reminder to make sure that if some of the parameters end up being required, they should be kept in this section of the .json, in the hopes of facilitating keeping them in sync eventually.

@diego-plan9 diego-plan9 merged commit 4c482ab into Qiskit:master Apr 11, 2019
lia-approves pushed a commit to edasgupta/qiskit-terra that referenced this pull request Jul 30, 2019
* Removed required default parameters.

* Update changelog. Update defaults model validation to add nonetypes.

* Update changelog.

* Readd parameters to be required.

* Update changelog and defaults required parameters.
@1ucian0 1ucian0 added the mod: pulse Related to the Pulse module label Jan 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mod: pulse Related to the Pulse module type: specs Issues and PRs that involve modifications to the open specs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants