TM1py Documentation Overview
TM1py Documentation Overview
Release 1.0.2
1 Module contents 1
2 Subpackages 3
2.1 [Link] package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 [Link] package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.3 [Link] package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.4 [Link] package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
i
ii
CHAPTER 1
Module contents
1
TM1py Documentation, Release 1.0.2
Subpackages
2.1.1 Submodules
3
TM1py Documentation, Release 1.0.2
2.2.1 Submodules
4 Chapter 2. Subpackages
TM1py Documentation, Release 1.0.2
body
dimension_name
hierarchy_name
selected
subset
frequency
classmethod from_dict(chore_as_dict)
Alternative constructor
Parameters chore_as_dict – Chore as dict
Returns Chore, an instance of this class
classmethod from_json(chore_as_json)
Alternative constructor
Parameters chore_as_json – string, JSON. Response of
/api/v1/Chores(‘x’)/Tasks?$expand=*
Returns Chore, an instance of this class
name
reschedule(days=0, hours=0, minutes=0, seconds=0)
start_time
tasks
6 Chapter 2. Subpackages
TM1py Documentation, Release 1.0.2
body
body_as_dict
classmethod from_dict(chore_task_as_dict)
parameters
process_name
step
8 Chapter 2. Subpackages
TM1py Documentation, Release 1.0.2
element_attributes
elements
classmethod from_dict(hierarchy_as_dict)
get_element(element_name)
name
remove_edge(parent, component)
remove_edges(edges)
remove_edges_related_to_element(element_name)
remove_element(element_name)
remove_element_attribute(name)
subsets
update_edge(parent, component, weight)
update_element(element_name, element_type=None)
10 Chapter 2. Subpackages
TM1py Documentation, Release 1.0.2
Parameters
• dimension_name – name of the dimension
• subset – instance of [Link]. Can be None instead.
Returns
add_row(dimension_name, subset=None)
Add Dimension or Subset to the row-axis
Parameters
• dimension_name –
• subset – instance of [Link]. Can be None instead.
Returns
add_title(dimension_name, selection, subset=None)
Add subset and element to the titles-axis
Parameters
• dimension_name – name of the dimension.
• selection – name of an element.
• subset – instance of [Link]. Can be None instead.
Returns
as_MDX
Build a valid MDX Query from an Existing cubeview. Takes Zero suppression into account. Throws an
Exception when no elements are place on the columns. Subsets are referenced in the result-MDX through
the TM1SubsetToSet Function
Returns String, the MDX Query
body
columns
format_string
classmethod from_dict(view_as_dict, cube_name=None)
classmethod from_json(view_as_json, cube_name=None)
Alternative constructor :Parameters:
view_as_json : string, JSON
remove_column(dimension_name)
remove dimension from the column axis
Parameters dimension_name –
Returns
remove_row(dimension_name)
remove dimension from the row axis
Parameters dimension_name –
Returns
remove_title(dimension_name)
remove dimension from the titles-axis
Parameters dimension_name – name of the dimension.
Returns
rows
suppress_empty_cells
suppress_empty_columns
suppress_empty_rows
12 Chapter 2. Subpackages
TM1py Documentation, Release 1.0.2
–
• type – ‘String’ or ‘Numeric’
Returns
auto_generated_string = '#****Begin: Generated Statements***\r\n#****End: Generated S
begin_generated_statements = '#****Begin: Generated Statements***'
body
data_procedure
datasource_ascii_decimal_separator
datasource_ascii_delimiter_char
datasource_ascii_delimiter_type
datasource_ascii_header_records
datasource_ascii_quote_character
datasource_ascii_thousand_separator
datasource_data_source_name_for_client
datasource_data_source_name_for_server
datasource_password
datasource_query
datasource_subset
datasource_type
datasource_user_name
datasource_uses_unicode
datasource_view
drop_parameter_types()
end_generated_statements = '#****End: Generated Statements****'
epilog_procedure
classmethod from_dict(process_as_dict)
Parameters process_as_dict – Dictionary, process as dictionary
Returns an instance of this class
classmethod from_json(process_as_json)
Parameters process_as_json – response of /api/v1/Processes(‘x’)?$expand=*
Returns an instance of this class
has_security_access
metadata_procedure
name
parameters
prolog_procedure
remove_parameter(name)
remove_variable(name)
variables
class [Link](rules)
Bases: [Link].TM1Object.TM1Object
Abstraction of Rules on a cube.
rules_analytics A collection of rulestatements, where each statement is stored in uppercase without linebreaks.
comments are not included.
feeder_statements
feedstrings
has_feeders
init_analytics()
keywords = ['SKIPCHECK', 'FEEDSTRINGS', 'UNDEFVALS', 'FEEDERS']
rule_statements
rules_analytics
skipcheck
text
undefvals
class [Link](server_as_dict)
Abstraction of the TM1 Server
Notes contains the information you get from [Link] no methods so far
14 Chapter 2. Subpackages
TM1py Documentation, Release 1.0.2
hierarchy_name
is_dynamic
is_static
name
type
class [Link].TM1Object.TM1Object
Parent Class for all TM1 Objects e.g. Cube, Process, Dimension.
body
add_group(group_name)
body
construct_body()
construct body (json) from the class attributes :return: String, TM1 JSON representation of a user
friendly_name
classmethod from_dict(user_as_dict)
Alternative constructor
Parameters user_as_dict – user as dict
Returns user, an instance of this class
classmethod from_json(user_as_json)
Alternative constructor
Parameters user_as_json – user as JSON string
Returns user, an instance of this class
groups
is_admin
name
password
remove_group(group_name)
2.3.1 Submodules
class [Link](rest)
Bases: [Link]
Service to handle Object Updates for TM1 CellAnnotations
create(annotation)
create an Annotation
16 Chapter 2. Subpackages
TM1py Documentation, Release 1.0.2
class [Link](tm1_rest)
Service to Read and Write TM1 Applications
get(path)
Get Excel Application from TM1 Server in binary format. Can be dumped to file.
Parameters path – path through folder structur to application. For instance: “Fi-
nance/P&[Link]”
Returns
Return application as binary. Can be dumped to file: with open(“[Link]”, “wb”) as out:
[Link](content)
class [Link](tm1_rest)
Service to handle Read and Write operations to TM1 cubes
activate_transactionlog(*args)
Activate Transactionlog for one or many cubes
Parameters args – one or many cube names
Returns
create_cellset(mdx)
Execute MDX in order to create cellset at server. return the cellset-id
Parameters mdx – MDX Query, as string
Returns
create_cellset_from_view(cube_name, view_name, private)
deactivate_transactionlog(*args)
Deacctivate Transactionlog for one or many cubes
Parameters args – one or many cube names
Returns
delete_cellset(cellset_id)
Delete a cellset
Parameters cellset_id –
Returns
execute_mdx(mdx, cell_properties=None, top=None, skip_contexts=False)
Execute MDX and return the cells with their properties
Parameters
• mdx – MDX Query, as string
• cell_properties – properties to be queried from the cell. E.g. Value, Ordinal,
RuleDerived, . . .
• top – integer
• skip_contexts – skip elements from titles / contexts in response
Returns content in sweet concise structure.
execute_mdx_cellcount(mdx)
Execute MDX in order to understand how many cells are in a cellset. Only return number of cells in the
cellset. FAST!
Parameters mdx – MDX Query, as string
Returns Number of Cells in the CellSet
execute_mdx_csv(mdx)
Optimized for performance. Get csv string of coordinates and values. Context dimensions are omitted !
Cells with Zero/null are omitted !
Parameters mdx – Valid MDX Query
Returns String
execute_mdx_dataframe(mdx)
Optimized for performance. Get Pandas DataFrame from MDX Query. Context dimensions are omitted in
the resulting Dataframe ! Cells with Zero/null are omitted !
Parameters mdx – Valid MDX Query
Returns Pandas Dataframe
execute_mdx_dataframe_pivot(mdx, dropna=False, fill_value=None)
Execute MDX Query to get a pandas pivot dataframe in the shape as specified in the Query
Parameters
18 Chapter 2. Subpackages
TM1py Documentation, Release 1.0.2
• mdx –
• dropna –
• fill_value –
Returns
execute_mdx_raw(mdx, cell_properties=None, elem_properties=None, member_properties=None,
top=None, skip_contexts=False)
Execute MDX and return the raw data from TM1
Parameters
• mdx – String, a valid MDX Query
• cell_properties – List of properties to be queried from the cell. E.g. [‘Value’,
‘Ordinal’, ‘RuleDerived’, . . . ]
• elem_properties – List of properties to be queried from the elements. E.g. [‘Unique-
Name’,’Attributes’, . . . ]
• member_properties – List of properties to be queried from the members. E.g.
[‘UniqueName’,’Attributes’, . . . ]
• top – Integer limiting the number of cells and the number or rows returned
• skip_contexts – skip elements from titles / contexts in response
Returns Raw format from TM1.
execute_mdx_rows_and_values(mdx, element_unique_names=True)
execute_mdx_ui_array(mdx, elem_properties=None, member_properties=None,
value_precision=2, top=None)
Useful for grids or charting libraries that want an array of cell values per row. Returns 3-dimensional cell
structure for tabbed grids or multiple charts. Rows and pages are dicts, addressable by their name. Proper
order of rows can be obtained in headers[1] Example ‘cells’ return format:
‘cells’: {
‘10100’: {
‘Net Operating Income’: [ 19832724.72429739, 20365654.788303416,
20729201.329183243, 20480205.20121749],
‘Revenue’: [ 28981046.50724231, 29512482.207418434, 29913730.038971487,
29563345.9542385]},
‘10200’: {
‘Net Operating Income’: [ 9853293.623709997, 10277650.763958748,
10466934.096533755, 10333095.839474997],
‘Revenue’: [ 13888143.710000003, 14300216.43, 14502421.63,
14321501.940000001]}
},
Parameters
• top –
• mdx – a valid MDX Query
• elem_properties – List of properties to be queried from the elements. E.g. [‘Unique-
Name’,’Attributes’, . . . ]
Parameters
• top –
• mdx – String, valid MDX Query
• elem_properties – List of properties to be queried from the elements. E.g. [‘Unique-
Name’,’Attributes’, . . . ]
• member_properties – List of properties to be queried from the members. E.g.
[‘UniqueName’,’Attributes’, . . . ]
• value_precision – Integer (optional) specifying number of decimal places to return
Returns dict : { titles: [], headers: [axis][], cells: { Page0: [ [column name, column values], [],
. . . ], . . . } }
execute_mdx_values(mdx)
Optimized for performance. Query only raw cell values. Coordinates are omitted !
Parameters mdx – a valid MDX Query
Returns Generator of cell values
execute_view(cube_name, view_name, cell_properties=None, private=True, top=None,
skip_contexts=False)
get view content as dictionary with sweet and concise structure. Works on NativeView and
MDXView !
Parameters
• cube_name – String
• view_name – String
• cell_properties – List, cell properties: [Values, Status, HasPicklist, etc.]
20 Chapter 2. Subpackages
TM1py Documentation, Release 1.0.2
• private – Boolean
• top – Int, number of cells to return (counting from top)
• skip_contexts – skip elements from titles / contexts in response
Returns Dictionary : {([dim1].[elem1], [dim2][elem6]): {‘Value’:3127.312, ‘Ordinal’:12} . . . .
}
Parameters
• top –
• cube_name – cube name
• view_name – view name
• private – True (private) or False (public)
• elem_properties – List of properties to be queried from the elements. E.g. [‘Unique-
Name’,’Attributes’, . . . ]
• member_properties – List properties to be queried from the member. E.g. [‘Name’,
‘UniqueName’]
• value_precision – Integer (optional) specifying number of decimal places to return
Returns dict : { titles: [], headers: [axis][], cells: { Page0: { Row0: { [row values], Row1: [],
. . . }, . . . }, . . . } }
22 Chapter 2. Subpackages
TM1py Documentation, Release 1.0.2
Parameters
• top –
• cube_name – cube name
• view_name – view name
• private – True (private) or False (public)
• elem_properties – List of properties to be queried from the elements. E.g. [‘Unique-
Name’,’Attributes’, . . . ]
• member_properties – List of properties to be queried from the members. E.g.
[‘UniqueName’,’Attributes’, . . . ]
• value_precision – number decimals
Returns
24 Chapter 2. Subpackages
TM1py Documentation, Release 1.0.2
class [Link](rest)
Bases: [Link]
Service to handle Object Updates for TM1 Chores
activate(chore_name)
activate chore on TM1 Server
Parameters chore_name –
Returns response
create(chore)
create chore in TM1
Parameters chore – instance of [Link]
Returns
deactivate(chore_name)
deactivate chore on TM1 Server
Parameters chore_name –
Returns response
26 Chapter 2. Subpackages
TM1py Documentation, Release 1.0.2
delete(chore_name)
delete chore in TM1
Parameters chore_name –
Returns response
execute_chore(chore_name)
Ask TM1 Server to execute a chore
Parameters chore_name – String, name of the chore to be executed
Returns the response
exists(chore_name)
Check if Chore exists
Parameters chore_name –
Returns
get(chore_name)
Get a chore from the TM1 Server
Parameters chore_name –
Returns instance of [Link]
get_all()
get a List of all Chores
Returns List of [Link]
get_all_names()
get a List of all Chores
Returns List of [Link]
set_local_start_time(chore_name, date_time)
Makes Server crash if chore is activate (10.2.2 FP6) :)
Parameters
• chore_name –
• date_time –
Returns
update(chore)
update chore on TM1 Server
does not update: DST Sensitivity! :param chore: :return: response
[Link].deactivate_activate(func)
Higher Order function to handle activation and deactivation of chores before updating them
Parameters func –
Returns
class [Link](rest)
Bases: [Link]
28 Chapter 2. Subpackages
TM1py Documentation, Release 1.0.2
get_storage_dimension_order(cube_name)
Get the storage dimension order of a cube
Parameters cube_name –
Returns List of dimension names
update(cube)
Update existing cube on TM1 Server
Parameters cube – instance of [Link]
Returns response
update_storage_dimension_order(cube_name, dimension_names)
Update the storage dimension order of a cube
Parameters
• cube_name –
• dimension_names –
Returns
class [Link](rest)
Bases: [Link]
Service to handle Object Updates for TM1 Dimensions
create(dimension)
Create a dimension
Parameters dimension – instance of [Link]
Returns response
create_element_attributes_through_ti(dimension)
:param dimension. Instance of [Link] class :return:
delete(dimension_name)
Delete a dimension
Parameters dimension_name – Name of the dimension
Returns
execute_mdx(dimension_name, mdx)
Execute MDX against Dimension. Requires }ElementAttributes_ Cube of the dimension to exist !
Parameters
• dimension_name – Name of the Dimension
• mdx – valid Dimension-MDX Statement
Returns List of Element names
exists(dimension_name)
Check if dimension exists
Returns
get(dimension_name)
Get a Dimension
Parameters dimension_name –
Returns
get_all_names()
Ask TM1 Server for list with all dimension names
Returns List of Strings
update(dimension)
Update an existing dimension
Parameters dimension – instance of [Link]
Returns None
class [Link](rest)
Bases: [Link]
Service to handle Object Updates for TM1 Dimension (resp. Hierarchy) Elements
create(dimension_name, hierarchy_name, element)
create_element_attribute(dimension_name, hierarchy_name, element_attribute)
like AttrInsert
Parameters
• dimension_name –
• hierarchy_name –
• element_attribute – instance of [Link]
Returns
delete(dimension_name, hierarchy_name, element_name)
delete_element_attribute(dimension_name, hierarchy_name, element_attribute)
like AttrDelete
Parameters
• dimension_name –
• hierarchy_name –
• element_attribute – instance of [Link]
Returns
exists(dimension_name, hierarchy_name, element_name)
get(dimension_name, hierarchy_name, element_name)
get_element_attributes(dimension_name, hierarchy_name)
Get element attributes from hierarchy
Parameters
• dimension_name –
30 Chapter 2. Subpackages
TM1py Documentation, Release 1.0.2
• hierarchy_name –
Returns
get_element_names(dimension_name, hierarchy_name)
Get all elementnames
Parameters
• dimension_name –
• hierarchy_name –
Returns Generator of element-names
get_elements(dimension_name, hierarchy_name)
get_elements_filtered_by_attribute(dimension_name, hierarchy_name, attribute_name,
attribute_value)
Get all elements from a hierarchy with given attribute value
Parameters
• dimension_name –
• hierarchy_name –
• attribute_name –
• attribute_value –
Returns List of element names
get_leaf_element_names(dimension_name, hierarchy_name)
get_leaf_elements(dimension_name, hierarchy_name)
get_leaves_under_consolidation(dimension_name, hierarchy_name, consolidation,
max_depth=None)
Get all leaves under a consolidated element
Parameters
• dimension_name – name of dimension
• hierarchy_name – name of hierarchy
• consolidation – name of consolidated Element
• max_depth – 99 if not passed
Returns
get_members_under_consolidation(dimension_name, hierarchy_name, consolidation,
max_depth=None, leaves_only=False)
Get all members under a consolidated element
Parameters
• dimension_name – name of dimension
• hierarchy_name – name of hierarchy
• consolidation – name of consolidated Element
• max_depth – 99 if not passed
• leaves_only – Only Leaf Elements or all Elements
Returns
class [Link](rest)
Bases: [Link]
Service to handle Object Updates for TM1 Hierarchies
EDGES_WORKAROUND_VERSIONS = ('11.0.002', '11.0.003', '11.1.000')
create(hierarchy)
Create a hierarchy in an existing dimension
Parameters hierarchy –
Returns
delete(dimension_name, hierarchy_name)
exists(dimension_name, hierarchy_name)
Parameters
• dimension_name –
• hierarchy_name –
Returns
get(dimension_name, hierarchy_name)
get hierarchy
Parameters
• dimension_name – name of the dimension
• hierarchy_name – name of the hierarchy
Returns
get_all_names(dimension_name)
get all names of existing Hierarchies in a dimension
Parameters dimension_name –
Returns
get_default_member(dimension_name, hierarchy_name=None)
Get the defined default_member for a Hierarchy. Will return the element with index 1, if default member
is not specified explicitly in }HierarchyProperty Cube
Parameters
• dimension_name –
• hierarchy_name –
Returns String, name of Member
get_hierarchy_summary(dimension_name, hierarchy_name)
update(hierarchy)
update a hierarchy. It’s a two step process: 1. Update Hierarchy 2. Update Element-Attributes
Function caters for Bug with Edge Creation: [Link]
html/topic?id=75f2b99e-6961-4c71-9364-1d5e1e083eff
32 Chapter 2. Subpackages
TM1py Documentation, Release 1.0.2
class [Link](rest)
Bases: [Link]
Service to Query and Cancel Threads in TM1
cancel_thread(thread_id)
Kill a running thread
Parameters thread_id –
Returns
disconnect_user(user_name)
Disconnect User
Parameters user_name –
Returns
get_active_users()
Get the activate users in TM1
Returns List of [Link] instances
get_threads()
Return a dict of the currently running threads from the TM1 Server
Returns dict: the response
user_is_active(user_name)
Check if user is currently active in TM1
Parameters user_name –
Returns Boolean
class [Link](rest_service)
Parentclass for all Object Services
determine_actual_object_name(object_class, object_name)
version
class [Link](rest)
Bases: [Link]
Service to handle Object Updates for TI Processes
compile(name)
Compile a Process. Return List of Syntax errors.
Parameters name –
Returns
create(process)
Create a new process on TM1 Server
Parameters process – Instance of [Link] class
Returns Response
delete(name)
Delete a process in TM1
Parameters name –
Returns Response
execute(process_name, parameters=None, **kwargs)
Ask TM1 Server to execute a process. Call with parameter names as keyword arguments:
[Link](“[Link]”, pLegalEntity=”UK01”)
Parameters
• process_name –
• parameters – Deprecated! dictionary, e.g. {“Parameters”: [ { “Name”: “pLegalEn-
tity”, “Value”: “UK01” }] }
Returns
execute_ti_code(lines_prolog, lines_epilog=None)
Execute lines of code on the TM1 Server
Parameters
• lines_prolog – list - where each element is a valid statement of TI code.
• lines_epilog – list - where each element is a valid statement of TI code.
execute_with_return(process_name, **kwargs)
Ask TM1 Server to execute a process. pass process parameters as keyword arguments to this function.
E.g:
[Link].execute_with_return( process_name=”[Link]”, pWaitSec=2)
Parameters
• process_name – name of the TI process
• kwargs – names of process parameters
Returns success (boolean), status (String), error_log_file (String)
exists(name)
Check if Process exists.
34 Chapter 2. Subpackages
TM1py Documentation, Release 1.0.2
Parameters name –
Returns
get(name_process)
Get a process from TM1 Server
Parameters name_process –
Returns Instance of the [Link]
get_all()
Get a processes from TM1 Server
Returns List, instances of the [Link]
get_all_names()
Get List with all process names from TM1 Server
Returns List of Strings
get_all_process_names_filtered()
Get List with all process names from TM1 Server.
Does not return:
• system process
• Processes that have Subset as Datasource
get_error_log_file_content(file_name)
Get content of error log file (e.g. TM1ProcessError_20180926213819_65708356_979b248b-
[Link])
Parameters file_name – name of the error log file in the TM1 log directory
Returns String, content of the file
get_last_message_from_processerrorlog(process_name)
Get the latest ProcessErrorLog from a process entity
Parameters process_name – name of the process
Returns String - the errorlog, e.g.: “Fehler: Prolog Prozedurzeile (9): Zeichenfolge “US772131
kann nicht in eine reelle Zahl umgewandelt werden.”
get_processerrorlogs(process_name)
Get all ProcessErrorLog entries for a process
Parameters process_name – name of the process
Returns list - Collection of ProcessErrorLogs
update(process)
Update an existing Process on TM1 Server
Parameters process – Instance of [Link] class
Returns Response
class [Link](**kwargs)
Low level communication with TM1 instance through HTTP. Allows to execute HTTP Methods
• GET
• POST
• PATCH
• DELETE
Takes Care of
• Encodings
• TM1 User-Login
• HTTP Headers
• HTTP Session Management
• Response Handling
36 Chapter 2. Subpackages
TM1py Documentation, Release 1.0.2
class [Link](rest)
Bases: [Link]
Service to handle Security stuff
add_user_to_groups(user_name, groups)
Parameters
• user_name – name of user
38 Chapter 2. Subpackages
TM1py Documentation, Release 1.0.2
class [Link](rest)
Bases: [Link]
Service to query common information from the TM1 Server
execute_message_log_delta_request(*args, **kwargs)
execute_transaction_log_delta_request(*args, **kwargs)
get_active_configuration()
Read current effective(!) TM1 config settings as dictionary from TM1 Server
Returns config as dictionary
get_admin_host()
get_configuration()
get_data_directory()
get_last_process_message_from_messagelog(process_name)
Get the latest messagelog entry for a process
Parameters process_name – name of the process
Returns String - the message, for instance: “Ausführung normal beendet, verstrichene Zeit 0.03
Sekunden”
get_message_log_entries(reverse=True, top=None)
get_product_version()
Ask TM1 Server for its version
Returns String, the version
get_server_name()
Ask TM1 Server for its name
Returns String, the server name
get_static_configuration()
Read current applied (!) TM1 config settings as dictionary from TM1 Server
Returns config as dictionary
get_transaction_log_entries(reverse=True, user=None, cube=None, since=None,
top=None)
Parameters
• reverse –
• user –
• cube –
• since – of type datetime. If it doesn’t have tz information, UTC is assumed.
• top –
Returns
initialize_message_log_delta_requests(*args, **kwargs)
initialize_transaction_log_delta_requests(*args, **kwargs)
save_data()
update_static_configuration(configuration)
Update the .cfg file and triggers TM1 to re-read the file.
Parameters configuration –
Returns Response
[Link].odata_track_changes_header(func)
Higher Order function to handle addition and removal of [Link]-changes HTTP Header
Parameters func –
Returns
class [Link](rest)
Bases: [Link]
Service to handle Object Updates for TM1 Subsets (dynamic and static)
create(subset, private=True)
create subset on the TM1 Server
Parameters
• subset – [Link], the subset that shall be created
• private – boolean
40 Chapter 2. Subpackages
TM1py Documentation, Release 1.0.2
• private – Boolean
Returns response
class [Link].TM1Service.TM1Service(**kwargs)
All features of TM1py are exposed through this service
Can be saved and restored from File, to avoid multiple authentication with TM1.
connection
logout()
classmethod restore_from_file(file_name)
save_to_file(file_name)
version
whoami
class [Link](rest)
Bases: [Link]
Service to handle Object Updates for cube views (NativeViews and MDXViews)
create(view, private=True)
create a new view on TM1 Server
Parameters
• view – instance of subclass of [Link] ([Link] or [Link])
• private – boolean
Returns Response
delete(cube_name, view_name, private=True)
Delete an existing view (MDXView or NativeView) on the TM1 Server
Parameters
• cube_name – String, name of the cube
• view_name – String, name of the view
• private – Boolean
Returns String, the response
exists(cube_name, view_name, private=None)
Checks if view exists as private, public or both
Parameters
• cube_name – string, name of the cube
• view_name – string, name of the view
• private – boolean, if None: check for private and public
42 Chapter 2. Subpackages
TM1py Documentation, Release 1.0.2
2.4.1 Submodules
44 Chapter 2. Subpackages
TM1py Documentation, Release 1.0.2
[Link].read_dimension_composition_from_mdx_set(mdx)
[Link].read_dimension_composition_from_mdx_set_or_tuple(mdx)
[Link].read_dimension_composition_from_mdx_tuple(mdx)
[Link].split_mdx(mdx)
[Link].generate_unique_string(code)
[Link].get_all_defined_variables(code)
[Link].obfuscate_code(code, variable_mapping, unique_string)
[Link].obfuscate_process(process, new_name=None)
[Link].remove_comment_lines(code)
[Link].remove_generated_code(code)
Remove The generated code lines that are in between # *** comments
Parameters code –
Returns
[Link].split_into_statements(code)
code from one Tab. Code String must come Without Comment-lines !
Parameters code –
Returns
add(value)
Add an element.
copy()
discard(value)
Remove an element. Do not raise an exception if absent.
class [Link](data=None, **kwargs)
Bases: _abcoll.MutableMapping
A case-and-space-insensitive dict-like object with String-Tuples Keys.
Implements all methods and operations of [Link] as well as dict’s copy. Also
provides adjusted_items, adjusted_keys.
All keys are expected to be tuples of strings. The structure remembers the case of the last key to be set, and
iter(instance), keys(), items(), iterkeys(), and iteritems() will contain case-sensitive
keys.
However, querying and contains testing is case insensitive: data = CaseAndSpaceInsensitiveTuplesDict()
data[(‘[Business Unit].[UK]’, ‘[Scenario].[Worst Case]’)] = 1000 data[(‘[BusinessUnit].[UK]’, ‘[Sce-
nario].[worstcase]’)] == 1000 # True data[(‘[Business Unit].[UK]’, ‘[Scenario].[Worst Case]’)] == 1000 #
True
Entries are ordered
adjusted_items()
Like iteritems(), but with all adjusted keys.
adjusted_keys()
Like keys(), but with all adjusted keys.
copy()
[Link].build_cellset_from_pandas_dataframe(df )
Parameters df – a Pandas Dataframe, with dimension-column mapping in correct order. As created
in build_pandas_dataframe_from_cellset
Returns a CaseAndSpaceInsensitiveTuplesDict
[Link].build_content_from_cellset(raw_cellset_as_dict, top=None)
transform raw cellset data into concise dictionary
Parameters
• raw_cellset_as_dict –
• top – Maximum Number of cells
Returns
[Link].build_element_unique_names(dimension_names, element_names, hierar-
chy_names=None)
Create tuple of unique names from dimension, hierarchy and elements
Parameters
• dimension_names –
• element_names –
• hierarchy_names –
Returns Generator
46 Chapter 2. Subpackages
TM1py Documentation, Release 1.0.2
[Link].build_headers_from_cellset(raw_cellset_as_dict,
force_header_dimensionality=1)
Extract dimension headers from cellset into dictionary of titles (slicers) and headers (row,column,page) * Title
dimensions are in a single list of dicts * Header dimensions are a 2-dimensional list of the element dicts
• The first dimension in the header list is the axis
• The second dimension is the list of elements on the axis
• Dict format: {‘name’: ‘element or compound name’, ‘members’: [ {dict of dimension properties}, . . . ] }
– Stacked headers on an axis will have a compount ‘name’ created by joining the member’s ‘Name’
properties with a ‘/’
– Stacked headers will each be listed in the ‘memebers’ list; Single-element headers will only have one
element in list
Parameters
• raw_cellset_as_dict – raw data from TM1
• force_header_dimensionality – An optional integer (1,2 or 3) to force headers
array to be at least that long
Returns dict : { titles: [ { ‘name’: ‘xx’, ‘members’: {} } ], headers: [axis][ { ‘name’: ‘xx’,
‘members’: {} } ] }
[Link].build_pandas_dataframe_from_cellset(cellset, multiindex=True,
sort_values=True)
Parameters
• cellset –
• multiindex – True or False
• sort_values – Boolean to control sorting in result DataFrame
Returns
[Link].build_ui_arrays_from_cellset(raw_cellset_as_dict, value_precision)
Transform raw 1,2 or 3-dimension cellset data into concise dictionary
• Useful for grids or charting libraries that want an array of cell values per row
• Returns 3-dimensional cell structure for tabbed grids or multiple charts
• Rows and pages are dicts, addressable by their name. Proper order of rows can be obtained in headers[1]
• Example ‘cells’ return format:
‘cells’: {
‘10100’: {
‘Net Operating Income’: [ 19832724.72429739, 20365654.788303416,
20729201.329183243, 20480205.20121749],
‘Revenue’: [ 28981046.50724231, 29512482.207418434, 29913730.038971487,
29563345.9542385]},
‘10200’: {
‘Net Operating Income’: [ 9853293.623709997, 10277650.763958748,
10466934.096533755, 10333095.839474997],
Parameters
• raw_cellset_as_dict – raw data from TM1
• value_precision – Integer (optional) specifying number of decimal places to return
Returns dict : { titles: [], headers: [axis][], cells: { Page0: { Row0: { [row values], Row1: [], . . . },
. . . }, . . . } }
[Link].build_ui_dygraph_arrays_from_cellset(raw_cellset_as_dict,
value_precision=None)
Transform raw 1,2 or 3-dimension cellset data into dygraph-friendly format
• Useful for grids or charting libraries that want an array of cell values per column
• Returns 3-dimensional cell structure for tabbed grids or multiple charts
• Example ‘cells’ return format:
‘cells’: {
‘10100’: [ [‘Q1-2004’, 28981046.50724231, 19832724.72429739], [‘Q2-2004’,
29512482.207418434, 20365654.788303416], [‘Q3-2004’, 29913730.038971487,
20729201.329183243], [‘Q4-2004’, 29563345.9542385, 20480205.20121749]],
‘10200’: [ [‘Q1-2004’, 13888143.710000003, 9853293.623709997], [‘Q2-2004’, 14300216.43,
10277650.763958748], [‘Q3-2004’, 14502421.63, 10466934.096533755], [‘Q4-2004’,
14321501.940000001, 10333095.839474997]]
},
Parameters
• raw_cellset_as_dict – raw data from TM1
• value_precision – Integer (optional) specifying number of decimal places to return
Returns dict : { titles: [], headers: [axis][], cells: { Page0: [ [column name, column values], [], . . .
], . . . } }
[Link].case_and_space_insensitive_equals(item1, item2)
[Link].dimension_hierarchy_element_tuple_from_unique_name(element_unique_name)
Extract dimension name, hierarchy name and element name from element unique name. Works with explicit
and implicit hierarchy references.
Parameters element_unique_name – e.g. [d1].[e1] or [d1].[leaves].[e1]
Returns tuple of dimension name, hierarchy name, element name
[Link].dimension_name_from_element_unique_name(element_unique_name)
[Link].element_name_from_element_unique_name(element_unique_name)
[Link].element_names_from_element_unique_names(element_unique_names)
Get tuple of simple element names from the full element unique names
Parameters element_unique_names – tuple of element unique names
([dim1].[hier1].[elem1], . . . )
Returns tuple of element names: (elem1, elem2, . . . )
48 Chapter 2. Subpackages
TM1py Documentation, Release 1.0.2
[Link].element_names_from_element_unqiue_names(element_unique_names)
Get tuple of simple element names from the full element unique names
Parameters element_unique_names – tuple of element unique names
([dim1].[hier1].[elem1], . . . )
Returns tuple of element names: (elem1, elem2, . . . )
[Link].extract_axes_from_cellset(raw_cellset_as_dict)
[Link].extract_unique_names_from_members(members)
Extract list of unique names from part of the cellset response in: [{‘UniqueName’: ‘[dim1].[dim1].[elem1]’,
‘Element’: {‘UniqueName’: ‘[dim1].[dim1].[elem1]’}}, {‘UniqueName’: ‘[dim2].[dim2].[elem3]’, ‘Element’:
{‘UniqueName’: ‘[dim2].[dim2].[elem3]’}}] out: [“[dim1].[dim1].[elem1]”, “[dim2].[dim2].[elem3]”]
Parameters members – dictionary
Returns list of unique names
[Link].get_all_servers_from_adminhost(adminhost=’localhost’)
Ask Adminhost for TM1 Servers
Parameters adminhost – IP or DNS Alias of the adminhost
Returns List of Servers (instances of the [Link] class)
[Link].hierarchy_name_from_element_unique_name(element_unique_name)
[Link].load_all_bedrocks_from_github()
Load all Bedrocks from GitHub as [Link] instances
Returns
[Link].load_bedrock_from_github(bedrock_process_name)
Load bedrock from GitHub as [Link] instance
Parameters bedrock_process_name –
Returns
[Link].lower_and_drop_spaces(item)
[Link].sort_coordinates(cube_dimensions, unsorted_coordinates)
50 Chapter 2. Subpackages
Python Module Index
t [Link], 37
TM1py, 1 [Link], 39
[Link], 4 [Link], 40
[Link], 3 [Link].TM1Service, 42
[Link], 16 [Link], 42
[Link], 4 [Link], 49
[Link], 5 [Link], 44
[Link], 5 [Link], 45
[Link], 5 [Link], 45
[Link], 6
[Link], 6
[Link], 7
[Link], 7
[Link], 8
[Link], 8
[Link], 9
[Link], 9
[Link], 10
[Link], 10
[Link], 12
[Link], 14
[Link], 14
[Link], 14
[Link].TM1Object, 15
[Link], 15
[Link], 16
[Link], 44
[Link], 16
[Link], 17
[Link], 17
[Link], 26
[Link], 27
[Link], 29
[Link], 30
[Link], 32
[Link], 33
[Link], 33
[Link], 34
[Link], 36
51
TM1py Documentation, Release 1.0.2
A add_user_to_groups()
activate() ([Link] method), 5 ([Link]
activate() ([Link] method), 37
method), 26 add_variable() ([Link]
activate_transactionlog() method), 12
([Link] adjusted_items() ([Link]
method), 17 method), 45
active ([Link] attribute), 5 adjusted_items() ([Link]
add() ([Link] method), 46
method), 6 adjusted_keys() ([Link]
add() ([Link] method), 45
method), 45 adjusted_keys() ([Link]
add_column() ([Link] method), 46
method), 10 alias ([Link] attribute), 15
add_edge() ([Link] Annotation (class in [Link]), 4
method), 9 AnnotationService (class in
add_element() ([Link] [Link]), 16
method), 9 AnonymousSubset (class in [Link]),
add_element_attribute() 14
([Link] method), Application (class in [Link]), 5
9 ApplicationService (class in
add_elements() ([Link] [Link]), 17
method), 15 as_MDX ([Link] at-
add_generated_string_to_code() tribute), 11
([Link] static attribute_type ([Link]
method), 12 attribute), 9
add_group() ([Link] method), 15 auto_generated_string
add_hierarchy() ([Link] ([Link] attribute), 13
method), 8
add_http_header() B
([Link] b64_decode_password()
method), 37 ([Link]
add_parameter() ([Link] static method), 37
method), 12 balanced ([Link] at-
add_row() ([Link] tribute), 9
method), 11 begin_generated_statements
add_task() ([Link] method), 5 ([Link] attribute), 13
add_title() ([Link] body ([Link] attribute),
method), 11 4
53
TM1py Documentation, Release 1.0.2
54 Index
TM1py Documentation, Release 1.0.2
method), 28 datasource_data_source_name_for_server
create() ([Link] ([Link] attribute), 13
method), 29 datasource_password
create() ([Link] ([Link] attribute), 13
method), 30 datasource_query ([Link]
create() ([Link] attribute), 13
method), 32 datasource_subset
create() ([Link] ([Link] attribute), 13
method), 34 datasource_type ([Link]
create() ([Link] attribute), 13
method), 40 datasource_user_name
create() ([Link] ([Link] attribute), 13
method), 42 datasource_uses_unicode
create_cellset() ([Link] ([Link] attribute), 13
method), 17 datasource_view ([Link]
create_cellset_from_view() attribute), 13
([Link] days ([Link]
method), 18 attribute), 6
create_element_attribute() deactivate() ([Link] method),
([Link] 5
method), 30 deactivate() ([Link]
create_element_attributes_through_ti() method), 26
([Link]
deactivate_activate() (in module
method), 29 [Link]), 27
create_group() ([Link]
deactivate_transactionlog()
method), 38 ([Link]
create_user() ([Link] method), 18
method), 38 default_hierarchy
created ([Link] ([Link] at-
attribute), 4 tribute), 8
Cube (class in [Link]), 7 default_member ([Link]
cube ([Link] attribute), 16 attribute), 9
CubeService (class in [Link]), delete() ([Link]
27 method), 17
curly_braces() (in module [Link]), delete() ([Link]
44 method), 26
delete() ([Link]
D method), 28
data_procedure ([Link] delete() ([Link]
attribute), 13 method), 29
datasource_ascii_decimal_separator delete() ([Link]
([Link] attribute), 13 method), 30
datasource_ascii_delimiter_char delete() ([Link]
([Link] attribute), 13 method), 32
datasource_ascii_delimiter_type delete() ([Link]
([Link] attribute), 13 method), 34
datasource_ascii_header_records DELETE() ([Link]
([Link] attribute), 13 method), 36
datasource_ascii_quote_character delete() ([Link]
([Link] attribute), 13 method), 41
datasource_ascii_thousand_separator delete() ([Link]
([Link] attribute), 13 method), 42
datasource_data_source_name_for_client delete_cellset() ([Link]
([Link] attribute), 13 method), 18
Index 55
TM1py Documentation, Release 1.0.2
56 Index
TM1py Documentation, Release 1.0.2
execute_mdx_raw() ([Link]
([Link] method), 34
method), 19 execution_mode ([Link] at-
execute_mdx_rows_and_values() tribute), 5
([Link] exists() ([Link]
method), 19 method), 27
execute_mdx_ui_array() exists() ([Link]
([Link] method), 28
method), 19 exists() ([Link]
execute_mdx_ui_dygraph() method), 29
([Link] exists() ([Link]
method), 20 method), 30
execute_mdx_values() exists() ([Link]
([Link] method), 32
method), 20 exists() ([Link]
execute_message_log_delta_request() method), 34
([Link] exists() ([Link]
method), 39 method), 41
execute_ti_code() exists() ([Link]
([Link] method), 42
method), 34 expression ([Link] attribute),
execute_transaction_log_delta_request() 15
([Link] EXPRESSION ([Link]
method), 39 attribute), 44
execute_view() ([Link]
extract_axes_from_cellset() (in module
method), 20 [Link]), 49
execute_view_cellcount() extract_cellset()
([Link] ([Link]
method), 21 method), 23
execute_view_csv() extract_cellset_cellcount()
([Link] ([Link]
method), 21 method), 23
execute_view_dataframe() extract_cellset_composition()
([Link] ([Link]
method), 21 method), 24
execute_view_dataframe_pivot() extract_cellset_csv()
([Link] ([Link]
method), 21 method), 24
execute_view_raw() extract_cellset_dataframe_pivot()
([Link] ([Link]
method), 21 method), 24
execute_view_rows_and_values() extract_cellset_raw()
([Link] ([Link]
method), 22 method), 24
execute_view_ui_array() extract_cellset_rows_and_values()
([Link] ([Link]
method), 22 method), 24
execute_view_ui_dygraph() extract_cellset_values()
([Link] ([Link]
method), 22 method), 24
execute_view_values() extract_unique_names_from_members() (in
([Link] module [Link]), 49
method), 23
execute_with_return()
Index 57
TM1py Documentation, Release 1.0.2
F method), 13
feeder_statements ([Link] from_json() ([Link]
attribute), 14 class method), 14
feedstrings ([Link] attribute), 7 from_json() ([Link] class
feedstrings ([Link] attribute), method), 15
14 from_json() ([Link] class
format_string ([Link] method), 16
attribute), 11 from_string() ([Link]
frequency ([Link] attribute), 5 class method), 6
from_string()
frequency_string ([Link] ([Link]
attribute), 6 class method), 6
friendly_name ([Link] attribute),
16 G
from_dict() ([Link] class generate_unique_string() (in module
method), 6 [Link]), 45
from_dict() ([Link] get() ([Link]
class method), 7 method), 17
from_dict() ([Link] class get() ([Link]
method), 7 method), 17
from_dict() ([Link] get() ([Link]
class method), 8 method), 27
from_dict() ([Link] static get() ([Link]
method), 8 method), 28
get()
from_dict() ([Link]([Link]
class method), 9 method), 29
from_dict() ([Link] get() ([Link]
class method), 10 method), 30
from_dict() ([Link] get() ([Link]
class method), 10 method), 32
from_dict() ([Link] get() ([Link]
class method), 11 method), 35
from_dict() ([Link] class GET() ([Link]
method), 13 method), 36
from_dict() ([Link] get() ([Link]
class method), 14 method), 41
from_dict() ([Link] class get() ([Link]
method), 15 method), 43
from_dict() ([Link] class get_active_configuration()
method), 16 ([Link]
from_json() ([Link] method), 39
class method), 4 get_active_users()
from_json() ([Link] class ([Link]
method), 6 method), 33
from_json() ([Link] class get_admin_host() ([Link]
method), 7 method), 39
from_json() ([Link] get_all() ([Link]
class method), 8 method), 17
get_all() ([Link]
from_json() ([Link]
class method), 9 method), 27
from_json() ([Link] get_all() ([Link]
class method), 10 method), 28
from_json() ([Link] get_all() ([Link]
class method), 11 method), 35
from_json() ([Link] class
58 Index
TM1py Documentation, Release 1.0.2
Index 59
TM1py Documentation, Release 1.0.2
method), 35 hierarchy_name_from_element_unique_name()
get_product_version() (in module [Link]), 49
([Link] hierarchy_names ([Link]
method), 40 attribute), 8
get_random_intersection() HierarchyService (class in
([Link] [Link]), 32
method), 28 hours ([Link]
get_server_name() attribute), 6
([Link] httpmethod() (in module
method), 40 [Link]), 37
get_static_configuration()
([Link] I
method), 40 id ([Link] attribute), 4
get_storage_dimension_order() index ([Link] attribute), 8
([Link] init_analytics() ([Link]
method), 28 method), 14
get_threads() ([Link]
initialize_message_log_delta_requests()
method), 33 ([Link]
get_transaction_log_entries() method), 40
([Link] initialize_transaction_log_delta_requests()
method), 40 ([Link]
get_user() ([Link] method), 40
method), 38 is_admin ([Link] attribute), 16
get_user_names_from_group() is_connected() ([Link]
([Link] method), 37
method), 39 is_dynamic ([Link] attribute),
get_users_from_group() 15
([Link] is_static ([Link] attribute),
method), 39 15
get_value() ([Link] ITERABLE ([Link]
method), 24 attribute), 44
get_view_content()
([Link] K
method), 25 keywords ([Link] attribute), 14
groups ([Link] attribute), 16
L
H last_updated ([Link]
has_feeders ([Link] attribute), attribute), 4
14 last_updated_by ([Link]
has_rules ([Link] attribute), 7 attribute), 4
has_security_access load_all_bedrocks_from_github() (in mod-
([Link] attribute), 13 ule [Link]), 49
HEADERS ([Link] load_bedrock_from_github() (in module
attribute), 36 [Link]), 49
hierarchies ([Link] logout() ([Link]
attribute), 8 method), 37
Hierarchy (class in [Link]), 9 logout() ([Link].TM1Service.TM1Service
hierarchy_name ([Link] method), 42
attribute), 5 lower_and_drop_spaces() (in module
hierarchy_name ([Link] [Link]), 49
attribute), 5
hierarchy_name ([Link] at- M
tribute), 15
MDX ([Link] attribute), 10
60 Index
TM1py Documentation, Release 1.0.2
Index 61
TM1py Documentation, Release 1.0.2
62 Index
TM1py Documentation, Release 1.0.2
Index 63
TM1py Documentation, Release 1.0.2
W
whoami ([Link].TM1Service.TM1Service at-
tribute), 42
write_value() ([Link]
method), 25
write_values() ([Link]
method), 25
write_values_through_cellset()
([Link]
method), 26
64 Index