pycarta 0.3.9__tar.gz → 0.3.11.dev2__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 (141) hide show
  1. {pycarta-0.3.9/src/pycarta.egg-info → pycarta-0.3.11.dev2}/PKG-INFO +57 -28
  2. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/docs/conf.py +9 -1
  3. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/docs/quickstart.rst +113 -1
  4. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/setup.cfg +53 -23
  5. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/__init__.py +97 -37
  6. pycarta-0.3.11.dev2/src/pycarta/_compat.py +30 -0
  7. pycarta-0.3.11.dev2/src/pycarta/admin/file.py +183 -0
  8. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/admin/group.py +28 -6
  9. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/admin/permission.py +35 -2
  10. pycarta-0.3.11.dev2/src/pycarta/admin/secret.py +39 -0
  11. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/admin/service.py +45 -12
  12. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/admin/types/file.py +1 -1
  13. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/admin/types/user.py +8 -9
  14. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/admin/user.py +52 -8
  15. pycarta-0.3.11.dev2/src/pycarta/admin/v2/__init__.py +122 -0
  16. pycarta-0.3.11.dev2/src/pycarta/admin/v2/_helpers.py +28 -0
  17. pycarta-0.3.11.dev2/src/pycarta/admin/v2/advanced.py +314 -0
  18. pycarta-0.3.11.dev2/src/pycarta/admin/v2/aio/__init__.py +68 -0
  19. pycarta-0.3.11.dev2/src/pycarta/admin/v2/aio/apitoken.py +64 -0
  20. pycarta-0.3.11.dev2/src/pycarta/admin/v2/aio/auth.py +23 -0
  21. pycarta-0.3.11.dev2/src/pycarta/admin/v2/aio/permission.py +103 -0
  22. pycarta-0.3.11.dev2/src/pycarta/admin/v2/aio/resource.py +63 -0
  23. pycarta-0.3.11.dev2/src/pycarta/admin/v2/apitoken.py +209 -0
  24. pycarta-0.3.11.dev2/src/pycarta/admin/v2/auth.py +95 -0
  25. pycarta-0.3.11.dev2/src/pycarta/admin/v2/compat.py +164 -0
  26. pycarta-0.3.11.dev2/src/pycarta/admin/v2/exceptions.py +13 -0
  27. pycarta-0.3.11.dev2/src/pycarta/admin/v2/permission.py +355 -0
  28. pycarta-0.3.11.dev2/src/pycarta/admin/v2/resource.py +227 -0
  29. pycarta-0.3.11.dev2/src/pycarta/admin/v2/types.py +173 -0
  30. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/admin/workspace.py +50 -0
  31. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/auth/agent.py +86 -17
  32. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/auth/weblogin.py +14 -11
  33. pycarta-0.3.11.dev2/src/pycarta/exceptions.py +79 -0
  34. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/formsdb/__init__.py +9 -4
  35. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/graph/__init__.py +3 -0
  36. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/mqtt/__init__.py +3 -0
  37. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/sbg/__init__.py +3 -0
  38. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/services/__init__.py +3 -0
  39. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/services/server.py +246 -53
  40. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/tablify/__init__.py +3 -0
  41. {pycarta-0.3.9 → pycarta-0.3.11.dev2/src/pycarta.egg-info}/PKG-INFO +57 -28
  42. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta.egg-info/SOURCES.txt +16 -0
  43. pycarta-0.3.11.dev2/src/pycarta.egg-info/requires.txt +73 -0
  44. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/tox.ini +1 -1
  45. pycarta-0.3.9/src/pycarta/admin/file.py +0 -81
  46. pycarta-0.3.9/src/pycarta/admin/secret.py +0 -24
  47. pycarta-0.3.9/src/pycarta/exceptions.py +0 -39
  48. pycarta-0.3.9/src/pycarta.egg-info/requires.txt +0 -36
  49. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/.gitignore +0 -0
  50. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/.gitlab-ci.yml +0 -0
  51. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/.readthedocs.yml +0 -0
  52. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/AUTHORS.rst +0 -0
  53. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/CHANGELOG.rst +0 -0
  54. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/CONTRIBUTING.rst +0 -0
  55. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/LICENSE.txt +0 -0
  56. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/MANIFEST.in +0 -0
  57. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/README.md +0 -0
  58. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/README.rst +0 -0
  59. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/docs/Makefile +0 -0
  60. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/docs/_static/.gitignore +0 -0
  61. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/docs/authors.rst +0 -0
  62. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/docs/changelog.rst +0 -0
  63. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/docs/contributing.rst +0 -0
  64. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/docs/data-management.rst +0 -0
  65. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/docs/examples/00_index.ipynb +0 -0
  66. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/docs/examples/01_authentication.ipynb +0 -0
  67. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/docs/examples/02_admin.ipynb +0 -0
  68. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/docs/examples/03_services.ipynb +0 -0
  69. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/docs/examples/04_mqtt.ipynb +0 -0
  70. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/docs/examples/05_data_management.ipynb +0 -0
  71. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/docs/examples/06_seven_bridges.ipynb +0 -0
  72. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/docs/examples/README.md +0 -0
  73. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/docs/index.rst +0 -0
  74. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/docs/installation.rst +0 -0
  75. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/docs/license.rst +0 -0
  76. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/docs/mqtt.rst +0 -0
  77. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/docs/requirements.txt +0 -0
  78. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/docs/services.rst +0 -0
  79. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/pyproject.toml +0 -0
  80. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/setup.py +0 -0
  81. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/admin/__init__.py +0 -0
  82. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/admin/project.py +0 -0
  83. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/admin/types/__init__.py +0 -0
  84. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/admin/types/connection.py +0 -0
  85. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/admin/types/document_history.py +0 -0
  86. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/admin/types/group.py +0 -0
  87. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/admin/types/item.py +0 -0
  88. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/admin/types/namespace.py +0 -0
  89. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/admin/types/permission_entity.py +0 -0
  90. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/admin/types/permissions.py +0 -0
  91. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/admin/types/project.py +0 -0
  92. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/admin/types/resource_type.py +0 -0
  93. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/admin/types/service.py +0 -0
  94. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/admin/types/util.py +0 -0
  95. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/admin/types/workspace.py +0 -0
  96. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/auth/__init__.py +0 -0
  97. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/auth/config.py +0 -0
  98. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/auth/dialogs/carta_login.py +0 -0
  99. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/auth/profile.py +0 -0
  100. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/auth/ui.py +0 -0
  101. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/formsdb/concurrent.py +0 -0
  102. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/formsdb/types.py +0 -0
  103. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/fs/__init__.py +0 -0
  104. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/fs/configuration.py +0 -0
  105. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/fs/file.py +0 -0
  106. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/fs/multipart_upload.py +0 -0
  107. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/fs/types/__init__.py +0 -0
  108. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/fs/types/configuration.py +0 -0
  109. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/fs/types/exception.py +0 -0
  110. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/fs/types/file.py +0 -0
  111. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/graph/algorithms.py +0 -0
  112. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/graph/graph.py +0 -0
  113. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/graph/iterator.py +0 -0
  114. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/graph/util.py +0 -0
  115. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/graph/vertex/__init__.py +0 -0
  116. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/graph/vertex/types.py +0 -0
  117. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/graph/vertex/util.py +0 -0
  118. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/graph/visitor/__init__.py +0 -0
  119. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/graph/visitor/base.py +0 -0
  120. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/mqtt/client.py +0 -0
  121. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/mqtt/connection.py +0 -0
  122. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/mqtt/credentials.py +0 -0
  123. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/mqtt/exceptions.py +0 -0
  124. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/mqtt/formatter.py +0 -0
  125. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/mqtt/publisher.py +0 -0
  126. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/mqtt/subscriber.py +0 -0
  127. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/sbg/base.py +0 -0
  128. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/sbg/login.py +0 -0
  129. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/sbg/project.py +0 -0
  130. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/services/proxy.py +0 -0
  131. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/tablify/__main__.py +0 -0
  132. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/tablify/core.py +0 -0
  133. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/tablify/io.py +0 -0
  134. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/tablify/melt.py +0 -0
  135. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/tablify/tablify.py +0 -0
  136. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/tablify/types.py +0 -0
  137. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta/tablify/utils.py +0 -0
  138. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta.egg-info/dependency_links.txt +0 -0
  139. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta.egg-info/not-zip-safe +0 -0
  140. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/src/pycarta.egg-info/top_level.txt +0 -0
  141. {pycarta-0.3.9 → pycarta-0.3.11.dev2}/static/brand.png +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pycarta
