-
Notifications
You must be signed in to change notification settings - Fork 6
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
Feat db jobs and results #118
base: dev
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,939 @@ | |||
{ |
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 would name this file differently: the goal is not to have a DB per say, but to be able to save and load results. I have to checkout this file, but this could even be part of another notebook
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 stand by that, with the Result
integration, I would even have just a small mention in one of the first notebooks
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 agree, we can rename it "Result management"
@@ -165,7 +164,17 @@ def __init__( | |||
self.add(deepcopy(data)) | |||
|
|||
def __eq__(self, value: object) -> bool: | |||
return dumps(self) == dumps(value) |
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 provide me with an example where this didn't work (for my culture)
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.
The problem came from somewhere else but I had kept the change. I discard the change and all the tests passed.
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.
the change was not discarded though ?
@@ -198,7 +209,7 @@ def set_size(self, nb_qubits: int): | |||
pass | |||
|
|||
def __repr__(self) -> str: | |||
return f"{type(self).__name__}()" | |||
return f"{type(self).__name__}({self.nb_qubits})" |
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.
we should check if the basis is dynamic or not and put or not the number of
qubits depending on that
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.
done
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.
did you just revert the change ? I don't see the modif anymore ?
mpqp/local_storage/queries.py
Outdated
|
||
|
||
@ensure_db | ||
def fetch_results_with_result(result: Result | BatchResult | list[Result]): |
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.
what's the difference with fetch_results_with_result_and_job
?
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.
removed ?
mpqp/local_storage/load.py
Outdated
>>> jobs = get_all_jobs() | ||
>>> for job in jobs: | ||
... print(job) | ||
Job(JobType.SAMPLE, QCircuit([H(0), CNOT(0, 1), BasisMeasure([0, 1], c_targets=[0, 1], basis=ComputationalBasis(2))], nb_qubits=2, nb_cbits=2, label="H CX BM"), IBMDevice.AER_SIMULATOR, BasisMeasure([0, 1], c_targets=[0, 1], basis=ComputationalBasis(2))) |
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.
ellipsis
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.
done
mpqp/local_storage/load.py
Outdated
>>> jobs = get_jobs_with_id([1, 2, 3]) | ||
>>> for job in jobs: | ||
... print(job) | ||
Job(JobType.SAMPLE, QCircuit([H(0), CNOT(0, 1), BasisMeasure([0, 1], c_targets=[0, 1], basis=ComputationalBasis(2))], nb_qubits=2, nb_cbits=2, label="H CX BM"), IBMDevice.AER_SIMULATOR, BasisMeasure([0, 1], c_targets=[0, 1], basis=ComputationalBasis(2))) |
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.
ellipsis
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.
done
mpqp/local_storage/load.py
Outdated
job: Job(s) to search for. | ||
|
||
Returns: | ||
Matching job(s). |
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.
what's the matching criterion ?
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.
done
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.
did you check the doc generates properly here ?
@@ -19,4 +19,7 @@ def test_basis_measure_init_fails_duplicate_c_targets(): | |||
def test_basis_measure_repr(): | |||
measure = BasisMeasure([0, 1], shots=1025) | |||
representation = repr(measure) | |||
assert representation == "BasisMeasure([0, 1], shots=1025)" |
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 think that's wrong
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.
Outdated, changes discarded.
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.
are they ?
@@ -189,7 +189,7 @@ def test_count(circuit: QCircuit, filter: tuple[type[Gate]], count: int): | |||
), | |||
] | |||
), | |||
"[BasisMeasure([0, 1], shots=1000), ExpectationMeasure(" |
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.
wrong again
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.
Outdated, changes discarded.
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.
are they ?
@@ -49,8 +49,8 @@ | |||
H(0), | |||
H(1), | |||
CNOT(0, 1), | |||
BasisMeasure([0]), | |||
BasisMeasure([1]), | |||
BasisMeasure([0], [0]), |
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.
wonrg
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.
No, because we are checking the BasisMeasure repr but as it is not associated with a circuit, is not dynamic. So we need to specify the c_targets.
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.
see comments
>>> jobs = fetch_jobs_with_job(job) | ||
>>> for job in jobs: | ||
... print("job_id:", job['id']) | ||
|
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.
wouldn't the example be more speaking with actual results printed ?
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 stopped the review at expectation_value.py
@@ -0,0 +1,939 @@ | |||
{ |
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 agree, we can rename it "Result management"
def to_dict(self) -> dict[str, int | str | list[str] | float | None]: | ||
""" | ||
Serialize the quantum circuit to a dictionary. | ||
Returns: |
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.
Do you think we can include a small example for this method in the docstring?
@@ -104,7 +104,7 @@ def __str__(self) -> str: | |||
from mpqp.core.circuit import QCircuit | |||
|
|||
connection = self.connections() | |||
circuit_size = max(connection) + 1 if connection else 1 | |||
circuit_size = max(connection) + 1 if len(connection) == 0 else 1 |
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.
You mean if len(connection) != 0
here ? Otherwise it doesn't make sense
@@ -163,6 +163,17 @@ def to_computational(self): | |||
] | |||
) | |||
|
|||
def __eq__(self, other: object) -> bool: |
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.
Do you take into account here that we can call __eq__
to compare a Basis and VariableSizeBasis ?
No description provided.