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

Add support for multiple platform paths #903

Merged
merged 7 commits into from
Jun 3, 2024
Merged

Add support for multiple platform paths #903

merged 7 commits into from
Jun 3, 2024

Conversation

alecandido
Copy link
Member

@alecandido alecandido commented May 16, 2024

This is mainly an extension of the platform loading feature that I had in mind since long (i.e. just treat $QIBOLAB_PLATFORMS as most of the other $PATH-like variables, with multiple paths and fallback).

I started implementing this as a service for #849, to have both dummy_qrc and emulators in scope. However, I doubt it will be useful there, since I will just implement a separate fixture for that (though I could convert dummy_qrc to a more generic platforms fixture, up for voting).

In the process, I started narrowing the exports of Qibolab, since I was already touching __init__.py. More or less going in the direction of #790.

Ok, this is usually not a great idea, and I'm already kind of regretting...
I hope that is not breaking anything (things not listed in __all__ are exported by accident, and should not be used), but I might split it anyhow...

@alecandido
Copy link
Member Author

alecandido commented May 16, 2024

@Jacfomg, since you added them: why are these exported top-level?

from qibolab.execution_parameters import (
AcquisitionType,
AveragingMode,
ExecutionParameters,
)

We could export even more, but currently we are not doing it, so it's rather asymmetric (e.g. Pulse and PulseSequence are not exported top-level, though they are arguably as relevant as ExecutionParameters, or even more).

@andrea-pasquale removing this would break Qibocal? In any case, we could do it in 0.2, and that would not be a big deal (wrt everything else there...)

Copy link

codecov bot commented May 16, 2024

Codecov Report

Attention: Patch coverage is 98.57143% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 66.90%. Comparing base (485f416) to head (4972ed9).

Files Patch % Lines
src/qibolab/platform/load.py 96.77% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #903      +/-   ##
==========================================
+ Coverage   66.81%   66.90%   +0.08%     
==========================================
  Files          55       58       +3     
  Lines        5970     5983      +13     
==========================================
+ Hits         3989     4003      +14     
+ Misses       1981     1980       -1     
Flag Coverage Δ
unittests 66.90% <98.57%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@andrea-pasquale
Copy link
Contributor

@andrea-pasquale removing this would break Qibocal? In any case, we could do it in 0.2, and that would not be a big deal (wrt everything else there...)

Yes, it will break qibocal but it should be an easy fix.

@alecandido
Copy link
Member Author

Yes, it will break qibocal but it should be an easy fix.

At the moment, I'm not touching it.

I will do it in 0.2

@alecandido alecandido added this to the Qibolab 0.1.7 milestone May 16, 2024
@alecandido alecandido marked this pull request as ready for review May 16, 2024 17:33
@alecandido
Copy link
Member Author

Despite a bunch of reshuffling, this is intended to target 0.1.x (I added the milestone to make this clear).

For this reason, we should test that it's not breaking Qibocal, nor any platform working with the current Qibolab main. I would kindly ask the reviewers (@stavros11 and @andrea-pasquale) to do this, since, for you, it should be just a matter of reinstalling Qibolab with this branch in an environment you're already using for something else.

All the things I've moved around should have been considered internal, so it is formally non-breaking (but I hope it's non-breaking even in practice).

alecandido added a commit that referenced this pull request May 16, 2024
A pytest fixture is defined for the purpose, keeping it separate from the dummy_qrc for the time being, at least until #903 will be merged
alecandido added a commit that referenced this pull request May 16, 2024
A pytest fixture is defined for the purpose, keeping it separate from the dummy_qrc for the time being, at least until #903 will be merged
@Jacfomg
Copy link
Contributor

Jacfomg commented May 17, 2024

@Jacfomg, since you added them: why are these exported top-level?

I don't remenber who, but it was for the qibocal imports. Yes, changing would requiere changing it the import on each routine but only that.

@stavros11
Copy link
Member

stavros11 commented May 17, 2024

