kotharcomputing 0.101.5__tar.gz → 0.103.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.
Files changed (35) hide show
  1. {kotharcomputing-0.101.5/src/kotharcomputing.egg-info → kotharcomputing-0.103.0}/PKG-INFO +1 -1
  2. {kotharcomputing-0.101.5 → kotharcomputing-0.103.0}/pyproject.toml +1 -1
  3. {kotharcomputing-0.101.5 → kotharcomputing-0.103.0}/src/kotharcomputing/__init__.py +17 -0
  4. kotharcomputing-0.103.0/src/kotharcomputing/content_types.py +53 -0
  5. {kotharcomputing-0.101.5 → kotharcomputing-0.103.0}/src/kotharcomputing/files.py +6 -0
  6. {kotharcomputing-0.101.5 → kotharcomputing-0.103.0/src/kotharcomputing.egg-info}/PKG-INFO +1 -1
  7. {kotharcomputing-0.101.5 → kotharcomputing-0.103.0}/src/kotharcomputing.egg-info/SOURCES.txt +1 -0
  8. {kotharcomputing-0.101.5 → kotharcomputing-0.103.0}/tests/test_fetch_url_building.py +4 -0
  9. {kotharcomputing-0.101.5 → kotharcomputing-0.103.0}/tests/test_public_api.py +40 -0
  10. {kotharcomputing-0.101.5 → kotharcomputing-0.103.0}/LICENSE +0 -0
  11. {kotharcomputing-0.101.5 → kotharcomputing-0.103.0}/README.md +0 -0
  12. {kotharcomputing-0.101.5 → kotharcomputing-0.103.0}/setup.cfg +0 -0
  13. {kotharcomputing-0.101.5 → kotharcomputing-0.103.0}/src/kotharcomputing/agents.py +0 -0
  14. {kotharcomputing-0.101.5 → kotharcomputing-0.103.0}/src/kotharcomputing/ai.py +0 -0
  15. {kotharcomputing-0.101.5 → kotharcomputing-0.103.0}/src/kotharcomputing/aleph_language_server.py +0 -0
  16. {kotharcomputing-0.101.5 → kotharcomputing-0.103.0}/src/kotharcomputing/api_tokens.py +0 -0
  17. {kotharcomputing-0.101.5 → kotharcomputing-0.103.0}/src/kotharcomputing/client.py +0 -0
  18. {kotharcomputing-0.101.5 → kotharcomputing-0.103.0}/src/kotharcomputing/common.py +0 -0
  19. {kotharcomputing-0.101.5 → kotharcomputing-0.103.0}/src/kotharcomputing/credits.py +0 -0
  20. {kotharcomputing-0.101.5 → kotharcomputing-0.103.0}/src/kotharcomputing/errors.py +0 -0
  21. {kotharcomputing-0.101.5 → kotharcomputing-0.103.0}/src/kotharcomputing/executions.py +0 -0
  22. {kotharcomputing-0.101.5 → kotharcomputing-0.103.0}/src/kotharcomputing/fetch.py +0 -0
  23. {kotharcomputing-0.101.5 → kotharcomputing-0.103.0}/src/kotharcomputing/jobs.py +0 -0
  24. {kotharcomputing-0.101.5 → kotharcomputing-0.103.0}/src/kotharcomputing/py.typed +0 -0
  25. {kotharcomputing-0.101.5 → kotharcomputing-0.103.0}/src/kotharcomputing/runtimes.py +0 -0
  26. {kotharcomputing-0.101.5 → kotharcomputing-0.103.0}/src/kotharcomputing/service_prices.py +0 -0
  27. {kotharcomputing-0.101.5 → kotharcomputing-0.103.0}/src/kotharcomputing/subscribe_user.py +0 -0
  28. {kotharcomputing-0.101.5 → kotharcomputing-0.103.0}/src/kotharcomputing/subscribe_workspace.py +0 -0
  29. {kotharcomputing-0.101.5 → kotharcomputing-0.103.0}/src/kotharcomputing/subscriptions.py +0 -0
  30. {kotharcomputing-0.101.5 → kotharcomputing-0.103.0}/src/kotharcomputing/users.py +0 -0
  31. {kotharcomputing-0.101.5 → kotharcomputing-0.103.0}/src/kotharcomputing/workspaces.py +0 -0
  32. {kotharcomputing-0.101.5 → kotharcomputing-0.103.0}/src/kotharcomputing.egg-info/dependency_links.txt +0 -0
  33. {kotharcomputing-0.101.5 → kotharcomputing-0.103.0}/src/kotharcomputing.egg-info/requires.txt +0 -0
  34. {kotharcomputing-0.101.5 → kotharcomputing-0.103.0}/src/kotharcomputing.egg-info/top_level.txt +0 -0
  35. {kotharcomputing-0.101.5 → kotharcomputing-0.103.0}/tests/test_fetch_auth_headers.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kotharcomputing
