openquantum-sdk 0.3.3__tar.gz → 0.3.4__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.
Files changed (25) hide show
  1. {openquantum_sdk-0.3.3/openquantum_sdk.egg-info → openquantum_sdk-0.3.4}/PKG-INFO +12 -1
  2. openquantum_sdk-0.3.3/PKG-INFO → openquantum_sdk-0.3.4/README.md +11 -11
  3. {openquantum_sdk-0.3.3 → openquantum_sdk-0.3.4}/openquantum_sdk/__init__.py +1 -1
  4. {openquantum_sdk-0.3.3 → openquantum_sdk-0.3.4}/openquantum_sdk/clients.py +20 -0
  5. {openquantum_sdk-0.3.3 → openquantum_sdk-0.3.4}/openquantum_sdk/models.py +7 -0
  6. openquantum_sdk-0.3.3/README.md → openquantum_sdk-0.3.4/openquantum_sdk.egg-info/PKG-INFO +22 -0
  7. {openquantum_sdk-0.3.3 → openquantum_sdk-0.3.4}/pyproject.toml +1 -1
  8. {openquantum_sdk-0.3.3 → openquantum_sdk-0.3.4}/tests/test_clients.py +12 -2
  9. {openquantum_sdk-0.3.3 → openquantum_sdk-0.3.4}/MANIFEST.in +0 -0
  10. {openquantum_sdk-0.3.3 → openquantum_sdk-0.3.4}/openquantum_sdk/__main__.py +0 -0
  11. {openquantum_sdk-0.3.3 → openquantum_sdk-0.3.4}/openquantum_sdk/auth.py +0 -0
  12. {openquantum_sdk-0.3.3 → openquantum_sdk-0.3.4}/openquantum_sdk/enums.py +0 -0
  13. {openquantum_sdk-0.3.3 → openquantum_sdk-0.3.4}/openquantum_sdk/qiskit/__init__.py +0 -0
  14. {openquantum_sdk-0.3.3 → openquantum_sdk-0.3.4}/openquantum_sdk/utils.py +0 -0
  15. {openquantum_sdk-0.3.3 → openquantum_sdk-0.3.4}/openquantum_sdk.egg-info/SOURCES.txt +0 -0
  16. {openquantum_sdk-0.3.3 → openquantum_sdk-0.3.4}/openquantum_sdk.egg-info/dependency_links.txt +0 -0
  17. {openquantum_sdk-0.3.3 → openquantum_sdk-0.3.4}/openquantum_sdk.egg-info/entry_points.txt +0 -0
  18. {openquantum_sdk-0.3.3 → openquantum_sdk-0.3.4}/openquantum_sdk.egg-info/requires.txt +0 -0
  19. {openquantum_sdk-0.3.3 → openquantum_sdk-0.3.4}/openquantum_sdk.egg-info/top_level.txt +0 -0
  20. {openquantum_sdk-0.3.3 → openquantum_sdk-0.3.4}/requirements-dev.txt +0 -0
  21. {openquantum_sdk-0.3.3 → openquantum_sdk-0.3.4}/requirements.txt +0 -0
  22. {openquantum_sdk-0.3.3 → openquantum_sdk-0.3.4}/setup.cfg +0 -0
  23. {openquantum_sdk-0.3.3 → openquantum_sdk-0.3.4}/tests/__init__.py +0 -0
  24. {openquantum_sdk-0.3.3 → openquantum_sdk-0.3.4}/tests/conftest.py +0 -0
  25. {openquantum_sdk-0.3.3 → openquantum_sdk-0.3.4}/tests/test_qiskit_wrappers.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: openquantum-sdk
3
- Version: 0.3.3
3
+ Version: 0.3.4
4
4
  Summary: Python SDK for Open Quantum
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Classifier: License :: OSI Approved :: Apache Software License
@@ -58,6 +58,13 @@ auth = ClientCredentialsAuth(
58
58
  )
59
59
  ```
60
60
 
61
+ ### Option 3: Environment Variables
62
+
63
+ ```bash
64
+ export OPENQUANTUM_CLIENT_ID=s_...
65
+ export OPENQUANTUM_CLIENT_SECRET=e460c8...
66
+ ```
67
+
61
68
  ## Quickstart: One-Call Submission (Recommended)
62
69
 
63
70
  ```python
@@ -290,6 +297,7 @@ finally:
290
297
  | `list_user_organizations(limit=20, cursor=...)` | `PaginatedOrganizations` | Your orgs |
291
298
  | `list_providers(limit=20, cursor=...)` | `PaginatedProviders` | All backend providers |
292
299
  | `list_backend_classes(provider_id=None, limit=20, cursor=...)` | `PaginatedBackendClasses` | Available backends |
300
+ | `get_credit_balance(organization_id: str)` | `CreditBalanceRead` | Get current credit balance |
293
301
 
294
302
  ## Data Models
295
303
 
@@ -433,3 +441,6 @@ for cat in cats:
433
441
 
