Analytics Extensions are Available with Tableau Online!

You requested it, we listened, it took some time to make it happen… and now you can use TabPy, Rserve or any other analytics extension with Tableau Online!

To be able to enable the feature you need to be a site admin. In a similar way how on-prem Tableau Server is configured (see Multiple Analytics Extensions Connections with Tableau Server 2020.2 for details) for Tableau Online go to Settings, Extensions, set checkbox Enable analytics extensions for site and click Create new connection link. In popup window specify connection type, host, port and credentials.

NOTE. Tableau Online requires analytics extension connection to use SSL and authentication. This link shows some authentication related posts – http://tabscifi.com/category/authentication/. And with this link you can find some additional information about SSL and certificates – http://tabscifi.com/category/security/.

After configuring the connection click Save in the dialog window and then Save on the page. That’s it – now you can publish and use workbooks with Python/R/you-name-it scripts in them…

Actually there are couple more things to consider:

  • Your analytics extensions instance should use a certificate that Tableau Online can trust. It means no self-signed certs or certs issued by your organization. Those should be certs signed by one of well known CAs (Certificate Authority), e.g. DigiCert.
  • It has to be an endpoint (host and port) that is reachable for Tableau Online via the internet. If the analytics extension you are planning to use can be reached outside of your organization network Tableau Online should be able to see it too.
Share the post if you liked it
  •  
  •  
  •  
  •  
  •  
  •  

Why calculations for my Python/R/… SCRIPT_x field are per row?

Question Advanced Analytics Team hears somewhat regular is exactly what the title for the post says:

I created a calculated field and see the calls for TabPy/Rserve/MatLab/Einstein/etc. are made for each row. Why is that and what can I do for the field to be calculated once for the whole column?

Short answer is that behavior is how table calculation is computed – Tableau is evaluating each different value due to the settings. To change the behavior set the dimension as Specific Dimensions:

With Specific Dimensions data will be sent for calculation in one call.

For technical details read Tableau documentation on how to transform values with table calculations – https://help.tableau.com/current/pro/desktop/en-us/calculations_tablecalculations.htm#specific-dimensions.

Also consider watching these video recordings from Tableau Conference which provide some deeper dive into the topic and beyond:

  • Data science applications with TabPy/R:
  • Even More Data Science Applications in Tableau:
Share the post if you liked it
  •  
  •  
  •  
  •  
  •  
  •  

TabPy v2.3.1 Released: Deployed Function Overriding Bug Fixed

PyPi package – https://pypi.org/project/tabpy/2.3.1/.

GitHub release – https://github.com/tableau/TabPy/releases/tag/2.3.1.

The most important improvement of this release is a bug fix for overriding deployed functions (models).

TabPy supports overriding for deployed functions with increasing endpoint version for it.

For example if you run TabPy locally and deploy function like in the example below you will have endpoint Fn version 1:

from tabpy.tabpy_tools.client import Client

client = Client('http://localhost:9004/')

def fn(x, y):
  return x + y


client.deploy('Fn', fn, 'My awesome function')

In case you want to make any changes in the function in the way users of it automatically pick up new version without any work on their side use override parameter when deploying again:

def fn(x, y):
  return x * y + x * 2

client.deploy('Fn', fn, override=True)

With overriding endpoint Fn its version will be increased and all user SCRIPT_... calculations from now on will call this new version.

Share the post if you liked it
  •  
  •  
  •  
  •  
  •  
  •  

Running TabPy with Python Virtual Environment

In my post How to run TabPy with Anaconda on Linux I showed how to use Anaconda to create isolated Python environments so you can have different versions of Python with different packages installed all on the same machine.

If you can not use Anaconda for any reason there is another way to separate Python environments on a machine with help of Python virtual environment package.

For steps below I am using virtual machine running CentOS:

[ogolovatyi@3250e1583c74401 ~]$ hostnamectl
...
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-693.5.2.el7.x86_64
      Architecture: x86-64

All these steps with a little modifications can be used on MacOS or Windows.

To make things more interesting the machine has Python 2.7 on it:

[ogolovatyi@3250e1583c74401 ~]$ python -V
Python 2.7.5

Since TabPy requires Python 3.5 at least let’s first install it (on your Linux distribution you may need use some other package manager instead of yum):

sudo yum install python3

