ThoughtSpot Modeling Language (TML) is a YAML based representation of objects in ThoughtSpot. The TML format for each object type is fully documented here. This toolkit makes it easier for developers to work with TML programatically for devops and CI integration.
The easiest way to install the library is via pip:
pip install thoughtspot_tml
Using thoughtspot_tml
The simplest way to use thoughtspot_tml is add the following into your python app:
from thoughtspot_tml import *
This will get you the YAMLTML helper class as well as each of the ThoughtSpot object classes: Table, Worksheet, View, Answer, Liveboard
As noted above, each TML object uses an OrderedDict. If a library returns the OrderedDict, you can load that directly into the object constructor:
The following example shows using a library where the export_tml(guid) method returns an OrderedDict.
` lbod = ts.tml.exporttml(guid=lbguid) /# Create a Liveboard TML object lbobj = Liveboard(lbod) /# Or do it all in one step: lbobj = Liveboard(ts.tml.exporttml(guid=lbguid)) Retrieving TML as YAML string from REST API If the REST API library outputs the YAML string from the TML export call, you can use the YAMLTML class to load it to OrderedDict:
lbyaml = ts.tml.exporttmlstring(guid=lbguid) lbod = YAMLTML.loadstring(lb_yaml)
/# Create a Liveboard TML object lbobj = Liveboard(lbod) /# Or do it all in one step: lbobj = Liveboard(YAMLTML.loadstring(ts.tml.exporttmlstring(guid=lb_guid)))`
For more detailed instructions on how to use the toolkit, check out the readme.