For this reason, we should test that it's not breaking Qibocal, nor any platform working with the current Qibolab main. I would kindly ask the reviewers (@stavros11 and @andrea-pasquale) to do this, since, for you, it should be just a matter of reinstalling Qibolab with this branch in an environment you're already using for something else.

For now I get an error coming from this line in qibocal: https://github.com/qiboteam/qibocal/blob/37d060599c739b3b70602505d29509af295aedb0/src/qibocal/protocols/randomized_benchmarking/utils.py#L9
This is expected given the changes in this PR, however it is clearly a qibocal issue: why is defaultdict imported from qibolab instead of collections (standard library)?

Also, unrelated with the above point, but I see that tests here are failing for windows. Maybe some path related convention?

EDIT: Apart from the defaultdict issue, qibocal seems to work with this branch, at least the single shot and allXY that I tried (but is unlikely that some other routine is broken, given the changes).

@Jacfomg
Copy link
Contributor

Jacfomg commented May 17, 2024

For this reason, we should test that it's not breaking Qibocal, nor any platform working with the current Qibolab main. I would kindly ask the reviewers (@stavros11 and @andrea-pasquale) to do this, since, for you, it should be just a matter of reinstalling Qibolab with this branch in an environment you're already using for something else.

For now I get an error coming from this line in qibocal: https://github.com/qiboteam/qibocal/blob/37d060599c739b3b70602505d29509af295aedb0/src/qibocal/protocols/randomized_benchmarking/utils.py#L9 This is expected given the changes in this PR, however it is clearly a qibocal issue: why is defaultdict imported from qibolab instead of collections (standard library)?

Also, unrelated with the above point, but I see that tests here are failing for windows. Maybe some path related convention?

EDIT: Apart from the defaultdict issue, qibocal seems to work with this branch, at least the single shot and allXY that I tried (but is unlikely that some other routine is broken, given the changes).

Yes the import should not be like that, I will fix it.

@alecandido
Copy link
Member Author

alecandido commented May 17, 2024

Ok, great!

I just have to fix a test (because I need the path to be escaped for Windows), and on my side this is ready.

@stavros11 in case you're interested in, the problem is that the path separator on Windows is the same as the escape character, i.e. \. Thus, the path has to be escaped, but only on Windows...
(in any case, it is only a problem with the tests, Qibolab is working perfectly fine with both, if the path is suitably specified according to the platform)

Copy link
Member

@stavros11 stavros11 left a comment

Choose a reason for hiding this comment

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

Thanks @alecandido, looks good to me. My only concern is that the file reshuffling may cause some weird conflicts with 0.2, but if you are planning to do the rebase I don't have any objection.

from .load import create_platform
from .platform import Platform, unroll_sequences

__all__ = ["Platform", "create_platform", "unroll_sequences"]
Copy link
Member

Choose a reason for hiding this comment

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

This is probably trying to reproduce the previous behavior, however in principle we don't need to necessarily expose unroll_sequences externally. I think it is only used by the Platform internally.

Copy link
Member Author

Choose a reason for hiding this comment

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

Point is that I don't know what is used and what not, so I kept it to avoid breaking anything.

But what you say makes sense to me, so we could even immediately drop from 0.2.

src/qibolab/version.py Show resolved Hide resolved
@alecandido
Copy link
Member Author

but if you are planning to do the rebase I don't have any objection.

I have to take care of my own mess :P
I wanted to move even backends.py under platforms/ (before the backend and the platform have a very similar role, essentially the backend is just an interface for the platform), but I saved that for 0.2.

Copy link
Contributor

@andrea-pasquale andrea-pasquale left a comment

Choose a reason for hiding this comment

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

Thanks @alecandido, looks good to me.
I just have a suggestion.

src/qibolab/platform/load.py Show resolved Hide resolved
@alecandido
Copy link
Member Author

alecandido commented Jun 3, 2024

@stavros11 @andrea-pasquale: I've just rebased, so, as soon as the tests will pass, and given the double approval, I'll directly merge.

@alecandido alecandido merged commit 2e6c082 into main Jun 3, 2024
24 checks passed
@alecandido alecandido deleted the platforms-paths branch June 3, 2024 11:25
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