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

Driver/ami430 allow all units & fix warnings as exceptions #954

Merged
merged 9 commits into from
Jan 29, 2018

Conversation

spauka
Copy link
Contributor

@spauka spauka commented Jan 25, 2018

Fixes #952, #953.
In addition, adds a switch heater submodule that allows for setting of SwitchHeater parameters.

Changes proposed in this pull request:

  • Allows the AMI430 to be operated with ramp rates specified in minutes, allows field units in kiloGauss.
  • Adds an instrument specific exception for instrument errors (i.e. allows us to differentiate why ramps may have failed between validation errors and instrument state)
  • Fixes bug in current_ramp_limit code that prevents user from setting a limit higher than 0.6A/s
  • Allows user to set field_ramp_limit, field_rating in instrument units, rather than having to convert to Amps.
  • Adds AMI430_SwitchHeater submodule that allows configuration of switch heater parameters.
  • Removes duplicated code between set_field, _set_field and ramp_to. Makes block a named parameter.
  • Deprecate ramp_to as it duplicates the functionality of ramp_to.
  • Don't automatically turn on switch heater before ramping, we may have a persistent current and this could cause a quench.
  • Ensure the number of segments in ramps is 1. There is currently no support in the driver for more than 1 ramp segment.

API changes

There are no changes to the public facing API apart from the addition of new features and the deprecation warning on ramp_to.

@sohailc I notice that you're also working on changes to how 3D works in this driver, in PR #910. None of the changes as far as I can tell intersect with yours, but as a result I haven't spent much time adding documentation or extending 3D functionality. Can we chat and discuss how best to add docs and type hints such that we don't conflict?

@jenshnielsen @sohailc

- The driver now supports both kGuass and Tesla, which are both units
that are supported by the controller, and allows switching between the
two.

- In addition, warnings about ramp rate are now just warnings as opposed
to exceptions that prevent the driver from initializing.
- Adds new parameters into the test framework
@codecov
Copy link

codecov bot commented Jan 25, 2018

Codecov Report

Merging #954 into master will increase coverage by 0.03%.
The diff coverage is 69.92%.

@@            Coverage Diff             @@
##           master     #954      +/-   ##
==========================================
+ Coverage   77.05%   77.08%   +0.03%     
==========================================
  Files          37       37              
  Lines        5182     5233      +51     
==========================================
+ Hits         3993     4034      +41     
- Misses       1189     1199      +10


log = logging.getLogger(__name__)

class AMI430Exception(Exception):
Copy link
Member

Choose a reason for hiding this comment

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

I do not quite understand why we need to make a custom exception. Can you explain?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just so that errors that are specific to the instrument state are differentiated from user errors (like ValueErrors) or python errors. I suppose they can be replaced by RuntimeErrors, but this seems like a poor fit given that they are used everywhere, and the error type suggests the error occured within python.

In particular, I imagined using it to detect a failure to sweep field in my own code, then automatically taking action.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I see your point.

@sohailc
Copy link
Member

sohailc commented Jan 25, 2018

This seems like a good modification to me. I have one comment if you can address that, please. Other than that, good job

@spauka
Copy link
Contributor Author

spauka commented Jan 28, 2018

Awesome :)

I can't merge, but if you guys are happy can we merge this?

@sohailc
Copy link
Member

sohailc commented Jan 29, 2018

I think before we can merge we need to make sure all checks pass. It should be quite trivial to make this happen :-)

@WilliamHPNielsen
Copy link
Contributor

@sohailc But the tests are passing? The few issues from Codacy are actually non-issues. See here: pylint-dev/pylint#1609. The lambdas were there before this PR.

@sohailc
Copy link
Member

sohailc commented Jan 29, 2018

Even though the lambda's are from before this PR, I think we should take every chance we get to improve code quality. @spauka can you please review the code quality suggestions and make improvements accordingly? They won't take more than a couple of minutes.

@WilliamHPNielsen Lets ignore the Codacy issues.

@sohailc
Copy link
Member

sohailc commented Jan 29, 2018

Oh and obviously please make sure that this branch is up to date with the base branch.

@spauka
Copy link
Contributor Author

spauka commented Jan 29, 2018

Hey @sohailc. Regarding Codacy issues:

  • As @WilliamHPNielsen mentions, unused class variables are not true, both AMI430SwitchHeater and _Decorators are used.
  • Regarding lambdas, there isn't an easy way around this. Both get_cmd and set_cmd wrap the argument as a Command, which checks qcodes.utils.deferred_operations.is_function, which returns False for a parameter. Either the behavior of Command is changed, or it has to be wrapped in a function or lambda.

Regarding code coverage, I guess this refers to the new SwitchHeater class. I can add tests tomorrow.

@sohailc
Copy link
Member

sohailc commented Jan 29, 2018

@spauka I don't understand. Why can you not change this:

get_cmd=lambda: self.current_ramp_limit()

to

get_cmd=self.current_ramp_limit

? Since "current_ramp_limit" is a class method and not a parameter, this should be fine.

@spauka
Copy link
Contributor Author

spauka commented Jan 29, 2018

@sohailc See the above comment. self.current_ramp_limit is a parameter, and is_function does not detect a Parameter as a function with the correct number of parameters.

@sohailc
Copy link
Member

sohailc commented Jan 29, 2018

You are right. I will merge this branch now after updating it

@sohailc
Copy link
Member

sohailc commented Jan 29, 2018

Hang on, the CI tests have failed this time. @spauka can you re-run the test by making a trivial change and pushing your code again?

@spauka spauka closed this Jan 29, 2018
@spauka spauka reopened this Jan 29, 2018
@spauka
Copy link
Contributor Author

spauka commented Jan 29, 2018

@sohailc Should be all good :)

@sohailc sohailc merged commit 1ced7f3 into microsoft:master Jan 29, 2018
@sohailc
Copy link
Member

sohailc commented Jan 29, 2018

Merged :-)

giulioungaretti pushed a commit that referenced this pull request Jan 29, 2018
Merge: 2a93bd7 18f453a
Author: sohail chatoor <schatoor@gmail.com>

    Merge pull request #954 from spauka/driver/ami430_expand
@WilliamHPNielsen
Copy link
Contributor

WilliamHPNielsen commented Jan 29, 2018

@sohailc When the tests fail, you (unfortunately) have to examine why. Travis is very slow at running tests, and a test counts as failed if it exceeds the hypothesis deadline. That puts us in a situation where tests fail not due to problems with the code, but due to heavy load on Travis' servers. It should be pretty easy to deduce from the Travis log what happened.

It is not optimal this way, and we should probably increase/disable deadlines if this keeps happening. @jenshnielsen already did this a few times, see #912 and #905.

@jenshnielsen
Copy link
Collaborator

We should probably just disable the hypothesis deadline on those tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants