CoreDataX 0.10.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.
- coredatax-0.10.0/PKG-INFO +116 -0
- coredatax-0.10.0/README.md +94 -0
- coredatax-0.10.0/api/CoreDataX/CDX.py +3928 -0
- coredatax-0.10.0/api/CoreDataX/__init__.py +27 -0
- coredatax-0.10.0/api/CoreDataX/__main__.py +49 -0
- coredatax-0.10.0/api/CoreDataX/client.py +206 -0
- coredatax-0.10.0/api/CoreDataX/example.csv +4 -0
- coredatax-0.10.0/api/CoreDataX/loader.py +71 -0
- coredatax-0.10.0/api/CoreDataX/requirements.txt +1 -0
- coredatax-0.10.0/api/CoreDataX/server.py +44 -0
- coredatax-0.10.0/pyproject.toml +42 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: CoreDataX
|
|
3
|
+
Version: 0.10.0
|
|
4
|
+
Summary: API for uploading data to the PSMA's CoreDataeXchange project.
|
|
5
|
+
Project-URL: Homepage, https://coredatax.com
|
|
6
|
+
Project-URL: Repository, https://github.com/CoreDataX/CoreDataX
|
|
7
|
+
Project-URL: Contact, https://coredatax.com
|
|
8
|
+
Author-email: George Slama <gslama@wat.midco.net>, Alfonso Martinez <Alfonso_VII@hotmail.com>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Programming Language :: Python
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
18
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
19
|
+
Requires-Python: >=3.8
|
|
20
|
+
Requires-Dist: requests
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# CoreDataX
|
|
24
|
+
|
|
25
|
+
Python client for the PSMA's [CoreDataeXchange](https://coredatax.com) — upload and
|
|
26
|
+
read magnetic-core loss measurements.
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install CoreDataX
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Upload
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
from CoreDataX import Client
|
|
36
|
+
|
|
37
|
+
cdx = Client("my-user", "my-password")
|
|
38
|
+
|
|
39
|
+
cdx.upload_csv("measurements.csv") # {'success': True, 'inserted': 120, 'errors': []}
|
|
40
|
+
cdx.upload_cdx("measurements.cdx") # one CDX document, or a list of them
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Or from the command line:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
python -m CoreDataX measurements.csv --username my-user --password my-password
|
|
47
|
+
# or set COREDATAX_USERNAME / COREDATAX_PASSWORD and just:
|
|
48
|
+
python -m CoreDataX measurements.csv
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### CSV format
|
|
52
|
+
|
|
53
|
+
A header row is required. These columns must be present:
|
|
54
|
+
|
|
55
|
+
| column | unit | meaning |
|
|
56
|
+
| --- | --- | --- |
|
|
57
|
+
| `magneticReference` | — | the reference of a magnetic already registered in CoreDataX |
|
|
58
|
+
| `frequency` | Hz | excitation frequency |
|
|
59
|
+
| `magneticFluxDensityPeak` | T | peak flux density |
|
|
60
|
+
| `temperature` | °C | ambient temperature |
|
|
61
|
+
| `volumetricLosses` | W/m³ | measured core losses per unit volume |
|
|
62
|
+
|
|
63
|
+
Optional: `setupReference`, `magneticFieldDcBias` (A/m), `magneticFieldWaveformType`
|
|
64
|
+
(e.g. `Sinusoidal`). Up to 10 000 rows per call. Rows are attributed to the
|
|
65
|
+
authenticated user — a `userId` column is ignored.
|
|
66
|
+
|
|
67
|
+
```csv
|
|
68
|
+
magneticReference,setupReference,frequency,magneticFluxDensityPeak,magneticFieldDcBias,magneticFieldWaveformType,temperature,volumetricLosses
|
|
69
|
+
3C90 --- TX-25-15-10,my-setup,100000,0.1,0,Sinusoidal,25,42000
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
A row the server rejects (unknown magnetic reference, unparseable number) does not
|
|
73
|
+
abort the upload — it comes back in `errors` with its CSV line number, while the
|
|
74
|
+
good rows are stored.
|
|
75
|
+
|
|
76
|
+
## Read
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
cdx.get_data(materials=["3C90"], min_frequency=50e3, max_frequency=500e3, limit=1000)
|
|
80
|
+
cdx.get_materials()
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Errors
|
|
84
|
+
|
|
85
|
+
Every call raises `CoreDataXError` on an HTTP failure — a failed upload never
|
|
86
|
+
looks like a successful one:
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
from CoreDataX import Client, CoreDataXError
|
|
90
|
+
|
|
91
|
+
try:
|
|
92
|
+
Client("my-user", "wrong-password")
|
|
93
|
+
except CoreDataXError as error:
|
|
94
|
+
print(error.status_code, error.detail) # 401 Invalid credentials
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Migrating from 0.9.0
|
|
98
|
+
|
|
99
|
+
0.9.0 talked to `https://coredatax.com:4242/` and authenticated with the account's
|
|
100
|
+
validation-token UUID in the request body. The API now serves over standard HTTPS and
|
|
101
|
+
protects writes with a JWT, so those calls fail with 401 — and 0.9.0 did not check the
|
|
102
|
+
status code, so uploads silently stored nothing.
|
|
103
|
+
|
|
104
|
+
| 0.9.0 | 0.10.0 |
|
|
105
|
+
| --- | --- |
|
|
106
|
+
| `server.insert_data(rows)` | `Client(user, password).insert(record)` |
|
|
107
|
+
| `loader.CsvLoader(token).load("f.csv")` | `Client(user, password).upload_csv("f.csv")` |
|
|
108
|
+
| `python loader.py <token> f.csv` | `python -m CoreDataX f.csv -u <user> -p <password>` |
|
|
109
|
+
|
|
110
|
+
`CsvLoader`/`CdxLoader` still exist as deprecated wrappers, and they now take a
|
|
111
|
+
username and password. The `server` module's functions raise `CoreDataXError`
|
|
112
|
+
explaining the migration rather than failing silently.
|
|
113
|
+
|
|
114
|
+
## License
|
|
115
|
+
|
|
116
|
+
MIT.
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# CoreDataX
|
|
2
|
+
|
|
3
|
+
Python client for the PSMA's [CoreDataeXchange](https://coredatax.com) — upload and
|
|
4
|
+
read magnetic-core loss measurements.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
pip install CoreDataX
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Upload
|
|
11
|
+
|
|
12
|
+
```python
|
|
13
|
+
from CoreDataX import Client
|
|
14
|
+
|
|
15
|
+
cdx = Client("my-user", "my-password")
|
|
16
|
+
|
|
17
|
+
cdx.upload_csv("measurements.csv") # {'success': True, 'inserted': 120, 'errors': []}
|
|
18
|
+
cdx.upload_cdx("measurements.cdx") # one CDX document, or a list of them
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Or from the command line:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
python -m CoreDataX measurements.csv --username my-user --password my-password
|
|
25
|
+
# or set COREDATAX_USERNAME / COREDATAX_PASSWORD and just:
|
|
26
|
+
python -m CoreDataX measurements.csv
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### CSV format
|
|
30
|
+
|
|
31
|
+
A header row is required. These columns must be present:
|
|
32
|
+
|
|
33
|
+
| column | unit | meaning |
|
|
34
|
+
| --- | --- | --- |
|
|
35
|
+
| `magneticReference` | — | the reference of a magnetic already registered in CoreDataX |
|
|
36
|
+
| `frequency` | Hz | excitation frequency |
|
|
37
|
+
| `magneticFluxDensityPeak` | T | peak flux density |
|
|
38
|
+
| `temperature` | °C | ambient temperature |
|
|
39
|
+
| `volumetricLosses` | W/m³ | measured core losses per unit volume |
|
|
40
|
+
|
|
41
|
+
Optional: `setupReference`, `magneticFieldDcBias` (A/m), `magneticFieldWaveformType`
|
|
42
|
+
(e.g. `Sinusoidal`). Up to 10 000 rows per call. Rows are attributed to the
|
|
43
|
+
authenticated user — a `userId` column is ignored.
|
|
44
|
+
|
|
45
|
+
```csv
|
|
46
|
+
magneticReference,setupReference,frequency,magneticFluxDensityPeak,magneticFieldDcBias,magneticFieldWaveformType,temperature,volumetricLosses
|
|
47
|
+
3C90 --- TX-25-15-10,my-setup,100000,0.1,0,Sinusoidal,25,42000
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
A row the server rejects (unknown magnetic reference, unparseable number) does not
|
|
51
|
+
abort the upload — it comes back in `errors` with its CSV line number, while the
|
|
52
|
+
good rows are stored.
|
|
53
|
+
|
|
54
|
+
## Read
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
cdx.get_data(materials=["3C90"], min_frequency=50e3, max_frequency=500e3, limit=1000)
|
|
58
|
+
cdx.get_materials()
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Errors
|
|
62
|
+
|
|
63
|
+
Every call raises `CoreDataXError` on an HTTP failure — a failed upload never
|
|
64
|
+
looks like a successful one:
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
from CoreDataX import Client, CoreDataXError
|
|
68
|
+
|
|
69
|
+
try:
|
|
70
|
+
Client("my-user", "wrong-password")
|
|
71
|
+
except CoreDataXError as error:
|
|
72
|
+
print(error.status_code, error.detail) # 401 Invalid credentials
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Migrating from 0.9.0
|
|
76
|
+
|
|
77
|
+
0.9.0 talked to `https://coredatax.com:4242/` and authenticated with the account's
|
|
78
|
+
validation-token UUID in the request body. The API now serves over standard HTTPS and
|
|
79
|
+
protects writes with a JWT, so those calls fail with 401 — and 0.9.0 did not check the
|
|
80
|
+
status code, so uploads silently stored nothing.
|
|
81
|
+
|
|
82
|
+
| 0.9.0 | 0.10.0 |
|
|
83
|
+
| --- | --- |
|
|
84
|
+
| `server.insert_data(rows)` | `Client(user, password).insert(record)` |
|
|
85
|
+
| `loader.CsvLoader(token).load("f.csv")` | `Client(user, password).upload_csv("f.csv")` |
|
|
86
|
+
| `python loader.py <token> f.csv` | `python -m CoreDataX f.csv -u <user> -p <password>` |
|
|
87
|
+
|
|
88
|
+
`CsvLoader`/`CdxLoader` still exist as deprecated wrappers, and they now take a
|
|
89
|
+
username and password. The `server` module's functions raise `CoreDataXError`
|
|
90
|
+
explaining the migration rather than failing silently.
|
|
91
|
+
|
|
92
|
+
## License
|
|
93
|
+
|
|
94
|
+
MIT.
|