3
- Version: 0.3.9
3
+ Version: 0.3.11.dev2
4
4
  Summary: Python interface to Carta.
5
5
  Author: Branden Kappes
6
6
  Author-email: branden.kappes@contextualize.us.com
@@ -11,40 +11,69 @@ Classifier: Programming Language :: Python
11
11
  Requires-Python: >=3.12
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE.txt
14
- Requires-Dist: importlib-metadata
15
- Requires-Dist: aiomqtt
16
14
  Requires-Dist: authlib
17
15
  Requires-Dist: boto3
18
- Requires-Dist: fastapi[standard]
19
- Requires-Dist: httpx>=0.27
20
- Requires-Dist: inflection
21
- Requires-Dist: itsdangerous
22
- Requires-Dist: networkx
23
- Requires-Dist: numpy
24
- Requires-Dist: paho-mqtt
25
- Requires-Dist: pandas
26
16
  Requires-Dist: pycognito
27
17
  Requires-Dist: pydantic
28
18
  Requires-Dist: python-dotenv
29
- Requires-Dist: sevenbridges-python
30
- Requires-Dist: starlette
31
- Requires-Dist: tqdm
32
- Requires-Dist: uvicorn
33
- Requires-Dist: websockets
19
+ Requires-Dist: requests
20
+ Provides-Extra: slim
21
+ Requires-Dist: authlib; extra == "slim"
22
+ Requires-Dist: boto3; extra == "slim"
23
+ Requires-Dist: pycognito; extra == "slim"
24
+ Requires-Dist: pydantic; extra == "slim"
25
+ Requires-Dist: python-dotenv; extra == "slim"
26
+ Requires-Dist: requests; extra == "slim"
27
+ Provides-Extra: carta
28
+ Requires-Dist: pycarta[slim]; extra == "carta"
29
+ Requires-Dist: fastapi[standard]; extra == "carta"
30
+ Requires-Dist: httpx>=0.27; extra == "carta"
31
+ Requires-Dist: inflection; extra == "carta"
32
+ Requires-Dist: itsdangerous; extra == "carta"
33
+ Provides-Extra: mqtt
34
+ Requires-Dist: pycarta[slim]; extra == "mqtt"
35
+ Requires-Dist: aiomqtt; extra == "mqtt"
36
+ Requires-Dist: cryptography; extra == "mqtt"
37
+ Requires-Dist: paho-mqtt; extra == "mqtt"
38
+ Provides-Extra: sbg
39
+ Requires-Dist: pycarta[slim]; extra == "sbg"
40
+ Requires-Dist: inflection; extra == "sbg"
41
+ Requires-Dist: python-dotenv; extra == "sbg"
42
+ Requires-Dist: sevenbridges-python; extra == "sbg"
43
+ Requires-Dist: tqdm; extra == "sbg"
44
+ Provides-Extra: graph
45
+ Requires-Dist: pycarta[slim]; extra == "graph"
46
+ Requires-Dist: networkx; extra == "graph"
47
+ Requires-Dist: numpy; extra == "graph"
48
+ Requires-Dist: pandas; extra == "graph"
49
+ Provides-Extra: tablify
50
+ Requires-Dist: pycarta[slim]; extra == "tablify"
51
+ Requires-Dist: numpy; extra == "tablify"
52
+ Requires-Dist: pandas; extra == "tablify"
53
+ Requires-Dist: tqdm; extra == "tablify"
54
+ Provides-Extra: all
55
+ Requires-Dist: pycarta[carta]; extra == "all"
56
+ Requires-Dist: pycarta[mqtt]; extra == "all"
57
+ Requires-Dist: pycarta[sbg]; extra == "all"
58
+ Requires-Dist: pycarta[graph]; extra == "all"
59
+ Requires-Dist: pycarta[tablify]; extra == "all"
60
+ Provides-Extra: dev
61
+ Requires-Dist: pycarta[all]; extra == "dev"
62
+ Requires-Dist: flask; extra == "dev"
63
+ Requires-Dist: ipython; extra == "dev"
64
+ Requires-Dist: jupyter; extra == "dev"
65
+ Requires-Dist: jupyterlab; extra == "dev"
66
+ Requires-Dist: petname; extra == "dev"
67
+ Requires-Dist: pydot; extra == "dev"
68
+ Requires-Dist: pytest; extra == "dev"
69
+ Requires-Dist: pytest-asyncio; extra == "dev"
70
+ Requires-Dist: pytest-cov; extra == "dev"
71
+ Requires-Dist: pytest-dependency; extra == "dev"
72
+ Requires-Dist: setuptools; extra == "dev"
34
73
  Provides-Extra: develop
