Fix get_measure_dimension; add get/set for measure & time dimension (#1412)#1413
Merged
Conversation
get_measure_dimension previously returned the cube's last dimension, on the assumption that the measures dimension is always last. That is not guaranteed - a cube can have its measures dimension assigned to any dimension - so the method could return the wrong dimension. Read the cube's MeasuresDimension navigation property instead, which is available on both v11 and v12 and reflects the actual assignment. When no measures dimension is explicitly assigned, TM1 returns 204 and we fall back to the last dimension (TM1's own default), preserving prior behavior for that case. Also add: - get_time_dimension: reads the TimeDimension nav property (None if unset) - set_measure_dimension / set_time_dimension: bind the nav property via PATCH, validating the dimension belongs to the cube first Note: }CubeProperties (the v11 control cube) is not used, since it does not exist on v12; the navigation-property approach works on both. Tests added and verified live against v11 and v12. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Closed
Collaborator
|
I think we must add In version 11.8.01700.1 The |
The MeasuresDimension and TimeDimension navigation properties are not
exposed before v11.8.018 (confirmed: fails on 11.8.01700.1, works on
11.8.02200.2+). Add @require_version("11.8.018") to get/set_measure_dimension
and get/set_time_dimension so older servers raise a clear version error
instead of failing on the missing endpoint. Docstrings updated accordingly.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1412.
CubeService.get_measure_dimensionreturned the cube's last dimension, assuming the measures dimension is always last. That assumption does not hold — a cube's measures dimension can be assigned to any dimension — so the method could return the wrong dimension (confirmed live:plan_BudgetPlan's measures dimension isplan_business_unit, not its last dimension).This PR reads the cube's
MeasuresDimensionnavigation property instead, which reflects the actual assignment and is available on both v11 and v12. It also adds the matching time-dimension getter and setters for both.Changes
get_measure_dimension— now reads/Cubes('x')/MeasuresDimension. When no measures dimension is explicitly assigned (server returns204), falls back to the last dimension — TM1's own default — preserving prior behavior for that case.get_time_dimension(new) — reads/Cubes('x')/TimeDimension; returnsNonewhen unassigned.set_measure_dimension/set_time_dimension(new) — bind the navigation property viaPATCHusing@odata.bind. Decorated@require_data_adminand validate that the target dimension belongs to the cube (raisingValueErrorotherwise)._validate_dimension_in_cube(new private helper).Testing
5 new tests in
Tests/CubeService_test.py(set+get round-trips for measure & time, the unset-timeNonecase, andValueErroron invalid dimensions). Existingtest_get_measure_dimensionretained.Verified live against both servers in
Tests/config.ini:tm1srv01, 11.8): 6/6 passtm1srv02, PA Engine): 6/6 passBlack and Ruff pass on the changed files.
Note for reviewers
The v12
$metadatamarksMeasuresDimensionwith@Core.Revisions: [{Version: 12.0.0, Kind: Deprecated}]. It is deprecated but currently functional on v12; flagging in case a different long-term endpoint is preferred.