-
Notifications
You must be signed in to change notification settings - Fork 118
(Enhancement Proposal) alias infromation from MDX View #1254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
(Enhancement Proposal) alias infromation from MDX View #1254
Conversation
There was a problem hiding this 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, useDict[str, str]
from the typing module which is already imported.
def aliases(self) -> dict[str, str]:
I was not familiar with the I guess it's an optional or new property then!? I will add some more comments to the open review that copilot started |
TM1py/Objects/MDXView.py
Outdated
@@ -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 = {}): |
There was a problem hiding this comment.
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
TM1py/Objects/MDXView.py
Outdated
View.__init__(self, cube_name, view_name) | ||
self._mdx = MDX | ||
self._aliases = Meta.get('Aliases', {}) |
There was a problem hiding this comment.
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]: |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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).
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.