35
- Requires-Dist: ipython; extra == "develop"
36
- Requires-Dist: jupyter; extra == "develop"
37
- Requires-Dist: jupyterlab; extra == "develop"
38
- Requires-Dist: pydot; extra == "develop"
74
+ Requires-Dist: pycarta[dev]; extra == "develop"
39
75
  Provides-Extra: testing
40
- Requires-Dist: fastapi; extra == "testing"
41
- Requires-Dist: flask; extra == "testing"
42
- Requires-Dist: petname; extra == "testing"
43
- Requires-Dist: pytest; extra == "testing"
44
- Requires-Dist: pytest-cov; extra == "testing"
45
- Requires-Dist: setuptools; extra == "testing"
46
- Requires-Dist: pytest-asyncio; extra == "testing"
47
- Requires-Dist: pytest-dependency; extra == "testing"
76
+ Requires-Dist: pycarta[dev]; extra == "testing"
48
77
  Dynamic: license-file
49
78
 
50
79
  # pycarta - Python Interface to Carta Platform
@@ -240,7 +240,15 @@ latex_elements = {
240
240
  # The font size ("10pt", "11pt" or "12pt").
241
241
  # "pointsize": "10pt",
242
242
  # Additional stuff for the LaTeX preamble.
243
- # "preamble": "",
243
+ "preamble": r'''
244
+ \DeclareUnicodeCharacter{1F310}{(globe)}
245
+ \DeclareUnicodeCharacter{1F4E1}{(satellite)}
246
+ \DeclareUnicodeCharacter{1F510}{(lock)}
247
+ \DeclareUnicodeCharacter{1F5C3}{(file cabinet)}
248
+ \DeclareUnicodeCharacter{1F6E0}{(tools)}
249
+ \DeclareUnicodeCharacter{1F9EC}{(DNA)}
250
+ \DeclareUnicodeCharacter{FE0F}{}
251
+ ''',
244
252
  }
