Skip to content

Conversation

Cubewise-JoeCHK
Copy link
Contributor

@Cubewise-JoeCHK Cubewise-JoeCHK commented Jul 26, 2025

TM1 Version: 11.8.02700.4

This proposal comes from the project demands. The process requires to output the dataframe from MDXView. At the meantime, the dataframe shows the alias value regarding MDXView setting instead of Principal Name.

In RestAPI response, there's a Meta information to describe View detail setup, including Aliases. but TM1py doesn't cover it yet.

Future Plans

MDXView enrichment is foreseeable... in the future, we may construct MDXView object with alias information then send back to TM1 for creating view

Caution

due to limitation on development resources, this proposal is only tested in v11, not v12.

@Copilot Copilot AI review requested due to automatic review settings July 26, 2025 11:31
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This enhancement adds alias information support to MDXView objects by extracting and exposing alias metadata from TM1 REST API responses. The change enables users to retrieve alias settings configured in MDX views and access them through a new aliases property.

Key changes:

  • Added Meta parameter to MDXView constructor to handle alias metadata
  • Created aliases property that parses dimension-hierarchy patterns and returns simplified dimension-to-alias mappings
  • Updated ViewService to pass Meta information when creating MDXView instances

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
TM1py/Objects/MDXView.py Added Meta parameter, aliases property with regex parsing, and updated from_dict method
TM1py/Services/ViewService.py Modified get method to pass Meta information from REST response to MDXView constructor
Tests/MDXView_test.py Added unit tests for alias functionality and Meta information handling
Comments suppressed due to low confidence (1)

TM1py/Objects/MDXView.py:28

  • The dict[str, str] syntax requires Python 3.9+. For broader compatibility, use Dict[str, str] from the typing module which is already imported.
    def aliases(self) -> dict[str, str]:

@MariusWirtz
Copy link
Collaborator

I was not familiar with the Meta property in the response of the MDXView!
I can't reproduce it in 11.8.01700.1.

I guess it's an optional or new property then!?
In that case we should make sure all the code works when the property isn't set.

I will add some more comments to the open review that copilot started

@@ -15,13 +15,39 @@ class MDXView(View):
IMPORTANT. MDXViews can't be seen through the old TM1 clients (Archict, Perspectives). They do exist though!
"""

def __init__(self, cube_name: str, view_name: str, MDX: str):
def __init__(self, cube_name: str, view_name: str, MDX: str, Meta: dict = {}):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please name it meta instead of Meta.

Unfortunately, we broke with the Python naming conventions many years ago when we named the other argument MDX instead of mdx, but let's not introduce any more unconventional names

View.__init__(self, cube_name, view_name)
self._mdx = MDX
self._aliases = Meta.get('Aliases', {})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not store the meta as a property in the class? Perhaps there is more interesting stuff in it?


@property
def mdx(self):
return self._mdx

@property
def aliases(self) -> dict[str, str]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would call this alias_by_dimension and then we need a separate one for alias_by_hierarchy

@@ -1,6 +1,9 @@
import unittest

from TM1py import MDXView
from unittest.mock import Mock, patch
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In TM1py, we don't use mocks for tests.
Instead, we define test cases that do real API interactions with TM1. It comes at a price, that running the test suite takes time and you need a real TM1 installation to run tests.

But the benefit of using real API interaction is that we can use the same test suite against different versions of TM1 (e.g. TM1 11 local, PAoC, PAaaS).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants