elapi 2.1.0__tar.gz → 2.2.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.
- {elapi-2.1.0 → elapi-2.2.0}/PKG-INFO +87 -70
- {elapi-2.1.0 → elapi-2.2.0}/README.md +81 -67
- {elapi-2.1.0 → elapi-2.2.0}/pyproject.toml +6 -4
- elapi-2.2.0/src/elapi/VERSION +1 -0
- elapi-2.2.0/src/elapi/__init__.py +2 -0
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/_names.py +8 -0
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/api/__init__.py +3 -0
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/api/api.py +277 -94
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/api/endpoint.py +72 -21
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/api/validators.py +6 -6
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/cli/_plugin_handler.py +55 -25
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/cli/_venv_state_manager.py +17 -2
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/cli/doc.py +10 -8
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/cli/elapi.py +393 -304
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/configuration/__init__.py +14 -3
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/configuration/_config_history.py +15 -5
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/configuration/_overload_history.py +57 -27
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/configuration/config.py +21 -3
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/configuration/overridable_vars.py +36 -0
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/configuration/validators.py +90 -11
- elapi-2.2.0/src/elapi/loggers/__init__.py +52 -0
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/loggers/base.py +20 -4
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/path.py +4 -5
- elapi-2.2.0/src/elapi/plugins/__init__.py +1 -0
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/plugins/bill_teams/_doc.py +7 -5
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/plugins/bill_teams/cli.py +54 -36
- elapi-2.2.0/src/elapi/plugins/bill_teams/formats.py +25 -0
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/plugins/bill_teams/specification.py +2 -2
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/plugins/commons/cli_helpers.py +13 -8
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/plugins/commons/export.py +4 -5
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/plugins/commons/get_data_from_input_or_path.py +3 -3
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/plugins/commons/get_information.py +51 -32
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/plugins/experiments/_doc.py +10 -18
- elapi-2.2.0/src/elapi/plugins/experiments/cli.py +356 -0
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/plugins/experiments/formats.py +27 -2
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/plugins/show_config.py +2 -1
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/styles/__init__.py +2 -2
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/styles/base.py +2 -1
- elapi-2.2.0/src/elapi/styles/formats.py +219 -0
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/styles/highlight.py +3 -3
- elapi-2.2.0/src/elapi/utils/__init__.py +9 -0
- elapi-2.2.0/src/elapi/utils/messages.py +82 -0
- elapi-2.2.0/src/elapi/utils/utils.py +52 -0
- elapi-2.1.0/src/elapi/VERSION +0 -1
- elapi-2.1.0/src/elapi/__init__.py +0 -2
- elapi-2.1.0/src/elapi/loggers/__init__.py +0 -16
- elapi-2.1.0/src/elapi/plugins/__init__.py +0 -0
- elapi-2.1.0/src/elapi/plugins/bill_teams/format.py +0 -30
- elapi-2.1.0/src/elapi/plugins/experiments/cli.py +0 -336
- elapi-2.1.0/src/elapi/plugins/version.py +0 -10
- elapi-2.1.0/src/elapi/styles/format.py +0 -147
- elapi-2.1.0/src/elapi/utils/__init__.py +0 -2
- elapi-2.1.0/src/elapi/utils/messages.py +0 -84
- elapi-2.1.0/src/elapi/utils/utils.py +0 -58
- {elapi-2.1.0 → elapi-2.2.0}/LICENSE +0 -0
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/cli/__init__.py +0 -0
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/cli/__main__.py +0 -0
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/configuration/log_file.py +0 -0
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/core_validators/__init__.py +0 -0
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/core_validators/base.py +0 -0
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/core_validators/path.py +0 -0
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/loggers/handlers/__init__.py +0 -0
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/loggers/handlers/file.py +0 -0
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/loggers/handlers/stderr.py +0 -0
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/plugins/bill_teams/__init__.py +0 -0
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/plugins/bill_teams/bill_teams.py +0 -0
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/plugins/bill_teams/generate_table.py +0 -0
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/plugins/bill_teams/invoice.py +0 -0
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/plugins/bill_teams/validators.py +0 -0
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/plugins/commons/__init__.py +0 -0
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/plugins/commons/get_location_from_headers.py +0 -0
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/plugins/experiments/__init__.py +0 -0
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/plugins/experiments/experiments.py +0 -0
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/styles/_markdown_doc.py +0 -0
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/styles/_missing.py +0 -0
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/styles/colors.py +0 -0
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/styles/rich_utils.py +0 -0
- {elapi-2.1.0 → elapi-2.2.0}/src/elapi/validators.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: elapi
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2.0
|
|
4
4
|
Summary: elAPI is a powerful, extensible API client for eLabFTW.
|
|
5
5
|
Home-page: https://www.urz.uni-heidelberg.de/en/service-catalogue/software-and-applications/elabftw
|
|
6
6
|
License: AGPL-3.0-only
|
|
@@ -22,6 +22,7 @@ Classifier: Programming Language :: Python :: 3
|
|
|
22
22
|
Classifier: Programming Language :: Python :: 3.9
|
|
23
23
|
Classifier: Programming Language :: Python :: 3.10
|
|
24
24
|
Classifier: Programming Language :: Python :: 3.11
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
25
26
|
Classifier: Topic :: Internet :: WWW/HTTP
|
|
26
27
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
27
28
|
Classifier: Topic :: System :: Systems Administration
|
|
@@ -32,21 +33,33 @@ Requires-Dist: h2 (>=4.1.0,<5.0.0)
|
|
|
32
33
|
Requires-Dist: httpx (>=0.24.1,<0.25.0)
|
|
33
34
|
Requires-Dist: httpx-auth (>=0.17.0,<0.18.0)
|
|
34
35
|
Requires-Dist: mistune (>=3.0.2,<4.0.0)
|
|
35
|
-
Requires-Dist: python-dateutil (>=2.
|
|
36
|
+
Requires-Dist: python-dateutil (>=2.9.0.post0,<3.0.0) ; extra == "uhd-urz"
|
|
36
37
|
Requires-Dist: pyyaml (>=6.0.1,<7.0.0)
|
|
37
|
-
Requires-Dist:
|
|
38
|
+
Requires-Dist: rich (>=13.8.0,<14.0.0)
|
|
39
|
+
Requires-Dist: tenacity (>=9.0.0,<10.0.0) ; extra == "uhd-urz"
|
|
38
40
|
Requires-Dist: typer[all] (>=0.9.0,<0.10.0)
|
|
41
|
+
Requires-Dist: uvloop (>=0.20.0,<0.21.0) ; extra == "uhd-urz"
|
|
39
42
|
Project-URL: Repository, https://github.com/uhd-urz/elAPI/
|
|
40
43
|
Description-Content-Type: text/markdown
|
|
41
44
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
<p align="center">
|
|
46
|
+
<img src="https://heibox.uni-heidelberg.de/f/43bdc63b9458478e949f/?dl=1" alt="elAPI logo" width=120 />
|
|
47
|
+
</p>
|
|
48
|
+
|
|
49
|
+
<p align="center">
|
|
50
|
+
<a href="https://pypi.org/project/elapi">
|
|
51
|
+
<img alt="Package version" src="https://badge.fury.io/py/elapi.svg/?branch=main" />
|
|
52
|
+
</a>
|
|
53
|
+
<a href="#compatibility">
|
|
54
|
+
<img alt="Static Badge" src="https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-%230d7dbe">
|
|
55
|
+
<img alt="Static Badge" src="https://img.shields.io/badge/eLabFTW%20support-4.5%2B%20%7C%205.0%20%7C%205.1-%2323b3be">
|
|
56
|
+
</a>
|
|
57
|
+
</p>
|
|
58
|
+
|
|
59
|
+
elAPI is a powerful, extensible API client for [eLabFTW](https://www.elabftw.net/) developed at
|
|
47
60
|
the [University Computing Centre](https://www.urz.uni-heidelberg.de/en)
|
|
48
61
|
(URZ, [FIRE](https://www.urz.uni-heidelberg.de/en/node/64/organisation/future-it-research-education) division) of
|
|
49
|
-
[University of Heidelberg](https://www.uni-heidelberg.de/en). It supports serving all kinds of requests documented
|
|
62
|
+
[University of Heidelberg](https://www.uni-heidelberg.de/en). It supports serving all kinds of requests documented in
|
|
50
63
|
[eLabFTW API documentation](https://doc.elabftw.net/api/v2/) with ease. elAPI provides a simple interface via its CLI
|
|
51
64
|
executable, and numerous advanced APIs when it is used directly as a Python package.
|
|
52
65
|
|
|
@@ -70,16 +83,6 @@ local `~/Downloads/` folder.
|
|
|
70
83
|
|
|
71
84
|
## Installation
|
|
72
85
|
|
|
73
|
-
elAPI can be used both as a CLI tool and as a Python library. If you are interested in simply using elAPI's
|
|
74
|
-
off-the-shelf features from the command-line, install elAPI as a CLI tool. If you intend to write automation script for
|
|
75
|
-
eLabFTW, you should install elAPI as a library inside a virtual environment. Of course, if you're interested in
|
|
76
|
-
both, you can have elAPI installed in both ways.
|
|
77
|
-
|
|
78
|
-
### Install elAPI as a CLI tool
|
|
79
|
-
|
|
80
|
-
Support for installing Python packages with `pip install --user` has been deprecated with the adoption
|
|
81
|
-
of [PEP 688](https://peps.python.org/pep-0668/) on many systems
|
|
82
|
-
like [Debian 12](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1030335#5).
|
|
83
86
|
We recommend [`pipx`](https://pipx.pypa.io/stable/) for installing elAPI for use of its CLI functionalities. Pipx
|
|
84
87
|
installs packages in isolated virtual environments, so Pipx-installed elAPI should not conflict with elAPI installed
|
|
85
88
|
inside other virtual environments.
|
|
@@ -89,24 +92,52 @@ $ pipx install elapi
|
|
|
89
92
|
```
|
|
90
93
|
|
|
91
94
|
After installation with Pipx is complete, you would also be able to run elAPI just by entering the `elapi` command on
|
|
92
|
-
the
|
|
93
|
-
|
|
95
|
+
the terminal. You can move on to ["Getting started"](#getting-started).
|
|
96
|
+
|
|
97
|
+
### Advanced installation
|
|
98
|
+
|
|
99
|
+
elAPI can be used both as a CLI tool and as a Python library. If you are interested in simply using elAPI's
|
|
100
|
+
off-the-shelf features from the command-line, install elAPI as a CLI tool (see ["Installation"](#installation)). If you
|
|
101
|
+
intend to write automation script for eLabFTW, you should install elAPI as a library inside a virtual environment. Of
|
|
102
|
+
course, if you're interested in both, you can have elAPI installed in both ways.
|
|
94
103
|
|
|
95
|
-
|
|
104
|
+
> [!NOTE]
|
|
105
|
+
> Support for installing Python packages with `pip install --user` has been deprecated with the adoption
|
|
106
|
+
> of [PEP 688](https://peps.python.org/pep-0668/) on many systems
|
|
107
|
+
> like [Debian 12](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1030335#5).
|
|
96
108
|
|
|
97
|
-
|
|
109
|
+
### Installing elAPI as a library
|
|
110
|
+
|
|
111
|
+
It is recommended to install elAPI inside a Python virtual environment with your preferred package manager (`pip`,
|
|
112
|
+
`poetry`, `pipenv`, `rye`, `uv`, etc.) for use of its rich APIs for
|
|
98
113
|
working with eLabFTW. From inside a virtual environment, elAPI CLI can be invoked with `python -m elapi.cli`.
|
|
99
114
|
At the moment, though, the documentation about using elAPI as a library is severely lacking.
|
|
100
115
|
|
|
101
|
-
##
|
|
116
|
+
## Getting started
|
|
102
117
|
|
|
103
|
-
|
|
104
|
-
server
|
|
118
|
+
Once you have elAPI [installed](#installation), to **quickly** get started, run `elapi init`. You will be prompted with
|
|
119
|
+
questions about your eLabFTW server with examples to help you fill in the answers. Here's a demo:
|
|
120
|
+
|
|
121
|
+
```shell
|
|
122
|
+
$ elapi init
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
<video src='https://github.com/user-attachments/assets/8d5f69ed-b644-4d75-b816-d06d4e937105'> </video>
|
|
126
|
+
<p align="center">elapi init demo</p>
|
|
105
127
|
|
|
106
|
-
|
|
128
|
+
That's all! Run [`elapi show-config`](#show-config) to view your configuration details.
|
|
107
129
|
|
|
108
|
-
|
|
109
|
-
|
|
130
|
+
## Compatibility
|
|
131
|
+
|
|
132
|
+
elAPI is compatible with the following Python versions: `3.9`, `3.10`, `3.11`, `3.12`. elAPI supports
|
|
133
|
+
the [eLabFTW REST API v2](https://doc.elabftw.net/api/v2/), and can be used with the following eLabFTW
|
|
134
|
+
versions: `4.5`, `4.6`, `4.7`, `4.8`, `4.9`, `4.10`, `5.0`, `5.1`.
|
|
135
|
+
|
|
136
|
+
## Configuration
|
|
137
|
+
|
|
138
|
+
elAPI needs to be configured first before you can do anything useful with it. Mainly, elAPI needs to know your eLabFTW
|
|
139
|
+
server's API URL and your API key (or token) for access. See quick configuration method
|
|
140
|
+
in "[Getting started](#getting-started)" before you dive into the advanced settings.
|
|
110
141
|
|
|
111
142
|
### Advanced configuration
|
|
112
143
|
|
|
@@ -141,15 +172,17 @@ verify_ssl: true
|
|
|
141
172
|
timeout: 90
|
|
142
173
|
```
|
|
143
174
|
|
|
144
|
-
`export_dir` is where elAPI will export response content to if no path is provided to `--export/-E`.
|
|
145
|
-
When `unsafe_api_token_warning` is `True`, elAPI will show a warning if you're storing `elapi.yml` in the current
|
|
146
|
-
working directory, as it typically happens that developers accidentally commit and push configuration files with
|
|
147
|
-
secrets.
|
|
148
|
-
|
|
149
|
-
HTTP/2 if you are making async requests with
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
175
|
+
- `export_dir` is where elAPI will export response content to if no path is explicitly provided to `--export/-E`.
|
|
176
|
+
- When `unsafe_api_token_warning` is `True`, elAPI will show a warning if you're storing `elapi.yml` in the current
|
|
177
|
+
working directory, as it typically happens that developers accidentally commit and push configuration files with
|
|
178
|
+
secrets.
|
|
179
|
+
- `enable_http2` enables HTTP/2 protocol support which by default is turned off. Be aware
|
|
180
|
+
of [known issues](https://github.com/encode/httpx/discussions/2112) with HTTP/2 if you are making async requests with
|
|
181
|
+
a heavy load.
|
|
182
|
+
- `verify_ssl` can be turned off with value `False` if you are
|
|
183
|
+
trying out a development server that doesn't provide a valid SSL certificate.
|
|
184
|
+
- `timeout` can be modified to your needs. E.g., a poor internet connection might benefit from a higher timeout number.
|
|
185
|
+
The default timeout is `90` seconds.
|
|
153
186
|
|
|
154
187
|
### `show-config`
|
|
155
188
|
|
|
@@ -157,36 +190,14 @@ You can get an overview of detected configuration with `elapi show-config`. `sho
|
|
|
157
190
|
which configuration values are actually used by elAPI, if you are working with multiple configuration files.
|
|
158
191
|
|
|
159
192
|
```shell
|
|
160
|
-
$ elapi show-config
|
|
161
|
-
|
|
162
|
-
elapi configuration information
|
|
163
|
-
|
|
164
|
-
The following debug information includes configuration values and their sources as detected by elapi.
|
|
165
|
-
|
|
166
|
-
▌ Name [Key]: Value ← Source
|
|
167
|
-
|
|
168
|
-
• Log file path: /Users/ <username >/.local/share/elapi/elapi.log
|
|
169
|
-
• Host address [host]: https://demo.elabftw.net/api/v2 ← USER LEVEL
|
|
170
|
-
• API Token [api_token]: 00-55******55555 ← USER LEVEL
|
|
171
|
-
• Export directory [export_dir]: /Users/ ← USER LEVEL <username >/Downloads/elapi
|
|
172
|
-
• App data directory: /Users/ <username >/.local/share/elapi
|
|
173
|
-
• Third-party plugins directory: /Users/ <username >/.local/share/elapi/plugins
|
|
174
|
-
• Caching directory: /private/var/tmp/elapi
|
|
175
|
-
• Unsafe API token use warning [unsafe_api_token_warning]: True ← USER LEVEL
|
|
176
|
-
• Enable HTTP/2 [enable_http2]: False ← USER LEVEL
|
|
177
|
-
• Verify SSL certificate [verify_ssl]: True ← USER LEVEL
|
|
178
|
-
• Timeout duration [timeout]: 90.0 seconds ← USER LEVEL
|
|
179
|
-
• Development mode [development_mode]: False ← USER LEVEL
|
|
180
|
-
|
|
181
|
-
Detected configuration sources that are in use:
|
|
182
|
-
|
|
183
|
-
• USER LEVEL: /Users/ <username >/.config/elapi.yml
|
|
184
|
-
|
|
193
|
+
$ elapi show-config # system username: "culdesac"
|
|
185
194
|
```
|
|
186
195
|
|
|
196
|
+

|
|
197
|
+
|
|
187
198
|
If both `host` and `api_token` are detected, you are good to go!
|
|
188
199
|
|
|
189
|
-
###
|
|
200
|
+
### Overriding configuration
|
|
190
201
|
|
|
191
202
|
elAPI now supports `--override/--OC` as a global option that can be used to override the configuration parameters
|
|
192
203
|
as detected by `elapi show-cofig`. All plugins will also automatically listen to the overridden configuration. This can
|
|
@@ -266,7 +277,7 @@ You can reset the configuration to default values.
|
|
|
266
277
|
$ elapi delete config
|
|
267
278
|
```
|
|
268
279
|
|
|
269
|
-
### `experiments` plugin
|
|
280
|
+
### `experiments` built-in plugin
|
|
270
281
|
|
|
271
282
|
`experiments` plugin enables experiments-specific actions. You can download an experiment in PDF by its "Unique eLabID"
|
|
272
283
|
to `~/Downloads` directory.
|
|
@@ -287,7 +298,7 @@ You can also upload an attachment to an experiment.
|
|
|
287
298
|
$ elapi experiments upload-attachment --id <experiment ID> --path <path to attachment file> --comment <comment for your attachment>
|
|
288
299
|
```
|
|
289
300
|
|
|
290
|
-
|
|
301
|
+
## Creating a plugin
|
|
291
302
|
|
|
292
303
|
elAPI has seamless support with tight-integration for third-party plugins. A simple third-party plugin can be created in
|
|
293
304
|
a few easy steps:
|
|
@@ -314,7 +325,7 @@ you want to create a plugin metadata file `elapi_plugin_metadata.yml` (notice on
|
|
|
314
325
|
define the virtual environment that your plugin specifically requires.
|
|
315
326
|
|
|
316
327
|
```python
|
|
317
|
-
import requests
|
|
328
|
+
import requests # A third-party dependency
|
|
318
329
|
|
|
319
330
|
from elapi.api import GETRequest
|
|
320
331
|
from elapi.plugins.commons import Typer
|
|
@@ -338,8 +349,14 @@ def wiki_status():
|
|
|
338
349
|
And the path to virtual environment will be defined in the metadata file:
|
|
339
350
|
|
|
340
351
|
```yaml
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
352
|
+
# elapi_plugin_metadata.yml
|
|
353
|
+
plugin_name: awesome
|
|
354
|
+
cli_script: ~/awesome/cli.py # Path to the cli.py script
|
|
355
|
+
venv_dir: ~/awesome/.venv # Path to the virtual environment
|
|
356
|
+
project_dir: ~/awesome # Path to the project root directory where the plugin is located
|
|
344
357
|
```
|
|
345
358
|
|
|
359
|
+
This metadata file of plugin `awesome` must be placed inside `~/.local/share/elapi/plugins/awesome`. Notice, the plugin
|
|
360
|
+
name must also match the parent directory name of `elapi_plugin_metadata.yml`. This way we ensure a plugin name remains
|
|
361
|
+
unique.
|
|
362
|
+
|
|
@@ -1,11 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://heibox.uni-heidelberg.de/f/43bdc63b9458478e949f/?dl=1" alt="elAPI logo" width=120 />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://pypi.org/project/elapi">
|
|
7
|
+
<img alt="Package version" src="https://badge.fury.io/py/elapi.svg/?branch=main" />
|
|
8
|
+
</a>
|
|
9
|
+
<a href="#compatibility">
|
|
10
|
+
<img alt="Static Badge" src="https://img.shields.io/badge/python-3.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-%230d7dbe">
|
|
11
|
+
<img alt="Static Badge" src="https://img.shields.io/badge/eLabFTW%20support-4.5%2B%20%7C%205.0%20%7C%205.1-%2323b3be">
|
|
12
|
+
</a>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
elAPI is a powerful, extensible API client for [eLabFTW](https://www.elabftw.net/) developed at
|
|
6
16
|
the [University Computing Centre](https://www.urz.uni-heidelberg.de/en)
|
|
7
17
|
(URZ, [FIRE](https://www.urz.uni-heidelberg.de/en/node/64/organisation/future-it-research-education) division) of
|
|
8
|
-
[University of Heidelberg](https://www.uni-heidelberg.de/en). It supports serving all kinds of requests documented
|
|
18
|
+
[University of Heidelberg](https://www.uni-heidelberg.de/en). It supports serving all kinds of requests documented in
|
|
9
19
|
[eLabFTW API documentation](https://doc.elabftw.net/api/v2/) with ease. elAPI provides a simple interface via its CLI
|
|
10
20
|
executable, and numerous advanced APIs when it is used directly as a Python package.
|
|
11
21
|
|
|
@@ -29,16 +39,6 @@ local `~/Downloads/` folder.
|
|
|
29
39
|
|
|
30
40
|
## Installation
|
|
31
41
|
|
|
32
|
-
elAPI can be used both as a CLI tool and as a Python library. If you are interested in simply using elAPI's
|
|
33
|
-
off-the-shelf features from the command-line, install elAPI as a CLI tool. If you intend to write automation script for
|
|
34
|
-
eLabFTW, you should install elAPI as a library inside a virtual environment. Of course, if you're interested in
|
|
35
|
-
both, you can have elAPI installed in both ways.
|
|
36
|
-
|
|
37
|
-
### Install elAPI as a CLI tool
|
|
38
|
-
|
|
39
|
-
Support for installing Python packages with `pip install --user` has been deprecated with the adoption
|
|
40
|
-
of [PEP 688](https://peps.python.org/pep-0668/) on many systems
|
|
41
|
-
like [Debian 12](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1030335#5).
|
|
42
42
|
We recommend [`pipx`](https://pipx.pypa.io/stable/) for installing elAPI for use of its CLI functionalities. Pipx
|
|
43
43
|
installs packages in isolated virtual environments, so Pipx-installed elAPI should not conflict with elAPI installed
|
|
44
44
|
inside other virtual environments.
|
|
@@ -48,24 +48,52 @@ $ pipx install elapi
|
|
|
48
48
|
```
|
|
49
49
|
|
|
50
50
|
After installation with Pipx is complete, you would also be able to run elAPI just by entering the `elapi` command on
|
|
51
|
-
the
|
|
52
|
-
|
|
51
|
+
the terminal. You can move on to ["Getting started"](#getting-started).
|
|
52
|
+
|
|
53
|
+
### Advanced installation
|
|
54
|
+
|
|
55
|
+
elAPI can be used both as a CLI tool and as a Python library. If you are interested in simply using elAPI's
|
|
56
|
+
off-the-shelf features from the command-line, install elAPI as a CLI tool (see ["Installation"](#installation)). If you
|
|
57
|
+
intend to write automation script for eLabFTW, you should install elAPI as a library inside a virtual environment. Of
|
|
58
|
+
course, if you're interested in both, you can have elAPI installed in both ways.
|
|
53
59
|
|
|
54
|
-
|
|
60
|
+
> [!NOTE]
|
|
61
|
+
> Support for installing Python packages with `pip install --user` has been deprecated with the adoption
|
|
62
|
+
> of [PEP 688](https://peps.python.org/pep-0668/) on many systems
|
|
63
|
+
> like [Debian 12](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1030335#5).
|
|
55
64
|
|
|
56
|
-
|
|
65
|
+
### Installing elAPI as a library
|
|
66
|
+
|
|
67
|
+
It is recommended to install elAPI inside a Python virtual environment with your preferred package manager (`pip`,
|
|
68
|
+
`poetry`, `pipenv`, `rye`, `uv`, etc.) for use of its rich APIs for
|
|
57
69
|
working with eLabFTW. From inside a virtual environment, elAPI CLI can be invoked with `python -m elapi.cli`.
|
|
58
70
|
At the moment, though, the documentation about using elAPI as a library is severely lacking.
|
|
59
71
|
|
|
60
|
-
##
|
|
72
|
+
## Getting started
|
|
61
73
|
|
|
62
|
-
|
|
63
|
-
server
|
|
74
|
+
Once you have elAPI [installed](#installation), to **quickly** get started, run `elapi init`. You will be prompted with
|
|
75
|
+
questions about your eLabFTW server with examples to help you fill in the answers. Here's a demo:
|
|
76
|
+
|
|
77
|
+
```shell
|
|
78
|
+
$ elapi init
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
<video src='https://github.com/user-attachments/assets/8d5f69ed-b644-4d75-b816-d06d4e937105'> </video>
|
|
82
|
+
<p align="center">elapi init demo</p>
|
|
64
83
|
|
|
65
|
-
|
|
84
|
+
That's all! Run [`elapi show-config`](#show-config) to view your configuration details.
|
|
66
85
|
|
|
67
|
-
|
|
68
|
-
|
|
86
|
+
## Compatibility
|
|
87
|
+
|
|
88
|
+
elAPI is compatible with the following Python versions: `3.9`, `3.10`, `3.11`, `3.12`. elAPI supports
|
|
89
|
+
the [eLabFTW REST API v2](https://doc.elabftw.net/api/v2/), and can be used with the following eLabFTW
|
|
90
|
+
versions: `4.5`, `4.6`, `4.7`, `4.8`, `4.9`, `4.10`, `5.0`, `5.1`.
|
|
91
|
+
|
|
92
|
+
## Configuration
|
|
93
|
+
|
|
94
|
+
elAPI needs to be configured first before you can do anything useful with it. Mainly, elAPI needs to know your eLabFTW
|
|
95
|
+
server's API URL and your API key (or token) for access. See quick configuration method
|
|
96
|
+
in "[Getting started](#getting-started)" before you dive into the advanced settings.
|
|
69
97
|
|
|
70
98
|
### Advanced configuration
|
|
71
99
|
|
|
@@ -100,15 +128,17 @@ verify_ssl: true
|
|
|
100
128
|
timeout: 90
|
|
101
129
|
```
|
|
102
130
|
|
|
103
|
-
`export_dir` is where elAPI will export response content to if no path is provided to `--export/-E`.
|
|
104
|
-
When `unsafe_api_token_warning` is `True`, elAPI will show a warning if you're storing `elapi.yml` in the current
|
|
105
|
-
working directory, as it typically happens that developers accidentally commit and push configuration files with
|
|
106
|
-
secrets.
|
|
107
|
-
|
|
108
|
-
HTTP/2 if you are making async requests with
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
131
|
+
- `export_dir` is where elAPI will export response content to if no path is explicitly provided to `--export/-E`.
|
|
132
|
+
- When `unsafe_api_token_warning` is `True`, elAPI will show a warning if you're storing `elapi.yml` in the current
|
|
133
|
+
working directory, as it typically happens that developers accidentally commit and push configuration files with
|
|
134
|
+
secrets.
|
|
135
|
+
- `enable_http2` enables HTTP/2 protocol support which by default is turned off. Be aware
|
|
136
|
+
of [known issues](https://github.com/encode/httpx/discussions/2112) with HTTP/2 if you are making async requests with
|
|
137
|
+
a heavy load.
|
|
138
|
+
- `verify_ssl` can be turned off with value `False` if you are
|
|
139
|
+
trying out a development server that doesn't provide a valid SSL certificate.
|
|
140
|
+
- `timeout` can be modified to your needs. E.g., a poor internet connection might benefit from a higher timeout number.
|
|
141
|
+
The default timeout is `90` seconds.
|
|
112
142
|
|
|
113
143
|
### `show-config`
|
|
114
144
|
|
|
@@ -116,36 +146,14 @@ You can get an overview of detected configuration with `elapi show-config`. `sho
|
|
|
116
146
|
which configuration values are actually used by elAPI, if you are working with multiple configuration files.
|
|
117
147
|
|
|
118
148
|
```shell
|
|
119
|
-
$ elapi show-config
|
|
120
|
-
|
|
121
|
-
elapi configuration information
|
|
122
|
-
|
|
123
|
-
The following debug information includes configuration values and their sources as detected by elapi.
|
|
124
|
-
|
|
125
|
-
▌ Name [Key]: Value ← Source
|
|
126
|
-
|
|
127
|
-
• Log file path: /Users/ <username >/.local/share/elapi/elapi.log
|
|
128
|
-
• Host address [host]: https://demo.elabftw.net/api/v2 ← USER LEVEL
|
|
129
|
-
• API Token [api_token]: 00-55******55555 ← USER LEVEL
|
|
130
|
-
• Export directory [export_dir]: /Users/ ← USER LEVEL <username >/Downloads/elapi
|
|
131
|
-
• App data directory: /Users/ <username >/.local/share/elapi
|
|
132
|
-
• Third-party plugins directory: /Users/ <username >/.local/share/elapi/plugins
|
|
133
|
-
• Caching directory: /private/var/tmp/elapi
|
|
134
|
-
• Unsafe API token use warning [unsafe_api_token_warning]: True ← USER LEVEL
|
|
135
|
-
• Enable HTTP/2 [enable_http2]: False ← USER LEVEL
|
|
136
|
-
• Verify SSL certificate [verify_ssl]: True ← USER LEVEL
|
|
137
|
-
• Timeout duration [timeout]: 90.0 seconds ← USER LEVEL
|
|
138
|
-
• Development mode [development_mode]: False ← USER LEVEL
|
|
139
|
-
|
|
140
|
-
Detected configuration sources that are in use:
|
|
141
|
-
|
|
142
|
-
• USER LEVEL: /Users/ <username >/.config/elapi.yml
|
|
143
|
-
|
|
149
|
+
$ elapi show-config # system username: "culdesac"
|
|
144
150
|
```
|
|
145
151
|
|
|
152
|
+

|
|
153
|
+
|
|
146
154
|
If both `host` and `api_token` are detected, you are good to go!
|
|
147
155
|
|
|
148
|
-
###
|
|
156
|
+
### Overriding configuration
|
|
149
157
|
|
|
150
158
|
elAPI now supports `--override/--OC` as a global option that can be used to override the configuration parameters
|
|
151
159
|
as detected by `elapi show-cofig`. All plugins will also automatically listen to the overridden configuration. This can
|
|
@@ -225,7 +233,7 @@ You can reset the configuration to default values.
|
|
|
225
233
|
$ elapi delete config
|
|
226
234
|
```
|
|
227
235
|
|
|
228
|
-
### `experiments` plugin
|
|
236
|
+
### `experiments` built-in plugin
|
|
229
237
|
|
|
230
238
|
`experiments` plugin enables experiments-specific actions. You can download an experiment in PDF by its "Unique eLabID"
|
|
231
239
|
to `~/Downloads` directory.
|
|
@@ -246,7 +254,7 @@ You can also upload an attachment to an experiment.
|
|
|
246
254
|
$ elapi experiments upload-attachment --id <experiment ID> --path <path to attachment file> --comment <comment for your attachment>
|
|
247
255
|
```
|
|
248
256
|
|
|
249
|
-
|
|
257
|
+
## Creating a plugin
|
|
250
258
|
|
|
251
259
|
elAPI has seamless support with tight-integration for third-party plugins. A simple third-party plugin can be created in
|
|
252
260
|
a few easy steps:
|
|
@@ -273,7 +281,7 @@ you want to create a plugin metadata file `elapi_plugin_metadata.yml` (notice on
|
|
|
273
281
|
define the virtual environment that your plugin specifically requires.
|
|
274
282
|
|
|
275
283
|
```python
|
|
276
|
-
import requests
|
|
284
|
+
import requests # A third-party dependency
|
|
277
285
|
|
|
278
286
|
from elapi.api import GETRequest
|
|
279
287
|
from elapi.plugins.commons import Typer
|
|
@@ -297,7 +305,13 @@ def wiki_status():
|
|
|
297
305
|
And the path to virtual environment will be defined in the metadata file:
|
|
298
306
|
|
|
299
307
|
```yaml
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
308
|
+
# elapi_plugin_metadata.yml
|
|
309
|
+
plugin_name: awesome
|
|
310
|
+
cli_script: ~/awesome/cli.py # Path to the cli.py script
|
|
311
|
+
venv_dir: ~/awesome/.venv # Path to the virtual environment
|
|
312
|
+
project_dir: ~/awesome # Path to the project root directory where the plugin is located
|
|
303
313
|
```
|
|
314
|
+
|
|
315
|
+
This metadata file of plugin `awesome` must be placed inside `~/.local/share/elapi/plugins/awesome`. Notice, the plugin
|
|
316
|
+
name must also match the parent directory name of `elapi_plugin_metadata.yml`. This way we ensure a plugin name remains
|
|
317
|
+
unique.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "elapi"
|
|
3
|
-
version = "2.
|
|
3
|
+
version = "2.2.0"
|
|
4
4
|
description = "elAPI is a powerful, extensible API client for eLabFTW."
|
|
5
5
|
authors = [
|
|
6
6
|
"Alexander Haller, Mahadi Xion <elabftw@uni-heidelberg.de>",
|
|
@@ -38,15 +38,17 @@ python = "^3.9.0"
|
|
|
38
38
|
dynaconf = "^3.2.0"
|
|
39
39
|
httpx = "^0.24.1"
|
|
40
40
|
httpx-auth = "^0.17.0"
|
|
41
|
+
rich = "^13.8.0" # typer already depends on rich. We define rich here to use the latest version of rich
|
|
41
42
|
typer = { extras = ["all"], version = "^0.9.0" }
|
|
42
43
|
pyyaml = "^6.0.1"
|
|
43
44
|
mistune = "^3.0.2"
|
|
44
45
|
h2 = "^4.1.0"
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
tenacity = { version = "^9.0.0", optional = true }
|
|
47
|
+
python-dateutil = { version = "^2.9.0.post0", optional = true }
|
|
48
|
+
uvloop = { version = "^0.20.0", optional = true }
|
|
47
49
|
|
|
48
50
|
[tool.poetry.extras]
|
|
49
|
-
uhd-urz = ["python-dateutil", "tenacity"]
|
|
51
|
+
uhd-urz = ["python-dateutil", "tenacity", "uvloop"]
|
|
50
52
|
|
|
51
53
|
[tool.poetry.group.dev.dependencies]
|
|
52
54
|
ptpython = "^3.0.23"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.2.0
|
|
@@ -10,9 +10,16 @@ LOG_FILE_NAME: str = f"{APP_NAME}.log"
|
|
|
10
10
|
CONFIG_FILE_EXTENSION: str = "yml"
|
|
11
11
|
CONFIG_FILE_NAME: str = f"{APP_NAME}.{CONFIG_FILE_EXTENSION}"
|
|
12
12
|
DEFAULT_EXPORT_DATA_FORMAT: str = "json"
|
|
13
|
+
VERSION_FILE_NAME: str = "VERSION"
|
|
13
14
|
user_home: Path = Path.home()
|
|
14
15
|
cur_dir: Path = Path.cwd()
|
|
15
16
|
|
|
17
|
+
# eLabFTW specific definitions
|
|
18
|
+
ELAB_NAME: str = "elabftw"
|
|
19
|
+
ELAB_BRAND_NAME: str = "eLabFTW"
|
|
20
|
+
ELAB_API_EXPECTED_VERSION: int = 2
|
|
21
|
+
ELAB_HOST_URL_API_SUFFIX: str = f"/api/v{ELAB_API_EXPECTED_VERSION}"
|
|
22
|
+
|
|
16
23
|
# reference for the following directory conventions:
|
|
17
24
|
# https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
|
18
25
|
|
|
@@ -44,6 +51,7 @@ KEY_ENABLE_HTTP2: str = "ENABLE_HTTP2"
|
|
|
44
51
|
KEY_VERIFY_SSL: str = "VERIFY_SSL"
|
|
45
52
|
KEY_TIMEOUT: str = "TIMEOUT"
|
|
46
53
|
KEY_DEVELOPMENT_MODE: str = "DEVELOPMENT_MODE"
|
|
54
|
+
KEY_PLUGIN_KEY_NAME: str = "PLUGINS"
|
|
47
55
|
|
|
48
56
|
# Log data directory with root permission
|
|
49
57
|
LOG_DIR_ROOT: Path = Path(f"/var/log/{APP_NAME}")
|