mechbase 0.2.2__tar.gz → 0.5.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.
- mechbase-0.5.0/PKG-INFO +71 -0
- mechbase-0.5.0/README.md +56 -0
- {mechbase-0.2.2 → mechbase-0.5.0}/pyproject.toml +4 -1
- {mechbase-0.2.2 → mechbase-0.5.0}/src/mechbase/_http.py +3 -0
- mechbase-0.5.0/src/mechbase/cli.py +577 -0
- {mechbase-0.2.2 → mechbase-0.5.0}/src/mechbase/client.py +16 -0
- {mechbase-0.2.2 → mechbase-0.5.0}/src/mechbase/models.py +69 -2
- {mechbase-0.2.2 → mechbase-0.5.0}/src/mechbase/resources/_base.py +20 -1
- mechbase-0.5.0/src/mechbase/resources/analytics.py +29 -0
- mechbase-0.5.0/src/mechbase/resources/findings.py +52 -0
- {mechbase-0.2.2 → mechbase-0.5.0}/src/mechbase/resources/measurements.py +26 -21
- {mechbase-0.2.2 → mechbase-0.5.0}/src/mechbase/resources/registry.py +27 -2
- {mechbase-0.2.2 → mechbase-0.5.0}/src/mechbase/resources/routes.py +7 -0
- mechbase-0.5.0/src/mechbase/resources/thread.py +80 -0
- mechbase-0.5.0/tests/test_cli.py +64 -0
- mechbase-0.5.0/tests/test_parity.py +130 -0
- mechbase-0.5.0/tests/test_thread.py +107 -0
- {mechbase-0.2.2 → mechbase-0.5.0}/uv.lock +1 -1
- mechbase-0.2.2/PKG-INFO +0 -40
- mechbase-0.2.2/README.md +0 -25
- {mechbase-0.2.2 → mechbase-0.5.0}/.gitignore +0 -0
- {mechbase-0.2.2 → mechbase-0.5.0}/examples/list_assets.py +0 -0
- {mechbase-0.2.2 → mechbase-0.5.0}/examples/push_measurement.py +0 -0
- {mechbase-0.2.2 → mechbase-0.5.0}/examples/run_survey.py +0 -0
- {mechbase-0.2.2 → mechbase-0.5.0}/examples/sync_registry.py +0 -0
- {mechbase-0.2.2 → mechbase-0.5.0}/src/mechbase/__init__.py +0 -0
- {mechbase-0.2.2 → mechbase-0.5.0}/src/mechbase/errors.py +0 -0
- {mechbase-0.2.2 → mechbase-0.5.0}/src/mechbase/maintnode.py +0 -0
- {mechbase-0.2.2 → mechbase-0.5.0}/src/mechbase/resources/__init__.py +0 -0
- {mechbase-0.2.2 → mechbase-0.5.0}/tests/test_client.py +0 -0
- {mechbase-0.2.2 → mechbase-0.5.0}/tests/test_idempotency.py +0 -0
- {mechbase-0.2.2 → mechbase-0.5.0}/tests/test_maintnode.py +0 -0
- {mechbase-0.2.2 → mechbase-0.5.0}/tests/test_null_safety.py +0 -0
- {mechbase-0.2.2 → mechbase-0.5.0}/tests/test_registry.py +0 -0
mechbase-0.5.0/PKG-INFO
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: mechbase
|
|
3
|
+
Version: 0.5.0
|
|
4
|
+
Summary: Official Python client for the Mechbase condition-monitoring API
|
|
5
|
+
Project-URL: Homepage, https://app.mechbase.io
|
|
6
|
+
Project-URL: Source, https://github.com/arpedon/mechbase-sdk
|
|
7
|
+
Author: Arpedon
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
|
+
Requires-Dist: httpx>=0.27
|
|
11
|
+
Provides-Extra: dev
|
|
12
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
13
|
+
Requires-Dist: respx>=0.21; extra == 'dev'
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# mechbase
|
|
17
|
+
|
|
18
|
+
Official Python client for the [Mechbase](https://app.mechbase.io) condition-monitoring API.
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install mechbase
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
from mechbase import Mechbase
|
|
26
|
+
|
|
27
|
+
client = Mechbase(token="...") # defaults to https://app.mechbase.io
|
|
28
|
+
# self-hosted: Mechbase(token="...", base_url="https://mechbase.internal.acme.com")
|
|
29
|
+
|
|
30
|
+
me = client.me()
|
|
31
|
+
inst = client.for_installation(me.current_installation_id)
|
|
32
|
+
|
|
33
|
+
assets = inst.assets.list(q="pump", limit=50)
|
|
34
|
+
inst.measurements.create(point_id=42, data={"rms": 2.3}, notes="manual reading")
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Command line
|
|
38
|
+
|
|
39
|
+
The package installs a `mechbase` command:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pipx install mechbase
|
|
43
|
+
mechbase login # once; token stored in ~/.config/mechbase/config.json
|
|
44
|
+
mechbase points --asset 1
|
|
45
|
+
mechbase readings 2 # latest readings of point 2
|
|
46
|
+
mechbase reading show 2 766 # values, state and top spectrum peaks (electrical lines tagged)
|
|
47
|
+
mechbase reading delete 2 767
|
|
48
|
+
mechbase point show 2 # running, stale, alarm limits, last 7 days
|
|
49
|
+
mechbase findings --status open # diagnosed faults
|
|
50
|
+
mechbase finding ack <uuid> --wo WO-1234
|
|
51
|
+
mechbase finding close <uuid>
|
|
52
|
+
mechbase export measurements --point 2 -o readings.csv # also events, inspections; --format parquet
|
|
53
|
+
mechbase photo add point 2 pump.jpg # or: photo add asset 1 …, photo delete point 2 <uuid>
|
|
54
|
+
mechbase logout # revokes the stored token
|
|
55
|
+
mechbase comments 1 # an asset's thread
|
|
56
|
+
mechbase comment add 1 "Bearing noise after restart" --point 2 --reading 766
|
|
57
|
+
mechbase docs 1 # an asset's documents
|
|
58
|
+
mechbase doc add 1 manual.pdf --kind manual
|
|
59
|
+
mechbase alarms 2 # a point's limits: its own, then the installation default
|
|
60
|
+
mechbase alarm set 2 --minor 2.8 --major 7.1
|
|
61
|
+
mechbase alarm clear 2 # back to the installation default
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Reading numbers are the ones in the web URL (`…/measurementpoints/2/measurements/766/`).
|
|
65
|
+
Add `--json` to any command for scripting; `MECHBASE_TOKEN`, `MECHBASE_URL` and
|
|
66
|
+
`MECHBASE_INSTALLATION` override the stored config.
|
|
67
|
+
|
|
68
|
+
For edge agents identified by a `node_uuid` rather than a bearer token, use `MaintNode`.
|
|
69
|
+
|
|
70
|
+
Full docs and the other language SDKs (Go, Swift, Kotlin) live in the
|
|
71
|
+
[mechbase-sdk repo](https://github.com/arpedon/mechbase-sdk).
|
mechbase-0.5.0/README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# mechbase
|
|
2
|
+
|
|
3
|
+
Official Python client for the [Mechbase](https://app.mechbase.io) condition-monitoring API.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
pip install mechbase
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
from mechbase import Mechbase
|
|
11
|
+
|
|
12
|
+
client = Mechbase(token="...") # defaults to https://app.mechbase.io
|
|
13
|
+
# self-hosted: Mechbase(token="...", base_url="https://mechbase.internal.acme.com")
|
|
14
|
+
|
|
15
|
+
me = client.me()
|
|
16
|
+
inst = client.for_installation(me.current_installation_id)
|
|
17
|
+
|
|
18
|
+
assets = inst.assets.list(q="pump", limit=50)
|
|
19
|
+
inst.measurements.create(point_id=42, data={"rms": 2.3}, notes="manual reading")
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Command line
|
|
23
|
+
|
|
24
|
+
The package installs a `mechbase` command:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pipx install mechbase
|
|
28
|
+
mechbase login # once; token stored in ~/.config/mechbase/config.json
|
|
29
|
+
mechbase points --asset 1
|
|
30
|
+
mechbase readings 2 # latest readings of point 2
|
|
31
|
+
mechbase reading show 2 766 # values, state and top spectrum peaks (electrical lines tagged)
|
|
32
|
+
mechbase reading delete 2 767
|
|
33
|
+
mechbase point show 2 # running, stale, alarm limits, last 7 days
|
|
34
|
+
mechbase findings --status open # diagnosed faults
|
|
35
|
+
mechbase finding ack <uuid> --wo WO-1234
|
|
36
|
+
mechbase finding close <uuid>
|
|
37
|
+
mechbase export measurements --point 2 -o readings.csv # also events, inspections; --format parquet
|
|
38
|
+
mechbase photo add point 2 pump.jpg # or: photo add asset 1 …, photo delete point 2 <uuid>
|
|
39
|
+
mechbase logout # revokes the stored token
|
|
40
|
+
mechbase comments 1 # an asset's thread
|
|
41
|
+
mechbase comment add 1 "Bearing noise after restart" --point 2 --reading 766
|
|
42
|
+
mechbase docs 1 # an asset's documents
|
|
43
|
+
mechbase doc add 1 manual.pdf --kind manual
|
|
44
|
+
mechbase alarms 2 # a point's limits: its own, then the installation default
|
|
45
|
+
mechbase alarm set 2 --minor 2.8 --major 7.1
|
|
46
|
+
mechbase alarm clear 2 # back to the installation default
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Reading numbers are the ones in the web URL (`…/measurementpoints/2/measurements/766/`).
|
|
50
|
+
Add `--json` to any command for scripting; `MECHBASE_TOKEN`, `MECHBASE_URL` and
|
|
51
|
+
`MECHBASE_INSTALLATION` override the stored config.
|
|
52
|
+
|
|
53
|
+
For edge agents identified by a `node_uuid` rather than a bearer token, use `MaintNode`.
|
|
54
|
+
|
|
55
|
+
Full docs and the other language SDKs (Go, Swift, Kotlin) live in the
|
|
56
|
+
[mechbase-sdk repo](https://github.com/arpedon/mechbase-sdk).
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "mechbase"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.5.0"
|
|
8
8
|
description = "Official Python client for the Mechbase condition-monitoring API"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -15,6 +15,9 @@ dependencies = [
|
|
|
15
15
|
"httpx>=0.27",
|
|
16
16
|
]
|
|
17
17
|
|
|
18
|
+
[project.scripts]
|
|
19
|
+
mechbase = "mechbase.cli:main"
|
|
20
|
+
|
|
18
21
|
[project.optional-dependencies]
|
|
19
22
|
dev = [
|
|
20
23
|
"pytest>=8",
|
|
@@ -47,6 +47,7 @@ class HttpClient:
|
|
|
47
47
|
data: dict | None = None,
|
|
48
48
|
files: dict | list | None = None,
|
|
49
49
|
headers: dict | None = None,
|
|
50
|
+
raw: bool = False,
|
|
50
51
|
) -> Any:
|
|
51
52
|
response = self._client.request(
|
|
52
53
|
method,
|
|
@@ -57,6 +58,8 @@ class HttpClient:
|
|
|
57
58
|
files=files,
|
|
58
59
|
headers=headers,
|
|
59
60
|
)
|
|
61
|
+
if raw and 200 <= response.status_code < 300:
|
|
62
|
+
return response.content
|
|
60
63
|
return self._handle(response)
|
|
61
64
|
|
|
62
65
|
@staticmethod
|