434
442
  **Q: Why does auto mode fail on some QPUs?**
435
443
  **A:** `auto` only allows `PUBLIC` + `STANDARD`. Use explicit enums for private/instant access.
444
+
445
+ **Q: Can I hide the public plan citation notice?**
446
+ **A:** Setting `OPENQUANTUM_HIDE_CITATION_NOTICE=true` will omit the citation notice from output.
@@ -1,14 +1,3 @@
1
- Metadata-Version: 2.4
2
- Name: openquantum-sdk
3
- Version: 0.3.3
4
- Summary: Python SDK for Open Quantum
5
- Classifier: Programming Language :: Python :: 3
6
- Classifier: License :: OSI Approved :: Apache Software License
7
- Classifier: Operating System :: OS Independent
8
- Requires-Python: >=3.8
9
- Description-Content-Type: text/markdown
10
- Requires-Dist: requests>=2.25.0
11
-
12
1
  # Open Quantum Python SDK
13
2
 
14
3
  A lightweight, modern Python SDK for the **Open Quantum Platform**.
@@ -58,6 +47,13 @@ auth = ClientCredentialsAuth(
58
47
  )
59
48
  ```
60
49
 
50
+ ### Option 3: Environment Variables
51
+
52
+ ```bash
53
+ export OPENQUANTUM_CLIENT_ID=s_...
54
+ export OPENQUANTUM_CLIENT_SECRET=e460c8...
55
+ ```
56
+
61
57
  ## Quickstart: One-Call Submission (Recommended)
62
58
 
63
59
  ```python
@@ -290,6 +286,7 @@ finally:
290
286
  | `list_user_organizations(limit=20, cursor=...)` | `PaginatedOrganizations` | Your orgs |
291
287
  | `list_providers(limit=20, cursor=...)` | `PaginatedProviders` | All backend providers |
292
288
  | `list_backend_classes(provider_id=None, limit=20, cursor=...)` | `PaginatedBackendClasses` | Available backends |
289
+ | `get_credit_balance(organization_id: str)` | `CreditBalanceRead` | Get current credit balance |
293
290
 
294
291
  ## Data Models
295
292
 
@@ -433,3 +430,6 @@ for cat in cats:
433
430
 
434
431
  **Q: Why does auto mode fail on some QPUs?**
435
432
  **A:** `auto` only allows `PUBLIC` + `STANDARD`. Use explicit enums for private/instant access.
433
+
434
+ **Q: Can I hide the public plan citation notice?**
435
+ **A:** Setting `OPENQUANTUM_HIDE_CITATION_NOTICE=true` will omit the citation notice from output.
@@ -1,5 +1,5 @@
1
1
  from .clients import SchedulerClient, ManagementClient
2
2
  from .utils import poll_for_status
3
3
 
4
- __version__ = "0.3.3"
4
+ __version__ = "0.3.4"
5
5
  __all__ = ["SchedulerClient", "ManagementClient", "poll_for_status"]
@@ -2,6 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  from dataclasses import dataclass, asdict
4
4
  import sys
5
+ import os
5
6
  from typing import Optional, Dict, Any, List, Union, Tuple
6
7
  from urllib.parse import urljoin
7
8
  import requests
@@ -10,6 +11,7 @@ from .enums import AutoChoice, ExecutionPlanType, QueuePriorityType
10
11
  from .models import (
11
12
  APIError,
12
13
  BackendClassRead,
14
+ CreditBalanceRead,
13
15
  ErrorResponse,
14
16
  JobCategoryRead,
15
17
  JobCreate,
@@ -179,6 +181,10 @@ class ManagementClient(BaseClient):
179
181
  pagination = PaginationInfo.from_dict(data.get("pagination", {}))
180
182
  return PaginatedProviders(providers=providers, pagination=pagination)
181
183
 
184
+ def get_credit_balance(self, organization_id: str) -> CreditBalanceRead:
185
+ data = self._request("GET", f"/v1/organizations/{organization_id}/transactions/balance")
186
+ return CreditBalanceRead.from_dict(data)
187
+
182
188
 
183
189
  # ---------------------------------------------------------------------------
184
190
  # Scheduler Client
@@ -193,6 +199,7 @@ class SchedulerClient(BaseClient):
193
199
  ):
194
200
  super().__init__(base_url, token=token, auth=auth)
195
201
  self.management = management_client or ManagementClient(auth=self._auth)
202
+ self._public_plan_notice_shown = False
196
203
 
197
204
  def get_job_categories(
198
205
  self, limit: int = 20, cursor: Optional[str] = None
@@ -309,6 +316,19 @@ class SchedulerClient(BaseClient):
309
316
  )
310
317
 
311
318
  def create_job(self, job: JobCreate) -> JobRead:
