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

Testing the Connection #20

Closed
ccoffrin opened this issue Feb 17, 2018 · 4 comments
Closed

Testing the Connection #20

ccoffrin opened this issue Feb 17, 2018 · 4 comments
Labels

Comments

@ccoffrin
Copy link

One thing that is a little odd to me is that I can setup a connection like so,

conn = dwave_micro_client.Connection(...)

with a bunch of junk data and I only notice that the connection is broken when I try to use it with a call like,

solver = conn.get_solver()

Maybe the Connection init function could make a simple test, just to make sure it can talk to the server.

@randomir
Copy link
Member

"Easier to ask for forgiveness than permission". :)
The Connection constructor only initializes the connection object (with url, token, etc). The first actual connect attempt is on Connection.solver_names()/Connection.get_solver()/Future.result().

This actually makes sense, because the only reliable way to test for validity of url/token/proxies is to try to connect to the API.

@ccoffrin
Copy link
Author

Ok. Follow up question, given an initialized connection object, what is the proper way to test if the connection parameters are valid?

@randomir
Copy link
Member

The pythonic way would be to just go ahead and do an API request, e.g. Connection.solver_names(), assuming it will succeed, and catch any network/token exceptions which would signal a bad url/token.

If each call to SAPI had a very large cost associated with it (e.g. time to success/failure), a "ping"/"verify" endpoint would then be useful. But currently, Connection.solver_names()/Connection.get_solver() can be regarded as such low cost "canary" endpoints.

@ccoffrin
Copy link
Author

Ok, I'll close this issue then.

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

No branches or pull requests

2 participants