245
253
 
246
254
  # Grouping the document tree into LaTeX files. List of tuples
@@ -126,6 +126,37 @@ Profiles may also be managed interactively using the Carta profile UI,
126
126
  CartaProfileUI() # A GUI for viewing, adding, or modifying profiles.
127
127
 
128
128
 
129
+ API Token Authentication
130
+ ^^^^^^^^^^^^^^^^^^^^^^^^
131
+
132
+ API tokens provide a secure, revocable alternative to username/password
133
+ authentication. They are well-suited for automated scripts, CI/CD pipelines,
134
+ and service-to-service communication.
135
+
136
+ Create an API token (see :ref:`api_tokens`), then use it to authenticate:
137
+
138
+ .. code:: python
139
+
140
+ import pycarta as pc
141
+
142
+ # Explicit token login
143
+ pc.login(api_token="your_api_token_here")
144
+
145
+ # Or set the environment variable and call login() as usual:
146
+ # export CARTA_API_TOKEN=your_api_token_here
147
+ pc.login()
148
+
149
+ # Or construct an agent directly
150
+ from pycarta.auth import CartaAgent
151
+ agent = CartaAgent(api_token="your_api_token_here")
152
+
153
+ .. note::
154
+
155
+ API tokens take the highest precedence in the authentication chain. When
156
+ ``api_token`` is supplied (directly or via ``CARTA_API_TOKEN``), profiles
157
+ and username/password credentials are ignored.
158
+
159
+
129
160
  Automatic Authentication
130
161
  ^^^^^^^^^^^^^^^^^^^^^^^^
131
162
 
@@ -133,9 +164,11 @@ Any action that requires login will attempt to login using information from the
133
164
  environment. To enable automatic login, set the following environment variables::
134
165
 
135
166
  CARTA_USER=<Carta username>
136
-
167
+
137
168
  CARTA_PASS=<Carta password>
138
169
 
170
+ CARTA_API_TOKEN=<Carta API token> # takes precedence over username/password
171
+
139
172
  CARTA_PROFILE=<Carta profile>
140
173
 
141
174
  CARTA_ENV=<Carta environment> # optional
@@ -270,6 +303,85 @@ that group.
270
303
  members = list_group_members(group)
271
304
 
272
305
 
