labapi 1.0.3__py3-none-any.whl

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.
@@ -0,0 +1,210 @@
1
+ Metadata-Version: 2.4
2
+ Name: labapi
3
+ Version: 1.0.3
4
+ Summary: A Python client for the LabArchives API.
5
+ Author-email: Christoph Li <christoph.li@nih.gov>, Joshua Lawrimore <josh.lawrimore@nih.gov>
6
+ License: CC0-1.0
7
+ Project-URL: Documentation, https://github.com/nimh-dsst/labapi/tree/main/docs/source
8
+ Project-URL: Issues, https://github.com/nimh-dsst/labapi/issues
9
+ Project-URL: Source, https://github.com/nimh-dsst/labapi
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
14
+ Classifier: Natural Language :: English
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: Implementation :: CPython
21
+ Classifier: Topic :: Internet :: WWW/HTTP
22
+ Classifier: Topic :: Scientific/Engineering
23
+ Classifier: Topic :: Software Development :: Libraries
24
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
25
+ Classifier: Typing :: Typed
26
+ Requires-Python: >=3.12
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ Requires-Dist: cryptography>=46.0.3
30
+ Requires-Dist: lxml>=6.0.2
31
+ Requires-Dist: requests>=2.32.5
32
+ Provides-Extra: builtin-auth
33
+ Requires-Dist: selenium>=4.39.0; extra == "builtin-auth"
34
+ Requires-Dist: installed-browsers>=0.1.5; extra == "builtin-auth"
35
+ Provides-Extra: dotenv
36
+ Requires-Dist: python-dotenv>=1.2.1; extra == "dotenv"
37
+ Dynamic: license-file
38
+
39
+ # labapi
40
+
41
+ A Python client for the LabArchives API.
42
+
43
+ [![Python Version](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/)
44
+ [![Tests](https://github.com/nimh-dsst/labapi/actions/workflows/unit_tests.yml/badge.svg?branch=main)](https://github.com/nimh-dsst/labapi/actions/workflows/unit_tests.yml)
45
+ [![License: CC0-1.0](https://img.shields.io/badge/License-CC0_1.0-lightgrey.svg)](https://creativecommons.org/publicdomain/zero/1.0/)
46
+
47
+ `labapi` helps you authenticate with LabArchives, navigate notebook trees, and create or update notebook content from Python.
48
+
49
+ [Source](https://github.com/nimh-dsst/labapi) | [Docs](https://github.com/nimh-dsst/labapi/tree/main/docs/source) | [Issues](https://github.com/nimh-dsst/labapi/issues)
50
+
51
+ ## Start Here
52
+
53
+ - New to `labapi`? Follow the [First Success Tutorial](https://github.com/nimh-dsst/labapi/blob/main/docs/source/quick_start/tutorial.rst) for the fastest path from install to a visible change in LabArchives.
54
+ - Already using `labapi`? Jump to the [Quick Start](https://github.com/nimh-dsst/labapi/blob/main/docs/source/quick_start/index.rst), [User Guide](https://github.com/nimh-dsst/labapi/blob/main/docs/source/guide/index.rst), [Examples](https://github.com/nimh-dsst/labapi/blob/main/docs/source/examples/index.rst), or [FAQ](https://github.com/nimh-dsst/labapi/blob/main/docs/source/faq.rst).
55
+ - Working on the package itself? Start with [CONTRIBUTING.md](https://github.com/nimh-dsst/labapi/blob/main/CONTRIBUTING.md).
56
+
57
+ ## Install
58
+
59
+ Requirements:
60
+
61
+ - Python 3.12+
62
+ - `uv` (recommended) or `pip`
63
+
64
+ Recommended install for local use:
65
+
66
+ ```bash
67
+ uv add "labapi[dotenv,builtin-auth]"
68
+ # or
69
+ pip install "labapi[dotenv,builtin-auth]"
70
+ ```
71
+
72
+ Other install options:
73
+
74
+ ```bash
75
+ # Minimal install
76
+ uv add labapi
77
+ # or
78
+ pip install labapi
79
+
80
+ # Minimal install plus .env loading
81
+ uv add "labapi[dotenv]"
82
+ # or
83
+ pip install "labapi[dotenv]"
84
+ ```
85
+
86
+ Extras:
87
+
88
+ - `dotenv` loads `API_URL`, `ACCESS_KEYID`, and `ACCESS_PWD` from a local `.env` file.
89
+ - `builtin-auth` enables `default_authenticate()` to open the LabArchives login flow in a local browser.
90
+
91
+ ## Configure Credentials
92
+
93
+ Add your LabArchives API credentials to a `.env` file:
94
+
95
+ ```env
96
+ API_URL=https://api.labarchives.com
97
+ ACCESS_KEYID=your_access_key_id
98
+ ACCESS_PWD=your_access_password
99
+ ```
100
+
101
+ Or set them directly in your shell:
102
+
103
+ ```bash
104
+ export API_URL=https://api.labarchives.com
105
+ export ACCESS_KEYID=your_access_key_id
106
+ export ACCESS_PWD=your_access_password
107
+ ```
108
+
109
+ ```powershell
110
+ $env:API_URL="https://api.labarchives.com"
111
+ $env:ACCESS_KEYID="your_access_key_id"
112
+ $env:ACCESS_PWD="your_access_password"
113
+ ```
114
+
115
+ `.env` files are only auto-loaded when `python-dotenv` is installed, such as with `labapi[dotenv]`.
116
+
117
+ ## Quick Start
118
+
119
+ ```python
120
+ from datetime import datetime
121
+
122
+ from labapi import Client, NotebookPage, TextEntry
123
+
124
+ with Client() as client:
125
+ user = client.default_authenticate()
126
+
127
+ notebook_name = next(iter(user.notebooks))
128
+ notebook = user.notebooks[notebook_name]
129
+ page = notebook.create(
130
+ NotebookPage,
131
+ f"API tutorial - {datetime.now():%Y-%m-%d %H:%M:%S}",
132
+ )
133
+ page.entries.create(TextEntry, "<p>Hello from labapi!</p>")
134
+ ```
135
+
136
+ This is the recommended local workflow:
137
+
138
+ 1. Install `labapi[dotenv,builtin-auth]`.
139
+ 2. Set `API_URL`, `ACCESS_KEYID`, and `ACCESS_PWD`.
140
+ 3. Call `default_authenticate()` once the client is open.
141
+ 4. Start creating or updating notebooks, folders, pages, and entries through the object model.
142
+
143
+ ## Common Tasks
144
+
145
+ Authenticate in a service or callback-based app:
146
+
147
+ ```python
148
+ from labapi import Client
149
+
150
+ with Client() as client:
151
+ auth_url = client.generate_auth_url(callback_url)
152
+ # Redirect the user to auth_url, then read email + auth_code
153
+ user = client.login(email, auth_code)
154
+ ```
155
+
156
+ Create different entry types:
157
+
158
+ ```python
159
+ from labapi import HeaderEntry, PlainTextEntry, TextEntry
160
+
161
+ page.entries.create(TextEntry, "<p>Rich text content</p>")
162
+ page.entries.create(HeaderEntry, "Final Conclusions")
163
+ page.entries.create(PlainTextEntry, "<p>Literal text</p>")
164
+ page.entries.create_json_entry({"yield": 0.85, "purity": "99%"})
165
+ ```
166
+
167
+ Browse notebooks by name and path:
168
+
169
+ ```python
170
+ for name in user.notebooks:
171
+ print(name)
172
+
173
+ notebook = user.notebooks["My Research Notebook"]
174
+ page = notebook.traverse("Experiments/2026/Results")
175
+ ```
176
+
177
+ ## Documentation Map
178
+
179
+ - [First Success Tutorial](https://github.com/nimh-dsst/labapi/blob/main/docs/source/quick_start/tutorial.rst): shortest path from install to a successful write.
180
+ - [Quick Start](https://github.com/nimh-dsst/labapi/blob/main/docs/source/quick_start/index.rst): setup, navigation, page creation, uploads, and basic write operations.
181
+ - [Authentication Guide](https://github.com/nimh-dsst/labapi/blob/main/docs/source/guide/auth.rst): local browser auth, manual flows, and callback-based integration patterns.
182
+ - [User Guide](https://github.com/nimh-dsst/labapi/blob/main/docs/source/guide/index.rst): paths, entries, API behavior, exceptions, limits, and architecture notes.
183
+ - [Examples](https://github.com/nimh-dsst/labapi/blob/main/docs/source/examples/index.rst): end-to-end scripts for real workflows.
184
+ - [FAQ](https://github.com/nimh-dsst/labapi/blob/main/docs/source/faq.rst): troubleshooting and environment questions.
185
+
186
+ ## Development
187
+
188
+ Clone the repo and install development dependencies:
189
+
190
+ ```bash
191
+ git clone https://github.com/nimh-dsst/labapi.git
192
+ cd labapi
193
+ uv sync --all-groups
194
+ pre-commit install --hook-type pre-commit --hook-type pre-push
195
+ ```
196
+
197
+ Common checks:
198
+
199
+ ```bash
200
+ uv run pytest
201
+ uv run ruff check --fix .
202
+ uv run ruff format .
203
+ uv run pyright
204
+ ```
205
+
206
+ Integration tests are opt-in and require live credentials. See [CONTRIBUTING.md](https://github.com/nimh-dsst/labapi/blob/main/CONTRIBUTING.md) for the full setup, including `AUTH_EMAIL` and `AUTH_KEY`.
207
+
208
+ ## License
209
+
210
+ This project is licensed under the CC0 1.0 Universal License. See the [LICENSE](https://github.com/nimh-dsst/labapi/blob/main/LICENSE) file for details.
@@ -0,0 +1,31 @@
1
+ labapi/__init__.py,sha256=kvFdoZdiFzU8DEX5DulOHXmGx9OsLcb0AVmdoVuKA_A,1906
2
+ labapi/client.py,sha256=0VJNVxeMxy6HyyKYqH7FiUrQsaVYJxqX1T4dtsWtdS4,35176
3
+ labapi/exceptions.py,sha256=03mfCco_CEFitusPYGn59HQMjnl15MmSZ2UeXmTf3wg,2451
4
+ labapi/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
5
+ labapi/user.py,sha256=MK-DTLTmaYt8bLe8joqp-Sluzylb2Zdfpg1ERFdZ0PI,5511
6
+ labapi/entry/__init__.py,sha256=kxFrQteFCd5lye6gTi2v4iTmRea4RB39GnmntB2qvXQ,767
7
+ labapi/entry/attachment.py,sha256=pouY-0czE-bfRI3TzhEOf-AY9FRc7WWYvVUFh6TdKE4,6297
8
+ labapi/entry/collection.py,sha256=3JzA15TLCLkf9AVJ6v5elhJ1TbdGxoSTcErnZySAEUI,7296
9
+ labapi/entry/comment.py,sha256=rYBp4NncGOYgjEyLJjE18odQeF1huGG3NUuYcLEcRhw,435
10
+ labapi/entry/entries/__init__.py,sha256=GdsDOfclJ0HzqH2mo-Kn8GoIhY2dUqnpdTrWEZjDEmE,561
11
+ labapi/entry/entries/attachment.py,sha256=Vx0_r1FmwsRxcv2oNchPSJLGasYt7woKzTlutHynIfE,5144
12
+ labapi/entry/entries/base.py,sha256=J6iAToFcs1ZptRNHRclXPLriS7CI6_7ZEShlDfyPHgw,4675
13
+ labapi/entry/entries/text.py,sha256=NkqTnBska2nj6heAynZnvkZskI7HVpmgjQkH-WmjfFw,2066
14
+ labapi/entry/entries/unknown.py,sha256=w3M6kqQ1_9HOK0WSkVAN6ISl_ilom6o-5ZJ27Pqo7P8,1183
15
+ labapi/entry/entries/widget.py,sha256=HG8BKsQD_OKjGHB--C5NkdvqtEuekjAyl2VPst_F2WA,908
16
+ labapi/tree/__init__.py,sha256=3zcucyfjwIhnHk1H-bcwIFeDrm01oudjjAoZibEaUa8,593
17
+ labapi/tree/collection.py,sha256=NRQoigVYl1Sf81EWbyEz9xSkLLU_KEozKmvJ59Rnlto,6565
18
+ labapi/tree/directory.py,sha256=eC2P7vVVtgPN9US-3R5xsyWTglm5YOUhqiy-IRyyI2k,1886
19
+ labapi/tree/mixins.py,sha256=MnBQw7C_T2wMcLHnkog9DNaSZkb0WsPLIkVLqjEVC78,30545
20
+ labapi/tree/notebook.py,sha256=_q2lj8bf812Rh47lLyuRvkqoPDe0tV1flOV7ApFbBqg,2151
21
+ labapi/tree/page.py,sha256=Pp6C6bFyGOj44Nq0qF9GBg30eg22d-C4zQBVd-7tITM,8259
22
+ labapi/util/__init__.py,sha256=dJZ5PjA9yDZjBVkXwjETvOAtW3h9xJk1KCKk8QvJIwM,959
23
+ labapi/util/browser.py,sha256=lJwOsHkrP0S126rIu0FvsbVbyXRmI7gWE5hocPMZcdQ,3849
24
+ labapi/util/extract.py,sha256=wBqx7SnPmFD24WpVSyPnh1nWYcLq-TM6lue6I7Q9Q5Y,4429
25
+ labapi/util/path.py,sha256=MLnREDaiCybAiz7NbNotaXf293jCtzlzquOYFpev8x4,13451
26
+ labapi/util/types.py,sha256=s7hTo5uufYx3hx8Ml0v09zI8kp05My_-x7t_XJtMxso,2090
27
+ labapi-1.0.3.dist-info/licenses/LICENSE,sha256=ogEPNDSH0_dhiv_lT3ifVIdgIzHAqNA_SemnxUfPBJk,7048
28
+ labapi-1.0.3.dist-info/METADATA,sha256=8AoB7kSZ_VcCNlCgssPqROb9-0YfWsZpo-tSqG9av2U,7616
29
+ labapi-1.0.3.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
30
+ labapi-1.0.3.dist-info/top_level.txt,sha256=QnLtvV90oNubXOj2xAcMPyE51zTh08_WUPSN5ZHtl08,7
31
+ labapi-1.0.3.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,121 @@
1
+ Creative Commons Legal Code
2
+
3
+ CC0 1.0 Universal
4
+
5
+ CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6
+ LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
7
+ ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8
+ INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9
+ REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
10
+ PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
11
+ THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
12
+ HEREUNDER.
13
+
14
+ Statement of Purpose
15
+
16
+ The laws of most jurisdictions throughout the world automatically confer
17
+ exclusive Copyright and Related Rights (defined below) upon the creator
18
+ and subsequent owner(s) (each and all, an "owner") of an original work of
19
+ authorship and/or a database (each, a "Work").
20
+
21
+ Certain owners wish to permanently relinquish those rights to a Work for
22
+ the purpose of contributing to a commons of creative, cultural and
23
+ scientific works ("Commons") that the public can reliably and without fear
24
+ of later claims of infringement build upon, modify, incorporate in other
25
+ works, reuse and redistribute as freely as possible in any form whatsoever
26
+ and for any purposes, including without limitation commercial purposes.
27
+ These owners may contribute to the Commons to promote the ideal of a free
28
+ culture and the further production of creative, cultural and scientific
29
+ works, or to gain reputation or greater distribution for their Work in
30
+ part through the use and efforts of others.
31
+
32
+ For these and/or other purposes and motivations, and without any
33
+ expectation of additional consideration or compensation, the person
34
+ associating CC0 with a Work (the "Affirmer"), to the extent that he or she
35
+ is an owner of Copyright and Related Rights in the Work, voluntarily
36
+ elects to apply CC0 to the Work and publicly distribute the Work under its
37
+ terms, with knowledge of his or her Copyright and Related Rights in the
38
+ Work and the meaning and intended legal effect of CC0 on those rights.
39
+
40
+ 1. Copyright and Related Rights. A Work made available under CC0 may be
41
+ protected by copyright and related or neighboring rights ("Copyright and
42
+ Related Rights"). Copyright and Related Rights include, but are not
43
+ limited to, the following:
44
+
45
+ i. the right to reproduce, adapt, distribute, perform, display,
46
+ communicate, and translate a Work;
47
+ ii. moral rights retained by the original author(s) and/or performer(s);
48
+ iii. publicity and privacy rights pertaining to a person's image or
49
+ likeness depicted in a Work;
50
+ iv. rights protecting against unfair competition in regards to a Work,
51
+ subject to the limitations in paragraph 4(a), below;
52
+ v. rights protecting the extraction, dissemination, use and reuse of data
53
+ in a Work;
54
+ vi. database rights (such as those arising under Directive 96/9/EC of the
55
+ European Parliament and of the Council of 11 March 1996 on the legal
56
+ protection of databases, and under any national implementation
57
+ thereof, including any amended or successor version of such
58
+ directive); and
59
+ vii. other similar, equivalent or corresponding rights throughout the
60
+ world based on applicable law or treaty, and any national
61
+ implementations thereof.
62
+
63
+ 2. Waiver. To the greatest extent permitted by, but not in contravention
64
+ of, applicable law, Affirmer hereby overtly, fully, permanently,
65
+ irrevocably and unconditionally waives, abandons, and surrenders all of
66
+ Affirmer's Copyright and Related Rights and associated claims and causes
67
+ of action, whether now known or unknown (including existing as well as
68
+ future claims and causes of action), in the Work (i) in all territories
69
+ worldwide, (ii) for the maximum duration provided by applicable law or
70
+ treaty (including future time extensions), (iii) in any current or future
71
+ medium and for any number of copies, and (iv) for any purpose whatsoever,
72
+ including without limitation commercial, advertising or promotional
73
+ purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
74
+ member of the public at large and to the detriment of Affirmer's heirs and
75
+ successors, fully intending that such Waiver shall not be subject to
76
+ revocation, rescission, cancellation, termination, or any other legal or
77
+ equitable action to disrupt the quiet enjoyment of the Work by the public
78
+ as contemplated by Affirmer's express Statement of Purpose.
79
+
80
+ 3. Public License Fallback. Should any part of the Waiver for any reason
81
+ be judged legally invalid or ineffective under applicable law, then the
82
+ Waiver shall be preserved to the maximum extent permitted taking into
83
+ account Affirmer's express Statement of Purpose. In addition, to the
84
+ extent the Waiver is so judged Affirmer hereby grants to each affected
85
+ person a royalty-free, non transferable, non sublicensable, non exclusive,
86
+ irrevocable and unconditional license to exercise Affirmer's Copyright and
87
+ Related Rights in the Work (i) in all territories worldwide, (ii) for the
88
+ maximum duration provided by applicable law or treaty (including future
89
+ time extensions), (iii) in any current or future medium and for any number
90
+ of copies, and (iv) for any purpose whatsoever, including without
91
+ limitation commercial, advertising or promotional purposes (the
92
+ "License"). The License shall be deemed effective as of the date CC0 was
93
+ applied by Affirmer to the Work. Should any part of the License for any
94
+ reason be judged legally invalid or ineffective under applicable law, such
95
+ partial invalidity or ineffectiveness shall not invalidate the remainder
96
+ of the License, and in such case Affirmer hereby affirms that he or she
97
+ will not (i) exercise any of his or her remaining Copyright and Related
98
+ Rights in the Work or (ii) assert any associated claims and causes of
99
+ action with respect to the Work, in either case contrary to Affirmer's
100
+ express Statement of Purpose.
101
+
102
+ 4. Limitations and Disclaimers.
103
+
104
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
105
+ surrendered, licensed or otherwise affected by this document.
106
+ b. Affirmer offers the Work as-is and makes no representations or
107
+ warranties of any kind concerning the Work, express, implied,
108
+ statutory or otherwise, including without limitation warranties of
109
+ title, merchantability, fitness for a particular purpose, non
110
+ infringement, or the absence of latent or other defects, accuracy, or
111
+ the present or absence of errors, whether or not discoverable, all to
112
+ the greatest extent permissible under applicable law.
113
+ c. Affirmer disclaims responsibility for clearing rights of other persons
114
+ that may apply to the Work or any use thereof, including without
115
+ limitation any person's Copyright and Related Rights in the Work.
116
+ Further, Affirmer disclaims responsibility for obtaining any necessary
117
+ consents, permissions or other rights required for any use of the
118
+ Work.
119
+ d. Affirmer understands and acknowledges that Creative Commons is not a
120
+ party to this document and has no duty or obligation with respect to
121
+ this CC0 or use of the Work.
@@ -0,0 +1 @@
1
+ labapi