3
- Version: 0.101.5
3
+ Version: 0.103.0
4
4
  Summary: Python SDK for the Kothar API
5
5
  Author: Kothar Computing
6
6
  License-Expression: Apache-2.0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "kotharcomputing"
7
- version = "0.101.5"
7
+ version = "0.103.0"
8
8
  description = "Python SDK for the Kothar API"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -71,6 +71,15 @@ from .client import (
71
71
  KotharClientOptions,
72
72
  RawResponse,
73
73
  )
74
+ from .content_types import (
75
+ DEFAULT_CONTENT_TYPE,
76
+ GENERIC_CONTENT_TYPES,
77
+ KOTHAR_CONTENT_TYPES,
78
+ LEGACY_ALEPH_CONTENT_TYPE,
79
+ content_type_for_path,
80
+ content_type_for_path_or_default,
81
+ is_generic_content_type,
82
+ )
74
83
  from .credits import (
75
84
  CreditBalance,
76
85
  CreditTransaction,
@@ -213,6 +222,14 @@ __all__ = [
213
222
  "KotharClient",
214
223
  "KotharClientOptions",
215
224
  "RawResponse",
225
+ # Content Types
226
+ "DEFAULT_CONTENT_TYPE",
227
+ "GENERIC_CONTENT_TYPES",
228
+ "KOTHAR_CONTENT_TYPES",
229
+ "LEGACY_ALEPH_CONTENT_TYPE",
230
+ "content_type_for_path",
231
+ "content_type_for_path_or_default",
232
+ "is_generic_content_type",
216
233
  # Credits
217
234
  "CreditBalance",
218
235
  "CreditTransaction",
@@ -0,0 +1,53 @@
1
+ DEFAULT_CONTENT_TYPE = "application/octet-stream"
2
+ LEGACY_ALEPH_CONTENT_TYPE = "application/x-aleph"
3
+
4
+ KOTHAR_CONTENT_TYPES = {
5
+ "aleph": "application/vnd.kothar.aleph",
6
+ "figure": "application/vnd.kothar.figure+json",
7
+ "lattice_model": "application/vnd.kothar.lattice-model+json",
8
+ }
9
+
10
+ GENERIC_CONTENT_TYPES = (
11
+ DEFAULT_CONTENT_TYPE,
12
+ "application/json",
13
+ "text/plain",
14
+ )
15
+
16
+ _CONTENT_TYPES_BY_EXTENSION = {
17
+ ".aleph": KOTHAR_CONTENT_TYPES["aleph"],
18
+ ".figure": KOTHAR_CONTENT_TYPES["figure"],
19
+ ".lattice_model": KOTHAR_CONTENT_TYPES["lattice_model"],
20
+ ".qasm": "application/qasm",
21
+ }
22
+ _GENERIC_CONTENT_TYPE_SET = set(GENERIC_CONTENT_TYPES)
23
+
24
+
25
+ def content_type_for_path(path: str) -> str | None:
26
+ filename = path.replace("\\", "/").rsplit("/", 1)[-1]
27
+ extension_index = filename.rfind(".")
28
+ if extension_index <= 0 or extension_index == len(filename) - 1:
29
+ return None
30
+
31
+ return _CONTENT_TYPES_BY_EXTENSION.get(filename[extension_index:].lower())
32
+
33
+
34
+ def is_generic_content_type(content_type: str) -> bool:
35
+ normalized = content_type.split(";", 1)[0].strip().lower()
36
+ return normalized in _GENERIC_CONTENT_TYPE_SET
37
+
38
+
39
+ def content_type_for_path_or_default(path: str, fallback: str | None = None) -> str:
40
+ path_content_type = content_type_for_path(path)
41
+ if path_content_type is None:
42
+ return fallback or DEFAULT_CONTENT_TYPE
43
+ if not fallback:
44
+ return path_content_type
45
+
46
+ fallback_type = fallback.split(";", 1)[0].strip().lower()
47
+ if (
48
+ fallback_type == LEGACY_ALEPH_CONTENT_TYPE
49
+ or fallback_type in _GENERIC_CONTENT_TYPE_SET
50
+ ):
51
+ return path_content_type
52
+
53
+ return fallback
@@ -53,6 +53,8 @@ class FileContent:
53
53
  etag: str | None = None
54
54
  version_id: str | None = None
55
55
  mime_type: str | None = None
56
+ user_id: str | None = None
57
+ username: str | None = None
56
58
 
57
59
  def text(self, encoding: str = "utf-8") -> str:
58
60
  return self.data.decode(encoding)
@@ -88,6 +90,8 @@ class FileByPathClient:
88
90
  etag=response.headers.get("etag"),
89
91
  version_id=response.headers.get("x-kothar-file-version-id"),
90
92
  mime_type=response.headers.get("content-type"),
93
+ user_id=response.headers.get("x-kothar-file-user-id"),
94
+ username=response.headers.get("x-kothar-file-username"),
91
95
  )
92
96
 
93
97
  def create(
@@ -206,6 +210,8 @@ class FileByPathVersionClient:
206
210
  etag=response.headers.get("etag"),
207
211
  version_id=response.headers.get("x-kothar-file-version-id"),
208
212
  mime_type=response.headers.get("content-type"),
213
+ user_id=response.headers.get("x-kothar-file-user-id"),
214
+ username=response.headers.get("x-kothar-file-username"),
209
215
  )
210
216
 
211
217
  def download_url(self) -> str:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kotharcomputing
3
- Version: 0.101.5
3
+ Version: 0.103.0
4
4
  Summary: Python SDK for the Kothar API
5
5
  Author: Kothar Computing
6
6
  License-Expression: Apache-2.0
@@ -8,6 +8,7 @@ src/kotharcomputing/aleph_language_server.py
8
8
  src/kotharcomputing/api_tokens.py
9
9
  src/kotharcomputing/client.py
10
10
  src/kotharcomputing/common.py
11
+ src/kotharcomputing/content_types.py
11
12
  src/kotharcomputing/credits.py
12
13
  src/kotharcomputing/errors.py
13
14
  src/kotharcomputing/executions.py
@@ -131,6 +131,8 @@ def test_files_client_exposes_resolved_version_id_from_get_header() -> None:
131
131
  headers={
132
132
  "content-disposition": "inline; filename=file.txt",
133
133
  "x-kothar-file-version-id": "version-1",
134
+ "x-kothar-file-user-id": "user-1",
135
+ "x-kothar-file-username": "Ada Lovelace",
134
136
  },
135
137
  body=b"content",
136
138
  )
