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.1.tar.gz (3.3 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.1-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cube_utils-0.1.1.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.22.3 CPython/3.13.2 Linux/6.8.0-1021-azure

File hashes

Hashes for cube_utils-0.1.1.tar.gz
Algorithm Hash digest
SHA256 aa6ffc2f3ce40406589fd060ed6428babb80a0db8ba16126aa7466cb312269da
MD5 e85606dc766fc808d8b7ea66040aae6b
BLAKE2b-256 d89ab673c6d8caf5036a35c41cd260fb45a49329f31a6c8ba063f0fa57d6f82e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cube_utils-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.22.3 CPython/3.13.2 Linux/6.8.0-1021-azure

File hashes

Hashes for cube_utils-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 50b1c2a2e74f11606d8545b6698c2f06f36ffa38ac3d8e20d7b5aa1c06ff969c
MD5 546a88d3521391931121a8fc8ea5fe05
BLAKE2b-256 90990894f9e23b0b58570754e31631dc6424351fdc1b0fd573de46ccae5a1196

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