Join us
commit and push your .twb (Tableau Workbooks) files confidently
Tableau is a data visualization tool used in the Business Intelligence industry. its mainly uses to create an Analysis and Dashboard.
When creating/developing a Dashboard, Tableau users usually connecting to/extract data with Data Sources, creating views and analysis in Workbook, and publish it from Tableau Dekstop to Tableau Server to reach their audiences.
And under the hood, publishing Workbook is done by submitting .twb or .twbx files by Tableau Desktop to Tableau Server.
Most Tableau users use .twbx for offline and simple Analysis/Dashboard but when it comes to Analyzing/Dashboard with a large set of data .twb is far more preferable since it only contains Tableau’s instructions and connection information (not actual data) that make it more compact and modular than .twbx more info about .twb and .twbx here.
But this whole process rarely involves any audience or peer’s feedback and often doesn’t cover the requirements for controls and QA that software development follows.
So I create a new flow for Tableau Users that want to improve their Workbook developments process, by adding an extra step, Dashboard Promotion Flow.
With this new flow, every dashboard (except user sandbox and one-time dashboard) must be added to the repository, go through the Staging, and get reviewed before gets published to the Production.
Implementing this flow follows most data platform developments processes do.
Other than the .twb file, another info is needed for publishing Workbook, like the name of Workbook in the Tableau Server and to what project Workbook published, so I create a metadata fileworkbooks.yml
that stores those configurations.
The next step is creating a python script that publishes any .twb file to any project in the tableau server using the given parameters (name, project_id, source file). this process is quite simple just utilize this library tableau.github.io/server-client-python
Since the tableau project name is not unique, publishing is done by simply pushing the .twb file to some sample project_id in Tableau Server.
But a new question raises, tableau users, don’t know what project id that they are targeting, and it’s simply not a good idea referring some Workbooks with looks like some random string (UUID). With that consideration, I use the project path as a reference to the target project when publishing a Workbook (ex: Company Workbook/Company - Approved Workbook/Dashboard/Film).
Apparently, tableau project properties only store project_id and parent_project_id, not project path and there is no API/Library that handles this type of use case(at that time I’m writing this), so I create a helper function for that.
With the parse_projects_to_tree() function, I’m parsing all tableau projects into a tree data structure.
I’m using this treelib https://treelib.readthedocs.io/, as it covers my usage scenario, you can use other libraries that you prefer or maybe create your own tree module :)
This is done by using project_id and parent_project_id properties as a Child Node and a Parent Node, also I’m adding project_name as a Node Payload.
by defining all projects into a tree I can easily retrieve project_id based on project path, simply matching given project_path with Tree Project Structure by traversing the tree based on given candidate nodes.
After the main functionality has been done it’s time to add some features that make Workbook deployments easier.
get_addmodified_files() for getting all .twb files that change on the current PR and, coment_pr() that will send comments to PR that notify the user when Workbook is published.
I wrap my Tableau Workbook Deployments Project into GitHub Actions, using Github Actions to follows the Infrastructure-as-Code principle and have great integration with Github making it easier to use, for this action I set some arguments and environment variables that needed, like workbook_dir
to specify Workbook directory on the repository, env
to change target environments, and repo_token
that hold access token information.
I’m also submitting this GitHub Actions to the GitHub Marketplace if you want to use it github.com/marketplace/actions/tableau-workbook-action
The final step is to integrate newly created Github Actions into GitHub Workflow. Both staging and production workflows.
Staging workflows can be triggered when PR to master is opened and file changes are detected in the directory tableau/workbook/
.
And for Production workflows triggered when PR to master is closed and merged.
This sample Workbook result is based on configurations from workbooks.yml
that is published by Tableau Workbook Action triggered from tableau-staging-workflows.yml
and tableau-production-workflows.yml
With this new flow, each Dashboard will be tested and get reviewed first before being published to their audiences, and different drafts and versions will be tracked and managed well.
An (Automate) Dashboard deployment is a new concept and can be implemented in various forms. This specific approach is taken when I need to improve Tableau Workbook deployments through GitHub in a simple way, and there might be some improvement that needs to be made or.. another approach that is worth exploring.
If you like this post, you can give my newly published Github Actions a try or you can just share this article so people can find it too. Thank You.
Join other developers and claim your FAUN account now!
Influence
Total Hits
Posts
Only registered users can post comments. Please, login or signup.