A python module for TM1 Bedrock.
Project description
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:
replacemap_and_replacemap_and_joincartesianpivotunpivotbasic_reshapingcartesian_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
bedrockAPI 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
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 tm1_bedrock_py-1.4.tar.gz.
File metadata
- Download URL: tm1_bedrock_py-1.4.tar.gz
- Upload date:
- Size: 123.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9b120d47322e4e7a8eadcd51e36cd613d988a0790958a47961793886f2d9923
|
|
| MD5 |
75dcd331fd068bfe255522d55e1759d0
|
|
| BLAKE2b-256 |
14ffd97ea42f0977b489e7bc2fd0c1888d927933ab26e2080c0e845d4d648d2c
|
File details
Details for the file tm1_bedrock_py-1.4-py3-none-any.whl.
File metadata
- Download URL: tm1_bedrock_py-1.4-py3-none-any.whl
- Upload date:
- Size: 108.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8aad0133e0633dda5df1bd21177727fe3dd53b4a76c00b433f89e0b299a85cb2
|
|
| MD5 |
7557d7fe9da5e728b6ca64cb5899942c
|
|
| BLAKE2b-256 |
c0e3844ffd912c1143b4723d799f1f3321208bd73056469f7c93618347f50945
|