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

Make get_targets return list if names is None #606

Merged
merged 8 commits into from
May 2, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions azure-quantum/azure/quantum/target/target_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@

def get_targets(
self,
name: str,
provider_id: str,
name: str = None,
provider_id: str = None,
**kwargs
) -> Union[Target, List[Target]]:
"""Create targets that are available to this workspace
Expand All @@ -129,8 +129,13 @@
"""
target_statuses = self._workspace._get_target_status(name, provider_id)

# TODO: Make this function always return a list in the next major release.
Dismissed Show dismissed Hide dismissed
if len(target_statuses) == 1:
return self.from_target_status(*target_statuses[0], **kwargs)
result = self.from_target_status(*target_statuses[0], **kwargs)
if name is None:
return [result]
else:
return result

else:
# Don't return redundant targets
Expand Down
Loading