cdes 1.1.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.
- cdes-1.1.0/PKG-INFO +134 -0
- cdes-1.1.0/README.md +111 -0
- cdes-1.1.0/cdes/__init__.py +112 -0
- cdes-1.1.0/cdes/models.py +425 -0
- cdes-1.1.0/cdes/normalizer.py +81 -0
- cdes-1.1.0/cdes/reference.py +86 -0
- cdes-1.1.0/cdes/telemetry.py +84 -0
- cdes-1.1.0/cdes/validators.py +182 -0
- cdes-1.1.0/cdes.egg-info/PKG-INFO +134 -0
- cdes-1.1.0/cdes.egg-info/SOURCES.txt +13 -0
- cdes-1.1.0/cdes.egg-info/dependency_links.txt +1 -0
- cdes-1.1.0/cdes.egg-info/requires.txt +5 -0
- cdes-1.1.0/cdes.egg-info/top_level.txt +2 -0
- cdes-1.1.0/pyproject.toml +35 -0
- cdes-1.1.0/setup.cfg +4 -0
cdes-1.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cdes
|
|
3
|
+
Version: 1.1.0
|
|
4
|
+
Summary: Cannabis Data Exchange Standard (CDES) Python SDK
|
|
5
|
+
Author-email: Acidni LLC <support@acidni.net>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://cdes.acidni.net
|
|
8
|
+
Project-URL: Repository, https://github.com/Acidni-LLC/cdes-sdk-python
|
|
9
|
+
Keywords: cannabis,data,standard,cdes,terpenes
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
Provides-Extra: dev
|
|
20
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
21
|
+
Requires-Dist: black>=23.0; extra == "dev"
|
|
22
|
+
Requires-Dist: mypy>=1.0; extra == "dev"
|
|
23
|
+
|
|
24
|
+
# CDES Python SDK
|
|
25
|
+
|
|
26
|
+
Official Python SDK for the [Cannabis Data Exchange Standard (CDES)](https://cdes.acidni.net).
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install cdes
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Quick Start
|
|
35
|
+
|
|
36
|
+
### Validate Cannabis Data
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from cdes import validate_strain, validate_terpene_profile
|
|
40
|
+
|
|
41
|
+
# Validate a strain record
|
|
42
|
+
result = validate_strain({
|
|
43
|
+
"id": "blue-dream",
|
|
44
|
+
"name": "Blue Dream",
|
|
45
|
+
"type": "hybrid"
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
if result.valid:
|
|
49
|
+
print(" Strain data is valid!")
|
|
50
|
+
else:
|
|
51
|
+
for error in result.errors:
|
|
52
|
+
print(f" {error.path}: {error.message}")
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Access Reference Data
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from cdes import get_terpene_library, get_terpene_by_id
|
|
59
|
+
|
|
60
|
+
# Get the complete terpene library
|
|
61
|
+
library = get_terpene_library()
|
|
62
|
+
print(f"Library version: {library.version}")
|
|
63
|
+
print(f"Total terpenes: {len(library.terpenes)}")
|
|
64
|
+
|
|
65
|
+
# Look up a specific terpene
|
|
66
|
+
myrcene = get_terpene_by_id("terp-myrcene")
|
|
67
|
+
print(f"{myrcene.name}: CAS {myrcene.casNumber}")
|
|
68
|
+
print(f"Aromas: {', '.join(myrcene.aroma)}")
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Features
|
|
72
|
+
|
|
73
|
+
- **Schema Validation** - Validate strains, COAs, terpene profiles, and cannabinoid profiles
|
|
74
|
+
- **Reference Data** - Access the official CDES terpene library with CAS numbers and effects
|
|
75
|
+
- **Type Safety** - Full type hints and dataclass models
|
|
76
|
+
- **Zero Dependencies** - Pure Python, no external packages required
|
|
77
|
+
|
|
78
|
+
## API Reference
|
|
79
|
+
|
|
80
|
+
### Validators
|
|
81
|
+
|
|
82
|
+
| Function | Description |
|
|
83
|
+
|----------|-------------|
|
|
84
|
+
| `validate_strain(data)` | Validate a strain record |
|
|
85
|
+
| `validate_coa(data)` | Validate a Certificate of Analysis |
|
|
86
|
+
| `validate_terpene_profile(data)` | Validate a terpene profile |
|
|
87
|
+
| `validate_cannabinoid_profile(data)` | Validate a cannabinoid profile |
|
|
88
|
+
|
|
89
|
+
### Reference Data
|
|
90
|
+
|
|
91
|
+
| Function | Description |
|
|
92
|
+
|----------|-------------|
|
|
93
|
+
| `get_terpene_library()` | Get the complete terpene library |
|
|
94
|
+
| `get_terpene_by_id(id)` | Look up a terpene by CDES ID |
|
|
95
|
+
|
|
96
|
+
### Models
|
|
97
|
+
|
|
98
|
+
| Class | Description |
|
|
99
|
+
|-------|-------------|
|
|
100
|
+
| `ValidationResult` | Result of a validation operation |
|
|
101
|
+
| `ValidationError` | A single validation error |
|
|
102
|
+
| `Terpene` | A cannabis terpene |
|
|
103
|
+
| `TerpeneLibrary` | The complete terpene reference |
|
|
104
|
+
|
|
105
|
+
## Development
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# Clone the repository
|
|
109
|
+
git clone https://github.com/Acidni-LLC/cdes-sdk-python.git
|
|
110
|
+
cd cdes-sdk-python
|
|
111
|
+
|
|
112
|
+
# Install dev dependencies
|
|
113
|
+
pip install -e ".[dev]"
|
|
114
|
+
|
|
115
|
+
# Run tests
|
|
116
|
+
pytest
|
|
117
|
+
|
|
118
|
+
# Format code
|
|
119
|
+
black cdes tests
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Related Projects
|
|
123
|
+
|
|
124
|
+
- [cdes-spec](https://github.com/Acidni-LLC/cdes-spec) - JSON Schema specifications
|
|
125
|
+
- [cdes-reference-data](https://github.com/Acidni-LLC/cdes-reference-data) - Reference datasets
|
|
126
|
+
- [cdes-website](https://github.com/Acidni-LLC/cdes-website) - Documentation website
|
|
127
|
+
|
|
128
|
+
## License
|
|
129
|
+
|
|
130
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
131
|
+
|
|
132
|
+
## Maintained By
|
|
133
|
+
|
|
134
|
+
[Acidni LLC](https://acidni.com) - Cannabis Data Analytics & AI Solutions
|
cdes-1.1.0/README.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# CDES Python SDK
|
|
2
|
+
|
|
3
|
+
Official Python SDK for the [Cannabis Data Exchange Standard (CDES)](https://cdes.acidni.net).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install cdes
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
### Validate Cannabis Data
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
from cdes import validate_strain, validate_terpene_profile
|
|
17
|
+
|
|
18
|
+
# Validate a strain record
|
|
19
|
+
result = validate_strain({
|
|
20
|
+
"id": "blue-dream",
|
|
21
|
+
"name": "Blue Dream",
|
|
22
|
+
"type": "hybrid"
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
if result.valid:
|
|
26
|
+
print(" Strain data is valid!")
|
|
27
|
+
else:
|
|
28
|
+
for error in result.errors:
|
|
29
|
+
print(f" {error.path}: {error.message}")
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Access Reference Data
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
from cdes import get_terpene_library, get_terpene_by_id
|
|
36
|
+
|
|
37
|
+
# Get the complete terpene library
|
|
38
|
+
library = get_terpene_library()
|
|
39
|
+
print(f"Library version: {library.version}")
|
|
40
|
+
print(f"Total terpenes: {len(library.terpenes)}")
|
|
41
|
+
|
|
42
|
+
# Look up a specific terpene
|
|
43
|
+
myrcene = get_terpene_by_id("terp-myrcene")
|
|
44
|
+
print(f"{myrcene.name}: CAS {myrcene.casNumber}")
|
|
45
|
+
print(f"Aromas: {', '.join(myrcene.aroma)}")
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Features
|
|
49
|
+
|
|
50
|
+
- **Schema Validation** - Validate strains, COAs, terpene profiles, and cannabinoid profiles
|
|
51
|
+
- **Reference Data** - Access the official CDES terpene library with CAS numbers and effects
|
|
52
|
+
- **Type Safety** - Full type hints and dataclass models
|
|
53
|
+
- **Zero Dependencies** - Pure Python, no external packages required
|
|
54
|
+
|
|
55
|
+
## API Reference
|
|
56
|
+
|
|
57
|
+
### Validators
|
|
58
|
+
|
|
59
|
+
| Function | Description |
|
|
60
|
+
|----------|-------------|
|
|
61
|
+
| `validate_strain(data)` | Validate a strain record |
|
|
62
|
+
| `validate_coa(data)` | Validate a Certificate of Analysis |
|
|
63
|
+
| `validate_terpene_profile(data)` | Validate a terpene profile |
|
|
64
|
+
| `validate_cannabinoid_profile(data)` | Validate a cannabinoid profile |
|
|
65
|
+
|
|
66
|
+
### Reference Data
|
|
67
|
+
|
|
68
|
+
| Function | Description |
|
|
69
|
+
|----------|-------------|
|
|
70
|
+
| `get_terpene_library()` | Get the complete terpene library |
|
|
71
|
+
| `get_terpene_by_id(id)` | Look up a terpene by CDES ID |
|
|
72
|
+
|
|
73
|
+
### Models
|
|
74
|
+
|
|
75
|
+
| Class | Description |
|
|
76
|
+
|-------|-------------|
|
|
77
|
+
| `ValidationResult` | Result of a validation operation |
|
|
78
|
+
| `ValidationError` | A single validation error |
|
|
79
|
+
| `Terpene` | A cannabis terpene |
|
|
80
|
+
| `TerpeneLibrary` | The complete terpene reference |
|
|
81
|
+
|
|
82
|
+
## Development
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# Clone the repository
|
|
86
|
+
git clone https://github.com/Acidni-LLC/cdes-sdk-python.git
|
|
87
|
+
cd cdes-sdk-python
|
|
88
|
+
|
|
89
|
+
# Install dev dependencies
|
|
90
|
+
pip install -e ".[dev]"
|
|
91
|
+
|
|
92
|
+
# Run tests
|
|
93
|
+
pytest
|
|
94
|
+
|
|
95
|
+
# Format code
|
|
96
|
+
black cdes tests
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Related Projects
|
|
100
|
+
|
|
101
|
+
- [cdes-spec](https://github.com/Acidni-LLC/cdes-spec) - JSON Schema specifications
|
|
102
|
+
- [cdes-reference-data](https://github.com/Acidni-LLC/cdes-reference-data) - Reference datasets
|
|
103
|
+
- [cdes-website](https://github.com/Acidni-LLC/cdes-website) - Documentation website
|
|
104
|
+
|
|
105
|
+
## License
|
|
106
|
+
|
|
107
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
108
|
+
|
|
109
|
+
## Maintained By
|
|
110
|
+
|
|
111
|
+
[Acidni LLC](https://acidni.com) - Cannabis Data Analytics & AI Solutions
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
'''
|
|
2
|
+
CDES - Cannabis Data Exchange Standard Python SDK
|
|
3
|
+
|
|
4
|
+
A Python library for working with cannabis data that conforms to the CDES v1.0 specification.
|
|
5
|
+
|
|
6
|
+
Usage:
|
|
7
|
+
from cdes import Strain, StrainType, TerpeneProfile, ProductCategory
|
|
8
|
+
from cdes import normalize_terpene_name, normalize_strain_type
|
|
9
|
+
from cdes import validate_strain, validate_terpene_profile
|
|
10
|
+
'''
|
|
11
|
+
|
|
12
|
+
__version__ = "1.0.0"
|
|
13
|
+
|
|
14
|
+
# Core models
|
|
15
|
+
from .models import (
|
|
16
|
+
StrainType,
|
|
17
|
+
ConcentrationUnit,
|
|
18
|
+
ProductCategory,
|
|
19
|
+
StockLevel,
|
|
20
|
+
ValidationError,
|
|
21
|
+
ValidationResult,
|
|
22
|
+
Concentration,
|
|
23
|
+
TerpeneEntry,
|
|
24
|
+
TerpeneProfile,
|
|
25
|
+
CannabinoidEntry,
|
|
26
|
+
CannabinoidProfile,
|
|
27
|
+
Strain,
|
|
28
|
+
Batch,
|
|
29
|
+
Product,
|
|
30
|
+
FIXED_TERPENE_FIELDS,
|
|
31
|
+
# Legacy compatibility
|
|
32
|
+
Effect,
|
|
33
|
+
BoilingPoint,
|
|
34
|
+
Terpene,
|
|
35
|
+
TerpeneLibrary,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
# Normalizers
|
|
39
|
+
from .normalizer import (
|
|
40
|
+
normalize_terpene_name,
|
|
41
|
+
normalize_cannabinoid_name,
|
|
42
|
+
normalize_strain_type,
|
|
43
|
+
is_known_terpene,
|
|
44
|
+
is_known_cannabinoid,
|
|
45
|
+
TERPENE_ALIASES,
|
|
46
|
+
CANNABINOID_ALIASES,
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
# Validators
|
|
50
|
+
from .validators import (
|
|
51
|
+
validate_strain,
|
|
52
|
+
validate_coa,
|
|
53
|
+
validate_terpene_profile,
|
|
54
|
+
validate_cannabinoid_profile,
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
# Reference data
|
|
58
|
+
from .reference import get_terpene_library, get_terpene_by_id
|
|
59
|
+
|
|
60
|
+
# Telemetry (opt-in tracking)
|
|
61
|
+
from .telemetry import (
|
|
62
|
+
track_event,
|
|
63
|
+
disable_telemetry,
|
|
64
|
+
enable_telemetry,
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
__all__ = [
|
|
68
|
+
# Version
|
|
69
|
+
"__version__",
|
|
70
|
+
# Enums
|
|
71
|
+
"StrainType",
|
|
72
|
+
"ConcentrationUnit",
|
|
73
|
+
"ProductCategory",
|
|
74
|
+
"StockLevel",
|
|
75
|
+
# Models
|
|
76
|
+
"ValidationError",
|
|
77
|
+
"ValidationResult",
|
|
78
|
+
"Concentration",
|
|
79
|
+
"TerpeneEntry",
|
|
80
|
+
"TerpeneProfile",
|
|
81
|
+
"CannabinoidEntry",
|
|
82
|
+
"CannabinoidProfile",
|
|
83
|
+
"Strain",
|
|
84
|
+
"Batch",
|
|
85
|
+
"Product",
|
|
86
|
+
"FIXED_TERPENE_FIELDS",
|
|
87
|
+
# Legacy
|
|
88
|
+
"Effect",
|
|
89
|
+
"BoilingPoint",
|
|
90
|
+
"Terpene",
|
|
91
|
+
"TerpeneLibrary",
|
|
92
|
+
# Normalizers
|
|
93
|
+
"normalize_terpene_name",
|
|
94
|
+
"normalize_cannabinoid_name",
|
|
95
|
+
"normalize_strain_type",
|
|
96
|
+
"is_known_terpene",
|
|
97
|
+
"is_known_cannabinoid",
|
|
98
|
+
"TERPENE_ALIASES",
|
|
99
|
+
"CANNABINOID_ALIASES",
|
|
100
|
+
# Validators
|
|
101
|
+
"validate_strain",
|
|
102
|
+
"validate_coa",
|
|
103
|
+
"validate_terpene_profile",
|
|
104
|
+
"validate_cannabinoid_profile",
|
|
105
|
+
# Reference
|
|
106
|
+
"get_terpene_library",
|
|
107
|
+
"get_terpene_by_id",
|
|
108
|
+
# Telemetry
|
|
109
|
+
"track_event",
|
|
110
|
+
"disable_telemetry",
|
|
111
|
+
"enable_telemetry",
|
|
112
|
+
]
|