Using CS Tools as a library to get dependencies. #62
Unanswered
billdback-ts
asked this question in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Overview
As of v1.4, CS Tools can be used as a library to make it easy to write your own applications. One app that I've had come up several times is the ability to get dependencies in a spreadsheet format. Right now, there isn't a tool that provides such a capability, but it's easy to write with cstools. In this example, we will create a script that will get the tables and worksheets along with their dependencies and write to a CSV file.
Setup
Create a new project with a
venv
(highly recommended).Next, install cs_tools as a library into your environment
pip install cs_tools @ https://github.com/thoughtspot/cs_tools/archive/v1.4.0.zip
. Note that this will get a bit simpler in the future. Substitute a more recent version as appropriate.That's it other than libraries you may need for your own code.
Config
One nice thing about using cstools is that you can create and test a config file for your code. Run
cstools config create --config <name>
and create a new TOML file. Then runcstools config show
to see the names and locations of the config file. The actual file will be named something likecluster-cfg_<myconfig>.toml
, but you can rename it. Move the file to a convenient location for your script.The code
The actual code is pretty straightforward.
That's it. In less than sixty lines of code, we are able to get all of the objects and their dependencies and put them in CSV file that can be opened in Excel or other application.
Beta Was this translation helpful? Give feedback.
All reactions