It is recommended to update pip with the latest version. Note that python command still will run Python 2.7. You can change that, but doing so may cause some of other commands and tools work properly. Instead I use python3 command which runs the newly installed Python 3.6.8:

sudo python3 -m pip install --upgrade pip

Now to installing virtualenv package:

python3 -m pip install virtualenv

For a virtual environment it will be created in the folder where the next command is executed:

python3 -m venv TabPy-venv

After the command above succeeds you can see TabPy-venv folder was created. You can create multiple virtual environments with using the command – just make the names unique.

To activate the environment run the following:

[ogolovatyi@3250e1583c74401 ~]$ source TabPy-venv/bin/activate

Note how command line prompt changes after the command above succeeded – now it has virtual environment name in it. Additionally python command now runs Python 3.6.8 I installed before:

(TabPy-venv) [ogolovatyi@3250e1583c74401 ~]$ python -V
Python 3.6.8

All the packages installed in the active virtual environment will be installed in the folder for the environment (TabPy-venv for the shown steps) and won’t affect “system” Python or any other Python versions or environments.

Now let’s update pip (remember it is different pip this time – the one for the virtual environment) and install TabPy:

pip install --upgrade pip
...
pip install tabpy

If you check where the TabPy is installed you’ll see something like this:

(TabPy-venv) [ogolovatyi@3250e1583c74401 ~]$ whereis tabpy
tabpy: /home/....../ogolovatyi/TabPy-venv/bin/tabpy

To start TabPy run the usual tabpy command or specify config for TabPy (more details at TabPy: modifying default configuration).

And to exit virtual environment simply run deactivate command.

Additional information about virtualenv can be found at https://virtualenv.pypa.io/en/stable/.

Share the post if you liked it
  •  
  •  
  •  
  •  
  •  
  •  

How to Get Online-Accessible TabPy Instance with Heroku

Although it is very easy to install TabPy on your laptop, desktop, VM, and so on with just pip install --upgrade tabpy command there are some limitations and additional work which needs to be done. Some examples are:

  • You environment has to be configured – supported Python version (3.6 or newer at the moment this post is written) needs to be installed.
  • To isolate TabPy from other Python applications you may want to use Anaconda (additional reading – How to run TabPy with Anaconda on Linux), Python virtual environment or similar solution.
  • The machine with TabPy on it cannot be accessible outside of you work/home network.
  • You don’t want to expose the machine with TabPy on it to the whole internet.
  • and so on…

And there is a way to quickly create TabPy instance available everywhere via the internet just in minutes. It is done with Heroku which by their own words is

Heroku is a cloud platform that lets companies build, deliver, monitor and scale apps — we’re the fastest way to go from idea to URL, bypassing all those infrastructure headaches.

https://www.heroku.com/what

In simple words Heroku allows you to have accessible with internet applications running on their side which lifetime you control. What languages are supported and other documentation is available at https://devcenter.heroku.com/.

For what I am demonstrating here free Heroku account is sufficient – register at https://signup.heroku.com/login.

When you have registered and successfully logged to your Heroku account go to TabPy GitHub page at https://github.com/tableau/TabPy and click Deploy to Heroku (purple button on the screenshot below) button or use this link – https://dashboard.heroku.com/new?button-url=https%3A%2F%2Fgithub.com%2Ftableau%2FTabPy&template=https%3A%2F%2Fgithub.com%2Ftableau%2FTabPy.

On the first screen provide your application name (it has to be unique across Heroku applications) and click Deploy app:

Wait for application to be installed, configured and started (all steps should succeed as shown on the screenshot below):

To access the application click View button or use URL https://<your-app-name>.herokuapp.com/ (in the example above it is https://tabpy-heroku-demo.herokuapp.com/).

That is it! You have TabPy instance accessible via the internet. Hostname for it is <your-app-nme>.herokuapp.com and port is 80:

For secure connection use port 443 and set Require SSL checkbox as screenshot below demonstrates:

Secure connection uses certificate from Heroku issued by DigiCert:

There are some limitations to this solution:

  • You may use your own certificate, but it is not free.
  • The port is not configurable – it is always 80 or 443.
  • There is no authentication.

To resolve the limitations above you may configure and create your own Heroku application based on TabPy. What you have instead in easy and fast way to get TabPy up and running available from anywhere when you need it.

Share the post if you liked it
  •  
  •  
  •  
  •  
  •  
  •