319
+ hide_notice = os.getenv("OPENQUANTUM_HIDE_CITATION_NOTICE", "").lower() in ("1", "true", "yes")
320
+ if (
321
+ job.execution_plan_id == ExecutionPlanType.PUBLIC.value
322
+ and not self._public_plan_notice_shown
323
+ and not hide_notice
324
+ ):
325
+ print(
326
+ "\nNote: You have selected the Public Plan. Any publications or public work "
327
+ "resulting from this job must provide proper attribution to Open Quantum. "
328
+ "Citation guidelines can be found at www.openquantum.com/citation.\n"
329
+ )
330
+ self._public_plan_notice_shown = True
331
+
312
332
  data = self._request("POST", "/v1/jobs", json=asdict(job))
313
333
  return JobRead.from_dict(data)
314
334
 
@@ -103,6 +103,13 @@ class PaginatedBackendClasses:
103
103
  extra: Dict[str, Any] = field(default_factory=dict, repr=False)
104
104
 
105
105
 
106
+ @dataclass
107
+ class CreditBalanceRead(FlexibleDataclass):
108
+ spark_credits: float
109
+ full_credits: float
110
+ extra: Dict[str, Any] = field(default_factory=dict, repr=False)
111
+
112
+
106
113
  # ---------------------------------------------------------------------------
107
114
  # Scheduler API models
108
115
  # ---------------------------------------------------------------------------
@@ -1,3 +1,14 @@
1
+ Metadata-Version: 2.4
2
+ Name: openquantum-sdk
3
+ Version: 0.3.4
4
+ Summary: Python SDK for Open Quantum
5
+ Classifier: Programming Language :: Python :: 3
6
+ Classifier: License :: OSI Approved :: Apache Software License
7
+ Classifier: Operating System :: OS Independent
8
+ Requires-Python: >=3.8
9
+ Description-Content-Type: text/markdown
10
+ Requires-Dist: requests>=2.25.0
11
+
1
12
  # Open Quantum Python SDK
2
13
 
3
14
  A lightweight, modern Python SDK for the **Open Quantum Platform**.
@@ -47,6 +58,13 @@ auth = ClientCredentialsAuth(
47
58
  )
48
59
  ```
49
60
 
61
+ ### Option 3: Environment Variables
62
+
63
+ ```bash
64
+ export OPENQUANTUM_CLIENT_ID=s_...
65
+ export OPENQUANTUM_CLIENT_SECRET=e460c8...
66
+ ```
67
+
50
68
  ## Quickstart: One-Call Submission (Recommended)
51
69
 
52
70
  ```python
@@ -279,6 +297,7 @@ finally:
279
297
  | `list_user_organizations(limit=20, cursor=...)` | `PaginatedOrganizations` | Your orgs |
280
298
  | `list_providers(limit=20, cursor=...)` | `PaginatedProviders` | All backend providers |
281
299
  | `list_backend_classes(provider_id=None, limit=20, cursor=...)` | `PaginatedBackendClasses` | Available backends |
300
+ | `get_credit_balance(organization_id: str)` | `CreditBalanceRead` | Get current credit balance |
282
301
 
283
302
  ## Data Models
284
303
 
@@ -422,3 +441,6 @@ for cat in cats:
422
441
 
423
442
  **Q: Why does auto mode fail on some QPUs?**
424
443
  **A:** `auto` only allows `PUBLIC` + `STANDARD`. Use explicit enums for private/instant access.
444
+
445
+ **Q: Can I hide the public plan citation notice?**
446
+ **A:** Setting `OPENQUANTUM_HIDE_CITATION_NOTICE=true` will omit the citation notice from output.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "openquantum-sdk"
7
- version = "0.3.3"
7
+ version = "0.3.4"
8
8
  description = "Python SDK for Open Quantum"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -343,6 +343,16 @@ def test_list_user_organizations_pagination(mock_management):
343
343
  assert result.pagination.next_cursor == "cursor-xyz"
344
344
 
345
345
 
346
+ def test_get_credit_balance(mock_management):
347
+ mock_management.session.mocker.get(
348
+ "https://management.openquantum.com/v1/organizations/org-123/transactions/balance",
349
+ json={"spark_credits": 100.5, "full_credits": 50.0},
350
+ )
351
+ result = mock_management.get_credit_balance("org-123")
352
+ assert result.spark_credits == 100.5
353
+ assert result.full_credits == 50.0
354
+
355
+
346
356
  # ---------------------------------------------------------------------------
347
357
  # High-level submit_job tests (all pass unchanged)
348
358
  # ---------------------------------------------------------------------------
@@ -379,10 +389,10 @@ def test_download_job_output_success(mock_scheduler):
379
389
  job = mock_scheduler.get_job("job-123")
380
390
  mock_scheduler.session.mocker.get(
381
391
  "https://output.example.com/result-123",
382
- text='{"histogram": {"00": 512, "11": 512}}',
392
+ text='{"00": 512, "11": 512}',
383
393
  )
384
394
  output = mock_scheduler.download_job_output(job)
385
- assert output["histogram"]["00"] == 512
395
+ assert output["00"] == 512
386
396
 
387
397
 
388
398
  def test_download_job_output_no_url(mock_scheduler):