306
+ .. _api_tokens:
307
+
308
+ API Tokens
309
+ ^^^^^^^^^^
310
+
311
+ API tokens grant programmatic access to the Carta API without requiring
312
+ username/password credentials. Each token is scoped to a set of allowed
313
+ endpoints and can be given an expiry time or a maximum use count.
314
+
315
+ .. code:: python
316
+
317
+ import datetime
318
+ from pycarta.admin.v2 import (
319
+ SELF,
320
+ TokenEndpoint,
321
+ create_token,
322
+ list_tokens,
323
+ revoke_token,
324
+ delete_token,
325
+ )
326
+
327
+ # Create a token for the current user scoped to specific endpoints
328
+ token = create_token(
329
+ SELF,
330
+ name="my-automation-token",
331
+ allowed_endpoints=[
332
+ TokenEndpoint("GET", "/v2/auth/apitoken/**"),
333
+ TokenEndpoint(["POST", "DELETE"], "/v2/some/resource/**"),
334
+ ],
335
+ )
336
+ print(token.token_key) # Save this — the full key is only returned on creation
337
+
338
+ # Create a time-limited, single-use token
339
+ token = create_token(
340
+ SELF,
341
+ name="short-lived-token",
342
+ allowed_endpoints=[TokenEndpoint("ANY", "/**")],
343
+ expires=datetime.datetime(2026, 12, 31, tzinfo=datetime.timezone.utc),
344
+ uses=1,
345
+ )
346
+
347
+ # List tokens — keys are obfuscated in list responses
348
+ for t in list_tokens(SELF):
349
+ status = "revoked" if t.revoked else "active"
350
+ print(f"{t.name} ({status}): {t.token_key}")
351
+
352
+ # Revoke a token (marks it as inactive; the record remains)
353
+ revoke_token(SELF, "my-automation-token")
354
+
355
+ # Delete a token permanently
356
+ delete_token(SELF, "my-automation-token")
357
+
358
+ ``SELF`` is a sentinel that refers to the currently authenticated user's node.
359
+ To manage tokens on behalf of another node, pass a ``ResourceNode`` or its UUID
360
+ string instead.
361
+
362
+ ``TokenEndpoint`` validates the method/path format at construction time and
363
+ serializes to the ``METHOD /path`` pattern the API expects. Methods are
364
+ normalized to uppercase; multiple methods can be specified as a list or a
365
+ pipe-delimited string (``"POST|PUT"``).
366
+
367
+ An async API is also available:
368
+
369
+ .. code:: python
370
+
371
+ from pycarta.admin.v2.aio import apitoken as aio_tokens
372
+ import asyncio
373
+
374
+ async def main():
375
+ token = await aio_tokens.create_token(
376
+ SELF,
377
+ name="async-token",
378
+ allowed_endpoints=[TokenEndpoint("GET", "/v2/**")],
379
+ )
380
+ await aio_tokens.delete_token(SELF, "async-token")
381
+
382
+ asyncio.run(main())
383
+
384
+
273
385
  Secrets
274
386
  ^^^^^^^
275
387
 
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = pycarta
3
- version = 0.3.9
3
+ version = 0.3.11dev2
4
4
  description = Python interface to Carta.
5
5
  author = Branden Kappes
6
6
  author_email = branden.kappes@contextualize.us.com
@@ -21,26 +21,12 @@ package_dir =
21
21
  =src
22
22
  python_requires = >=3.12
23
23
  install_requires =
24
- importlib-metadata
25
- aiomqtt
26
24
  authlib
27
25
  boto3
28
- fastapi[standard]
29
- httpx>=0.27
30
- inflection
31
- itsdangerous
32
- networkx
33
- numpy
34
- paho-mqtt
35
- pandas
36
26
  pycognito
37
27
  pydantic
38
28
  python-dotenv
39
- sevenbridges-python
40
- starlette
41
- tqdm
42
- uvicorn
43
- websockets
29
+ requests
44
30
 
45
31
  [options.packages.find]
46
32
  where = src
@@ -48,20 +34,63 @@ exclude =
48
34
  tests
49
35
 
50
36
  [options.extras_require]
