Skip to main content

A python module for TM1 Bedrock.

Project description

Project Banner

TM1 Bedrock for Python

tm1_bedrock_py is a high-level integration toolkit for IBM Planning Analytics (TM1). It builds on TM1py and pandas to move, transform, validate, and load data between TM1 cubes, SQL databases, CSV files, and dimension structures.

The public API lives in TM1_bedrock_py.bedrock.

Main workflows

Need Function
Transform and write data within one cube data_copy
Move data between cubes or TM1 servers data_copy_intercube
Load SQL data into TM1 load_sql_data_to_tm1_cube
Export TM1 data to SQL load_tm1_cube_to_sql_table
Load CSV data into TM1 load_csv_data_to_tm1_cube
Export TM1 data to CSV load_tm1_cube_to_csv_file
Run TM1-sliced work in parallel async_executor_tm1
Export TM1 slices to SQL in parallel async_executor_tm1_to_sql
Load paginated SQL slices in parallel async_executor_sql_to_tm1
Load a directory of CSV files in parallel async_executor_csv_to_tm1
Build or copy cubes and dimensions cube_builder, dimension_builder, dimension_copy
Build one hierarchy hierarchy_builder, hierarchy_build_from_attributes
Export a dimension schema dimension_export
Run a coordinate-domain calculation pipeline input_handler

Installation

pip install tm1-bedrock-py

Airflow integration is optional:

pip install "tm1-bedrock-py[airflow]"

Python 3.9 or newer is required. The current dependency ranges are defined in pyproject.toml.

Quick start

from TM1py import TM1Service
from TM1_bedrock_py import bedrock

source_mdx = """
SELECT
  {[Period].[Period].[2026-01]} ON 0
FROM [Sales]
WHERE ([Version].[Version].[Actual], [Measure].[Measure].[Amount])
"""

with TM1Service(
    address="tm1.example.com",
    port=12354,
    user="svc_bedrock",
    password="...",
    ssl=True,
) as tm1:
    bedrock.data_copy_intercube(
        tm1_service=tm1,
        data_mdx=source_mdx,
        target_cube_name="Sales Reporting",
        target_dim_mapping={"Scenario": "Reported"},
        clear_target=True,
        target_clear_set_mdx_list=[
            "{[Period].[Period].[2026-01]}",
            "{[Scenario].[Scenario].[Reported]}",
        ],
        async_write=True,
        skip_zeros=True,
    )

Transformation arguments such as source_dim_mapping, related_dimensions, and target_dim_mapping are accepted through the wrappers' **kwargs.

Mapping pipeline

mapping_steps is an ordered list. Supported methods are:

  • replace
  • map_and_replace
  • map_and_join
  • cartesian
  • pivot
  • unpivot
  • basic_reshaping
  • cartesian_with_set

Example:

mapping_steps = [
    {
        "method": "replace",
        "mapping": {"Version": {"Working": "Budget"}},
    },
    {
        "method": "basic_reshaping",
        "new_columns_with_values": {"Load Source": "SQL"},
        "column_relabel_map": {"Amount": "Value"},
    },
]

Invalid mapping and calculation configurations fail before execution with field-level validation messages.

Failure behavior

Public bedrock functions preserve the original exception type and traceback while adding operation and safe parameter context. Passwords, tokens, secrets, credentials, API keys, MDX, and SQL query text are redacted or summarized in Bedrock-generated error messages. Parallel executors wait for their workers and raise if any worker failed; partial failures are not reported as success.

SQL and MDX strings are executable configuration. Only use statements from a trusted source.

Documentation

The full guide includes:

  • current function selection and connection examples;
  • complete bedrock API signatures and parameters;
  • TM1, SQL, CSV, async, dimension, and Airflow workflows;
  • mapping, clearing, performance, and error-handling guidance.

Read the hosted documentation at tm1-bedrock-py.readthedocs.io.

Validation scope

The release hardening suite covers public exception boundaries, offline TM1 wrapper orchestration through MockTM1Service, SQL/CSV fixtures, dimension building, async failure propagation, query redaction, rollback, and cleanup. Live TM1 behavior still requires validation against your Planning Analytics environment because authentication, server configuration, privileges, and version-specific REST behavior cannot be reproduced fully offline.

Development

python -m venv .venv
.\.venv\Scripts\activate
pip install -r requirements-dev.txt
pytest
python -m build

The repository may contain tests that require a configured tm1srv connection.

License

Apache-2.0. See LICENSE.

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

tm1_bedrock_py-1.4.1.tar.gz (110.6 kB view details)

Uploaded Source

Built Distribution

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

tm1_bedrock_py-1.4.1-py3-none-any.whl (95.4 kB view details)

Uploaded Python 3

File details

Details for the file tm1_bedrock_py-1.4.1.tar.gz.

File metadata

  • Download URL: tm1_bedrock_py-1.4.1.tar.gz
  • Upload date:
  • Size: 110.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for tm1_bedrock_py-1.4.1.tar.gz
Algorithm Hash digest
SHA256 5798e14d103be7f51d2bb0d0567e2dee99ecdb8b927ac24ecd5ae1918e8e7711
MD5 0f1ada3577f14db3492598e7c1b76c55
BLAKE2b-256 cb1b7e0a71ebe0cbc14bb5847d15ea57afbd510dff2ca197b4eabef45ea8a60a

See more details on using hashes here.

File details

Details for the file tm1_bedrock_py-1.4.1-py3-none-any.whl.

File metadata

  • Download URL: tm1_bedrock_py-1.4.1-py3-none-any.whl
  • Upload date:
  • Size: 95.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for tm1_bedrock_py-1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 78fc3cc3a47a1aa2354aa1588b11d493b1ebc7d94bda8127750676fbfc511516
MD5 cb293eb0386d91516e9febea87fb1a4f
BLAKE2b-256 c895c48c9301e8fb420b4e81759f9e5bd6009595f0942d7785aa4fcaa562d332

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