-
Notifications
You must be signed in to change notification settings - Fork 127
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
Bugfix when copying the ExperiemntData
object and add warning to _retrieve_data
#1316
Conversation
`copy` method now copies `provider` to the experiment data. In `_retrieve_data` method, the user will be warned if the provider is not given.
ExperiemntData
object and add warning to _retrievve_data
ExperiemntData
object and add warning to _retrieve_data
Added a check for existing data in the `ExperimentData` object to not spam the user if a simulator is used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOG.warning( | ||
"provider is None and there is no result data that are stored." | ||
" no data was retrieved." | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Why are you copying
_result_data
? - Why did you add the
and not self._result_data.copy()
section? It makes the code continue where previously it returned. - The warning is not clear. Replace it with something similar to what you wrote in the release notes, which is rephrased much better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Because
_result_data
can be locked so I used the copy method. - I used
and not self._result_data.copy()
so it will not print the warning unnecessarily. If there is no provider but there are results inself._result_data
, the warning is meaningless. - What about
Provider for ExperimentData object doesn't exist. Failed to retrieve data from the server.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please elaborate a bit about what _result_data
is, and when it is expected to be populated, is there a scenario (now that the provider is copied, and assuming that there's no other bug) that the provider is None
? You can answer some of these questions in inline comments. In general if you can please explain the general picture here.
- What do you mean by "locked", and how is copying related?
- After the
if
come not only the warning but also thereturn
statement, which was there also before this PR. So it looks like, in addition to the warning, there is also a change in behavior introduced here. - Looks good. You're not mentioning the
_result_data
thing, but I don't fully understand what it is so can't tell if it's necessary to include it in the warning message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_result_data
is an attribute ofExperimentData
of typeThreadSafeList()
and is used as a list ofResult
object. As a thread safe object, whenever_result_data
is being is being accessed (append data, read data, etc) it is needed to be locked (Source for working with safe thread obj here). Thecopy
method is taking care of it automatically so I used it for clear code reading.- True, I changed it to
if self.provider is None:
if not self._result_data.copy():
# Adding warning so the user will have indication why the analysis may fail.
LOG.warning("Warning Text.")
return
- I am not sure if to include it in the warning as this warning is there to indicate the user that the problem in analysis could be due to missing data. What about the following sentence? "Provider for ExperimentData object doesn't exist, resulting in a failed attempt to retrieve data from the server ; no stored result data exists"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(3) is very good. Only remove the space between "server" and the semicolon that follows it.
(2) is also good.
I still don't understand (1). Is _result_data
already locked, and for some reason you want to overcome it, and the copying helps you with this? Or does copy
lock, in this case, why do you want to lock? And when will it be unlocked? And what's locked - the original or the copy? Anyhow this should be explained in a code comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand. The original _result_data
is locked, therefore the check if _result_data
is impossible. So you copy it, the new object is not locked and you can check if _result_data.copy()
. So just please an inline comment in the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These items have to be completed for approval:
- Note my previous comment about connection to the original issue.
- An answer from @coruscating about the release notes.
- And of course what remains from the other comments.
LOG.warning( | ||
"provider is None and there is no result data that are stored." | ||
" no data was retrieved." | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please elaborate a bit about what _result_data
is, and when it is expected to be populated, is there a scenario (now that the provider is copied, and assuming that there's no other bug) that the provider is None
? You can answer some of these questions in inline comments. In general if you can please explain the general picture here.
- What do you mean by "locked", and how is copying related?
- After the
if
come not only the warning but also thereturn
statement, which was there also before this PR. So it looks like, in addition to the warning, there is also a change in behavior introduced here. - Looks good. You're not mentioning the
_result_data
thing, but I don't fully understand what it is so can't tell if it's necessary to include it in the warning message.
I added to a test under |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please run locally in your environment the code snippet of #1314. If it works then you can merge.
…retrieve_data` (qiskit-community#1316) ### Summary As said in qiskit-community#1314 , `copy` method in `Experiment Data` class will now copy the `provider` attribute to the copied instance and warnning if data isn't retrieved due to `provider=None` . ### Details and comments Some details that should be in this section include: - Why this change was necessary This is a bug that the provider isn't copied. In addition, `_retrive_data()` method in the `ExperimentData` class doesn;t retirive data if provider is not provided. Added a warning so the user will know.
…retrieve_data` (qiskit-community#1316) ### Summary As said in qiskit-community#1314 , `copy` method in `Experiment Data` class will now copy the `provider` attribute to the copied instance and warnning if data isn't retrieved due to `provider=None` . ### Details and comments Some details that should be in this section include: - Why this change was necessary This is a bug that the provider isn't copied. In addition, `_retrive_data()` method in the `ExperimentData` class doesn;t retirive data if provider is not provided. Added a warning so the user will know.
Summary
As said in #1314 ,
copy
method inExperiment Data
class will now copy theprovider
attribute to the copied instance and warnning if data isn't retrieved due toprovider=None
.Details and comments
Some details that should be in this section include:
This is a bug that the provider isn't copied. In addition,
_retrive_data()
method in theExperimentData
class doesn;t retirive data if provider is not provided. Added a warning so the user will know.