Python functions for Cube projects using cube.py config file.
Project description
Cube Utils
Cube Utils is a Python library for parsing and extracting information from query payloads.
Installation
You can install Cube Utils using pip:
pip install cube-utils
If you are using Cube, just add cube-utils to your requirements.txt file. e.g.
cube-utils
Usage
Here is an example of how to use the extract_cubes and extract_members functions from the cube_utils.query_parser module:
from cube_utils.query_parser import extract_cubes, extract_members
# Example payload
payload = {
"dimensions": ["test_a.city", "test_a.country", "test_a.state"],
"measures": ["test_b.count"],
"filters": [
{"values": ["US"], "member": "test_a.country", "operator": "equals"}
],
"timeDimensions": [
{
"dimension": "test_c.time",
"dateRange": ["2021-01-01", "2021-12-31"],
"granularity": "month",
}
],
}
# Extract cubes
cubes = extract_cubes(payload)
print(cubes) # Output: ['test_a', 'test_b', 'test_c']
# Extract members
members = extract_members(payload)
print(members) # Output: ['test_a.city', 'test_a.country', 'test_a.state', 'test_b.count', 'test_c.time']
Running Tests
To run the tests, use the following command:
python -m unittest discover tests
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cube_utils-0.1.2.tar.gz.
File metadata
- Download URL: cube_utils-0.1.2.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: pdm/2.24.2 CPython/3.13.3 Linux/6.11.0-1015-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf24f0a19f6b09996803bdddf23dad437a122c6046ccdc0e0842bb774c8fd852
|
|
| MD5 |
bf1cf81de620ecfbdd31c89b756acbff
|
|
| BLAKE2b-256 |
27776e10c844cf3bf67d9d098315b4452baafe516dc4ceb46bdddf87891b0348
|
File details
Details for the file cube_utils-0.1.2-py3-none-any.whl.
File metadata
- Download URL: cube_utils-0.1.2-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: pdm/2.24.2 CPython/3.13.3 Linux/6.11.0-1015-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
744a1c3eb1bb8f49c51ed9e18c177bea33d398f2f4c002ede41959040d525c17
|
|
| MD5 |
a0fa79963ae35d421d23d7dc14de71bf
|
|
| BLAKE2b-256 |
cf18eb86e3c414619ffd937352fe4302069ff7672ebb377911db7bcd8bdba4cc
|