Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cube_utils-0.1.3.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cube_utils-0.1.3-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file cube_utils-0.1.3.tar.gz.

File metadata

  • Download URL: cube_utils-0.1.3.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.25.3 CPython/3.13.5 Linux/6.11.0-1015-azure

File hashes

Hashes for cube_utils-0.1.3.tar.gz
Algorithm Hash digest
SHA256 4959800515736dd5f70e026002268ebaf972341bff5763b6500fb25362ecb133
MD5 72b006abe509fb5b4f4bae31f3622d17
BLAKE2b-256 582657d4acb674f0136ae03c4e39dc3011267b30acace23d58bad3740617b133

See more details on using hashes here.

File details

Details for the file cube_utils-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: cube_utils-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.25.3 CPython/3.13.5 Linux/6.11.0-1015-azure

File hashes

Hashes for cube_utils-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a2d8f774e50e5a83d5506d700c6b3184fd712602cc9c92e40c90a5d2f8a205b5
MD5 06f3f932ad71e1817d96c43f05fce0c9
BLAKE2b-256 3e1e7cbfcced66e0aa5aedf78cece906e9db7b8ebf69caff727dd8d35d02daf1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page