4 Replies Latest reply on Feb 16, 2018 7:54 AM by Jeff Strauss

    TabPy questions

    Jeff Strauss

      For TabPy, I followed all the instructions via the github for integration of Python code into Tableau dashboards.  But I still have these questions, BTW, I'm running on windows.



      1. TabPy needs to be persistent so that our analysts never get a "cannot connect to TabPy".  I have tried turning tabpy.py into a stand-alone exe using pyinstaller, and then I can create a service using sc create, but upon starting the service, I receive a dreaded 1053 error which I haven't figured out what to do about it yet.



      2. Instead of inserting Python code snippets into a Tableau calc, can the calc refer to Python (.py) modules, pass parms to this module, and then process the results?

        • 1. Re: TabPy questions
          Zhouyi Zhang

          Hi, Jeff


          I can't answer your 1st question since I'm not familiar with server admin.


          But to your 2nd question, I think you can do something like callback by using tabpy server and tabpy client. you can deploy your python code to tabpy server, below is the sample of using client.deploy


          TabPy/client.md at master · tableau/TabPy · GitHub


          as well as one of the thread I had answered before to someone else.

          TabPy remote function call


          Hope this could give you some ideas.



          1 of 1 people found this helpful
          • 2. Re: TabPy questions
            Jeff Strauss

            thx ZZ for this highly useful info.  I've started to tinker with the deploy of functions and it looks fairly straight forward once the concept is understood.

            • 3. Re: TabPy questions
              Jack Zhang

              Hi Jeff,


              For question 1, seems you already get your tableau connected to tabpy server, if running the py2exe file on a new environment, don't forget to set wgserver_trunsted_hosts <IP address>, which is I can think of to remind you.


              For question 2, you can deploy a function to tabpy server, then use the function in tableau desktop, instead of typing bunches of code in tableau cal editor. TabPy/client.md at master · tableau/TabPy · GitHub


              Hope my answer would be helpful.

              1 of 1 people found this helpful
              • 4. Re: TabPy questions
                Jeff Strauss

                Happy Friday.  Thank you for both of your inputs and thoughts.  I'm replying back with my findings.



                Q1.  In order to ensure that tabpy is always in a running status, I attempted to use both known utilities py2exe and pyinstaller to create a tabpy.exe executable out of tabpy.py.  This simply stated is a futile effort as it's just not directionally correct.  To connect to tabpy, Tableau needs to pass code to be interpreted by active process python.exe; tabpy.py is just the connector highway between Tableau and python.  So I reverted to a method that does work quite well (at least for windows).  Attached is a simple script (Script_startup_TabPy.cmd) that initiates a simple vbs (invis.vbs) which starts a windows shell with the startup.bat that is supplied within the tabpy_serrver install directory.  And then the simple script is defined within task scheduler to run at startup and uses a local system account, it launches python.exe as a process and the task ends within about 1 second.  Think of it as an orphaned process that is just sitting idle waiting for tabpy requests to come in from Tableau.


                Q2. The deploy of functions works, partially.  If anybody has a solution to get it working completely, please reply.  See attached simple_add.py.  It works when running "python simple_add.py" in the same location as tabpy_server.  However, if you install tabpy_client and future onto your desktop, I think it's supposed to work by design here too (thus enabling decision scientist to deploy common functions to tabpy which can then be referenced by Tableau).  It makes the connection fine, it defines the function fine, but then the deploy breaks because it can't find the endpoint within the server, it only exists locally.  See this for more info:  Cross OS client.deploy() fails due to OS specific path issues · Issue #8 · tableau/TabPy · GitHub

                1 of 1 people found this helpful