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

allow instantiation of qcvv experiments without superstaq credentials #1076

Merged
merged 3 commits into from
Sep 27, 2024

Conversation

richrines1
Copy link
Contributor

currently instantiating a qcvv experiment will fail if a css.Service can't be constructed, even if we don't require superstaq functionality

@@ -189,12 +189,20 @@ def __init__(
self._samples: Sequence[Sample] | None = None
"""The attribute to store the experimental samples in."""

self._service: css.service.Service = css.service.Service(**kwargs)
self._service_kwargs = kwargs
self._service: css.Service | None = None
Copy link
Contributor

Choose a reason for hiding this comment

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

Given the property superstaq_service which creates a service when needed, what is the point of having the _service attribute which is always initialized to None?

If we want to give the user an option to use some prebuilt service, then I suggest we have a service kwarg which defaults to None and overrides any other service kwargs that the user provides.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the idea was that .superstaq_service used this attribute to store the service the first time it's referenced, and then returned it in subsequent references so the service only gets instantiated once. not sure why i didn't just use @cached_property though - updated.

(agree we might think about allowing the user to pass in a prebuilt service as well though - was mostly trying to avoid any changes in functionality in this pr)

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah yeah, thats much nicer!

Copy link
Contributor

@cdbf1 cdbf1 left a comment

Choose a reason for hiding this comment

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

lgtm

@richrines1 richrines1 merged commit eb2e055 into main Sep 27, 2024
20 checks passed
@richrines1 richrines1 deleted the qcvv-lazy-service branch September 27, 2024 13:50
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.

2 participants