@@ -141,6 +143,8 @@ def test_files_client_exposes_resolved_version_id_from_get_header() -> None:
141
143
 
142
144
  assert file is not None
143
145
  assert file.version_id == "version-1"
146
+ assert file.user_id == "user-1"
147
+ assert file.username == "Ada Lovelace"
144
148
 
145
149
 
146
150
  def test_files_client_restores_versions_from_base_path_client() -> None:
@@ -82,6 +82,14 @@ def test_package_import_and_public_exports() -> None:
82
82
  "KotharClient",
83
83
  "KotharClientOptions",
84
84
  "RawResponse",
85
+ # Content Types
86
+ "DEFAULT_CONTENT_TYPE",
87
+ "GENERIC_CONTENT_TYPES",
88
+ "KOTHAR_CONTENT_TYPES",
89
+ "LEGACY_ALEPH_CONTENT_TYPE",
90
+ "content_type_for_path",
91
+ "content_type_for_path_or_default",
92
+ "is_generic_content_type",
85
93
  # Credits
86
94
  "CreditBalance",
87
95
  "CreditTransaction",
@@ -161,3 +169,35 @@ def test_kothar_client_uses_default_base_url() -> None:
161
169
  client = module.KotharClient()
162
170
 
163
171
  assert client._transport.base_url == "https://api.kotharcomputing.com/"
172
+
173
+
174
+ def test_content_type_helpers_are_exported() -> None:
175
+ module = importlib.import_module("kotharcomputing")
176
+
177
+ assert module.KOTHAR_CONTENT_TYPES["aleph"] == "application/vnd.kothar.aleph"
178
+ assert (
179
+ module.content_type_for_path("src/main.aleph")
180
+ == module.KOTHAR_CONTENT_TYPES["aleph"]
181
+ )
182
+ assert (
183
+ module.content_type_for_path("plot.figure")
184
+ == module.KOTHAR_CONTENT_TYPES["figure"]
185
+ )
186
+ assert (
187
+ module.content_type_for_path("models/hubbard.lattice_model")
188
+ == module.KOTHAR_CONTENT_TYPES["lattice_model"]
189
+ )
190
+ assert module.content_type_for_path("circuits/bell.qasm") == "application/qasm"
191
+ assert module.content_type_for_path("notes.txt") is None
192
+ assert (
193
+ module.content_type_for_path_or_default("src/main.aleph", "application/x-aleph")
194
+ == module.KOTHAR_CONTENT_TYPES["aleph"]
195
+ )
196
+ assert (
197
+ module.content_type_for_path_or_default(
198
+ "plot.figure", "application/vnd.example.figure"
199
+ )
200
+ == "application/vnd.example.figure"
201
+ )
202
+ assert module.is_generic_content_type("text/plain; charset=UTF-8")
203
+ assert not module.is_generic_content_type("application/vnd.example.asset")