qctrl-workflow-client 5.3.1__tar.gz → 5.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: qctrl-workflow-client
3
- Version: 5.3.1
3
+ Version: 5.5.0
4
4
  Summary: Q-CTRL Workflow Client
5
5
  License: https://q-ctrl.com/terms
6
6
  Keywords: black opal,boulder opal,fire opal,nisq,open controls,q control,q ctrl,q-control,q-ctrl,qcontrol,qctrl,quantum,quantum algorithms,quantum circuits,quantum coding,quantum coding software,quantum computing,quantum control,quantum control software,quantum control theory,quantum engineering,quantum error correction,quantum firmware,quantum fundamentals,quantum sensing,qubit,qudit
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "qctrl-workflow-client"
3
- version = "5.3.1"
3
+ version = "5.5.0"
4
4
  description = "Q-CTRL Workflow Client"
5
5
  license = "https://q-ctrl.com/terms"
6
6
  authors = ["Q-CTRL <support@q-ctrl.com>"]
@@ -11,7 +11,7 @@
11
11
  # distributed under the License is distributed on an "AS IS" BASIS. See the
12
12
  # License for the specific language.
13
13
 
14
- __version__ = "5.3.1"
14
+ __version__ = "5.5.0"
15
15
 
16
16
  from .defaults import get_authenticated_client_for_product
17
17
  from .functions import (
@@ -688,8 +688,74 @@ class ApiRouter(BaseRouter):
688
688
  )
689
689
  return response["tenant"]["tenant"]["currentInstances"]
690
690
 
691
+ def get_usage_time(self) -> float:
692
+ """
693
+ Return the total usage time of the machines in the user's cloud environment.
694
+ """
695
+ _query = gql.gql(
696
+ """
697
+ query UsageSummary($organizationId: ID!) {
698
+ tenant(organizationId: $organizationId) {
699
+ tenant {
700
+ usageSummary {
701
+ allocatedComputeSeconds
702
+ usedComputeSeconds
703
+ availableComputeSeconds
704
+ }
705
+ }
706
+ errors {
707
+ message
708
+ }
709
+ }
710
+ }
711
+ """
712
+ )
713
+
714
+ response = self._client.execute(
715
+ _query,
716
+ {"organizationId": self._get_configured_organization().organization_id},
717
+ )
718
+ return response["tenant"]["tenant"]["usageSummary"]
719
+
720
+ def shut_down_machines(self) -> dict[str, Any]:
721
+ """
722
+ Shut down all the machines in the user's cloud environment.
723
+
724
+ Returns
725
+ -------
726
+ dict[str, Any]
727
+ The response from the server,
728
+ like {'terminateTenant': {'successMessage': '...', 'errors': Any}}
729
+ """
730
+ _query = gql.gql(
731
+ """
732
+ mutation terminateTenant($organizationId: ID!, $organizationSlug: String!) {
733
+ terminateTenant(
734
+ input: {organizationId: $organizationId, organizationSlug: $organizationSlug}
735
+ ) {
736
+ successMessage
737
+ errors {
738
+ fields
739
+ message
740
+ }
741
+ }
742
+ }
743
+ """
744
+ )
745
+ return self._client.execute(
746
+ _query,
747
+ {
748
+ "organizationId": self._get_configured_organization().organization_id,
749
+ "organizationSlug": self._get_configured_organization().slug,
750
+ },
751
+ )
752
+
691
753
  def activity_monitor(
692
- self, limit: int, offset: int = 0, status: Optional[str] = None
754
+ self,
755
+ limit: int,
756
+ offset: int = 0,
757
+ status: Optional[str] = None,
758
+ only_user_results: bool = True,
693
759
  ) -> list[dict[str, Any]]:
694
760
  """
695
761
  Fetch metadata from previously submitted actions.
@@ -703,6 +769,10 @@ class ApiRouter(BaseRouter):
703
769
  Defaults to 0.
704
770
  status : str or None, optional
705
771
  The filter for action status. Defaults to None.
772
+ only_user_results : bool, optional
773
+ If True, only fetch actions that belong to the user;
774
+ otherwise, fetch actions that belong to the user's organization.
775
+ Defaults to True.
706
776
 
707
777
  Returns
708
778
  -------
@@ -734,6 +804,8 @@ class ApiRouter(BaseRouter):
734
804
  check_argument(offset >= 0, "Offset must be at least 0.", {"offset": offset})
735
805
 
736
806
  filter_by = {}
807
+ if not only_user_results:
808
+ filter_by["organizationSlug"] = self._get_configured_organization().slug
737
809
  if status is not None:
738
810
  valid_statuses = [status.value for status in ActionStatus]
739
811
  check_argument(