51
- develop =
37
+ slim =
38
+ authlib
39
+ boto3
40
+ pycognito
41
+ pydantic
42
+ python-dotenv
43
+ requests
44
+ carta =
45
+ pycarta[slim]
46
+ fastapi[standard]
47
+ httpx>=0.27
48
+ inflection
49
+ itsdangerous
50
+ mqtt =
51
+ pycarta[slim]
52
+ aiomqtt
53
+ cryptography
54
+ paho-mqtt
55
+ sbg =
56
+ pycarta[slim]
57
+ inflection
58
+ python-dotenv
59
+ sevenbridges-python
60
+ tqdm
61
+ graph =
62
+ pycarta[slim]
63
+ networkx
64
+ numpy
65
+ pandas
66
+ tablify =
67
+ pycarta[slim]
68
+ numpy
69
+ pandas
70
+ tqdm
71
+ all =
72
+ pycarta[carta]
73
+ pycarta[mqtt]
74
+ pycarta[sbg]
75
+ pycarta[graph]
76
+ pycarta[tablify]
77
+ dev =
78
+ pycarta[all]
79
+ flask
52
80
  ipython
53
81
  jupyter
54
82
  jupyterlab
55
- pydot
56
- testing =
57
- fastapi
58
- flask
59
83
  petname
84
+ pydot
60
85
  pytest
61
- pytest-cov
62
- setuptools
63
86
  pytest-asyncio
87
+ pytest-cov
64
88
  pytest-dependency
89
+ setuptools
90
+ develop =
91
+ pycarta[dev]
92
+ testing =
93
+ pycarta[dev]
65
94
 
66
95
  [options.entry_points]
67
96
 
@@ -78,6 +107,7 @@ markers =
78
107
  unit: mark test as unit test (runs by default, no external services)
79
108
  integration: mark test as integration test (requires external services)
80
109
  smoke_test: mark test as smoke/integration test (skipped unless --smoke-test)
110
+ extras_isolation: mark test as extras isolation test (creates clean venvs, slow)
81
111
  strict_markers = true
82
112
 
83
113
  [devpi:upload]
@@ -1,13 +1,6 @@
1
- import sys
2
-
3
- if sys.version_info[:2] >= (3, 8):
4
- # TODO: Import directly (no need for conditional) when `python_requires = >= 3.8`
5
- from importlib.metadata import PackageNotFoundError, version # pragma: no cover
6
- else:
7
- from importlib_metadata import PackageNotFoundError, version # pragma: no cover
1
+ from importlib.metadata import PackageNotFoundError, version
8
2
 
9
3
  try:
10
- # Change here if project is renamed and does not equal the package name
11
4
  dist_name = __name__
12
5
  __version__ = version(dist_name)
13
6
  except PackageNotFoundError: # pragma: no cover
@@ -17,21 +10,34 @@ finally:
17
10
 
18
11
 
19
12
  # ##### Import Submodules ##### #
20
- from .services import service
13
+ # Core modules (always available with [slim])
21
14
  from . import (
22
15
  admin,
23
16
  auth,
24
- formsdb,
25
17
  fs,
26
- graph,
27
- mqtt,
28
- sbg,
29
- tablify,
30
18
  )
31
19
 
20
+ # Optional modules — imported if deps are available, silently skipped otherwise.
21
+ # Users get a clear ImportError with install hint when they explicitly
22
+ # import an optional module (e.g., `from pycarta import mqtt`).
23
+ import importlib as _importlib
24
+ _optional_modules = ["formsdb", "graph", "mqtt", "sbg", "services", "tablify"]
25
+ for _mod_name in _optional_modules:
26
+ try:
27
+ _importlib.import_module(f".{_mod_name}", __name__)
28
+ except ImportError:
29
+ pass
30
+ del _importlib, _optional_modules, _mod_name
31
+
32
+ try:
33
+ from .services import service
34
+ except ImportError:
35
+ pass
36
+
32
37
 
33
38
  # ##### Set pycarta context ##### #
34
39
  import os
40
+ import warnings
35
41
  from .auth import (
36
42
  CartaAgent,
37
43
  CartaLoginUI,
@@ -40,7 +46,10 @@ from .auth import (
40
46
  )
41
47
  from .admin.types import User, Group
42
48
  from .exceptions import AuthenticationError
43
- from .sbg.login import SbgLoginManager
49
+ try:
50
+ from .sbg.login import SbgLoginManager
51
+ except ImportError:
52
+ SbgLoginManager = None
44
53
  from functools import wraps
45
54
 
46
55
 
@@ -50,15 +59,21 @@ class Singleton:
50
59
  if not isinstance(class_._instance, class_):
51
60
  class_._instance = object.__new__(class_, *args, **kwargs)
52
61
  return class_._instance
53
-
62
+
54
63
 
55
64
  class PycartaContext(Singleton):
56
65
  def __init__(self):
57
- self._sbg_login_manager: None | SbgLoginManager = None
66
+ self._sbg_login_manager: None | object = None
58
67
  self._profile: None | Profile = Profile()
59
68
  self._agent: None | CartaAgent = None
60
69
  self._interactive: bool = False
61
- self.login()
70
+ # D18.2-E (i): eager self.login() removed. Import-time authentication
71
+ # was a footgun — silently authenticating against production whenever
72
+ # CARTA_USER/CARTA_PASS were set in the environment. The lazy `agent`
73
+ # property (below) still logs in on first access, so idiomatic
74
+ # callers (pycarta.get_agent(), pycarta.admin.*) are unaffected.
75
+ # BREAKING: callers who relied on `import pycarta` to auto-auth must
76
+ # now call pycarta.login(...) explicitly.
62
77
 
63
78
  @property
64
79
  def agent(self):
@@ -73,7 +88,12 @@ class PycartaContext(Singleton):
73
88
  self._agent = agent
74
89
 
75
90
  @property
76
- def sbg_login_manager(self) -> SbgLoginManager:
91
+ def sbg_login_manager(self):
92
+ if SbgLoginManager is None:
93
+ raise ImportError(
94
+ "pycarta.sbg requires 'sevenbridges'. "
95
+ "Install it with: pip install pycarta[sbg]"
96
+ )
77
97
  if self._sbg_login_manager is None:
78
98
  self._sbg_login_manager = SbgLoginManager()
79
99
  return self._sbg_login_manager
@@ -90,11 +110,11 @@ class PycartaContext(Singleton):
90
110
 
91
111
  def is_interactive(self) -> bool:
92
112
  return self._interactive
93
-
113
+
94
114
  def ion(self) -> None:
95
115
  """Allow interaction with the user."""
96
116
  self._interactive = True
97
-
117
+
98
118
  def ioff(self) -> None:
99
119
  """Disallow interaction with the user."""
100
120
  self._interactive = False
@@ -105,6 +125,7 @@ class PycartaContext(Singleton):
105
125
  profile: str | None=None,
106
126
  username: str | None=None,
107
127
  password: str | None=None,
128
+ api_token: str | None=None,
108
129
  environment: str | None=None,
109
130
  host: str | None=None,
110
131
  interactive: bool=False,
@@ -113,9 +134,15 @@ class PycartaContext(Singleton):
113
134
  """
114
135
  Authenticate using a profile or username/password. Profile takes
115
136
  precedence over username/password. If neither are provided, then the
116
- CARTA_PROFILE environment variable is checked. If that is not set, then
117
- CARTA_USER and CARTA_PASS environment variables are checked for the
118
- username and password, respectively.
137
+ CARTA_PROFILE environment variable is checked. If that is not set,
138
+ then the credentials env vars are consulted in this order:
139
+
140
+ CARTA_USERNAME / CARTA_PASSWORD (preferred)
141
+ CARTA_USER / CARTA_PASS (deprecated aliases)
142
+
143
+ When only the deprecated aliases are set, a ``DeprecationWarning``
144
+ fires naming the modern replacement (D18.2-E ii). Precedence matches
145
+ ``tests/conftest.py::smoke_test_auth`` byte-for-byte.
119
146
 
120
147
  If these options are exhausted, but either "interactive" is set to
121
148
  True or the context is interactive, then the CartaLoginUI is used to
@@ -123,11 +150,13 @@ class PycartaContext(Singleton):
123
150
 
124
151
  In summary, in order of precedence:
125
152
 
126
- 1. Profile
127
- 2. Username/Password
128
- 3. CARTA_PROFILE environment variable
129
- 4. CARTA_USER/CARTA_PASS environment variable
130
- 5. Interactive
153
+ 1. API token (``api_token`` parameter or ``CARTA_API_TOKEN`` env var)
154
+ 2. Profile
155
+ 3. Username/Password
156
+ 4. CARTA_PROFILE environment variable
157
+ 5. CARTA_USERNAME/CARTA_PASSWORD environment variable
158
+ (CARTA_USER/CARTA_PASS accepted as deprecated aliases)
159
+ 6. Interactive
131
160
 
132
161
  Parameters
133
162
  ----------
@@ -156,13 +185,43 @@ class PycartaContext(Singleton):
156
185
  """
157
186
  from getpass import getpass
158
187
 
159
- # Check environment variables
188
+ # Check environment variables. Prefer modern names
189
+ # (CARTA_USERNAME / CARTA_PASSWORD); fall back to legacy
190
+ # CARTA_USER / CARTA_PASS with a DeprecationWarning. Precedence matches
191
+ # tests/conftest.py::smoke_test_auth byte-for-byte — see D18.2-E (ii).
192
+ api_token_ = api_token or os.environ.get("CARTA_API_TOKEN", None)
193
+
160
194
  profile_ = profile or os.environ.get("CARTA_PROFILE", None)
161
- username_ = username or os.environ.get("CARTA_USER", None)
162
- password_ = password or os.environ.get("CARTA_PASS", None)
195
+
196
+ _username_modern = os.environ.get("CARTA_USERNAME")
197
+ _username_legacy = os.environ.get("CARTA_USER")
198
+ if _username_modern is None and _username_legacy is not None:
199
+ warnings.warn(
200
+ "CARTA_USER is deprecated; use CARTA_USERNAME instead. "
201
+ "CARTA_USER will be removed in a future release.",
202
+ DeprecationWarning,
203
+ stacklevel=2,
204
+ )
205
+ username_ = username or _username_modern or _username_legacy
206
+
207
+ _password_modern = os.environ.get("CARTA_PASSWORD")
208
+ _password_legacy = os.environ.get("CARTA_PASS")
209
+ if _password_modern is None and _password_legacy is not None:
210
+ warnings.warn(
211
+ "CARTA_PASS is deprecated; use CARTA_PASSWORD instead. "
212
+ "CARTA_PASS will be removed in a future release.",
213
+ DeprecationWarning,
214
+ stacklevel=2,
215
+ )
216
+ password_ = password or _password_modern or _password_legacy
217
+
163
218
  environment_ = environment or os.environ.get("CARTA_ENV", None) or "production"
164
219
  host_ = host or os.environ.get("CARTA_HOST", None)
165
- if profile:
220
+ if api_token_:
221
+ self.agent = CartaAgent(api_token=api_token_,
222
+ environment=environment_,
223
+ host=host or host_,)
224
+ elif profile:
166
225
  self.agent = CartaAgent(profile=profile)
167
226
  elif username and password:
168
227
  self.agent = CartaAgent(username=username,
@@ -188,10 +247,11 @@ class PycartaContext(Singleton):
188
247
  self.agent = CartaWebLogin.login(environment=environment_,
189
248
  host=host_,)
190
249
  # Log in to Seven Bridges
191
- if not self._sbg_login_manager:
192
- self._sbg_login_manager = SbgLoginManager()
193
- elif reauthenticate_sbg:
194
- self._sbg_login_manager.login(interactive=interactive)
250
+ if SbgLoginManager is not None:
251
+ if not self._sbg_login_manager:
252
+ self._sbg_login_manager = SbgLoginManager()
253
+ elif reauthenticate_sbg:
254
+ self._sbg_login_manager.login(interactive=interactive)
195
255
  # TODO: This was probably done to avoid the automatic login logic.
196
256
  # TODO: Better to avoid the magic.
197
257
  # return False if self._agent is None else self.agent.is_authenticated()
@@ -0,0 +1,30 @@
1
+ """Compatibility utilities for optional dependency checking."""
2
+
3
+
4
+ def require_extra(module: str, package: str, extra: str) -> None:
5
+ """Check that an optional dependency is installed.
6
+
7
+ Call this at the top of a module's ``__init__.py`` to fail fast when
8
+ the required extras group has not been installed.
9
+
10
+ Parameters
11
+ ----------
12
+ module : str
13
+ The pycarta subpackage name (e.g. ``"mqtt"``).
14
+ package : str
15
+ The pip package to probe via import (e.g. ``"aiomqtt"``).
16
+ extra : str
17
+ The extras group name (e.g. ``"mqtt"``).
18
+
19
+ Raises
20
+ ------
21
+ ImportError
22
+ If *package* cannot be imported.
23
+ """
24
+ try:
25
+ __import__(package)
26
+ except ImportError:
27
+ raise ImportError(
28
+ f"pycarta.{module} requires '{package}'. "
29
+ f"Install it with: pip install pycarta[{extra}]"
30
+ ) from None