VizAlerts icon indicating copy to clipboard operation
VizAlerts copied to clipboard

Use tabcmd for exporting PDFs instead of URL actions

Open jdrummey opened this issue 8 years ago • 3 comments

This is courtesy of Bryant Howell @ Tableau: There are tabcmd options (such as page size) for PDF downloads that aren't available when grabbing PDFs using URLs. Bryant created a version of the tabhttp.py library that is object oriented and uses tabcmd instead of URL actions. The tableau_email.py file (attached as a txt file below because github is picky that way) has a TableauEmailer object that is a framework for reading out subscriptions and sending the email from them, and a TabCmd object that wraps all the tabcmd options and gets the necessary info from the repository.

The TabCmd object uses trick that Bryant figured out where the configuration file for tabcmd is modified with information from the repository to switch tabcmd onto a session that is established via trusted tickets.

Here's a code sample from Bryant using both the TableauEmailer and TabCmd objects.

` from tableau_email import *

tableau_server_admin_user = 'bhowell' tableau_server_admin_pw = '' tableau_server_url = 'http://127.0.0.1' tabcmd_dir = "C:\tabcmd\Command Line Utility" tabcmd_config_location = 'C:\Users\bhowell\AppData\Local\Tableau\Tabcmd' tabcmd_repository_pw = '' smtp_server = '

schedule_name_to_keep = "-- Full PDF Every Morning"

tableau_emailer = TableauEmailer(tabcmd_dir, tabcmd_config_location, tabcmd_repository_pw, tableau_server_url, tableau_server_admin_user, tableau_server_admin_pw, smtp_server) tableau_emailer.tabcmd.export_type = 'fullpdf' tableau_emailer.tabcmd.export_page_layout = 'landscape' tableau_emailer.generate_emails_from_named_schedule_in_repository(schedule_name_to_keep, '[email protected]', 'basic_email')

tableau_emailer.generate_email_from_view('[email protected]', '[email protected]', email_subject,

'basic_email', user, view_location)

tableau_emailer.tabcmd.site = 'default' for region in ['East', 'West', 'Central', 'South']: print "Bulding the {} e-mail".format(region) tableau_emailer.generate_email_from_view('[email protected]', '[email protected]', 'This viz is the {}!'.format(region), 'basic_email', 'bhowell', 'Book1/Dashboard1', view_filter_map={"Region": region}, email_content_type='csv') `

Here's my (Jonathan's) take on this:

  • Being able to support all the possible options for PDF output would be great since otherwise it forces the single PDF output option defined by the viz Page Setup settings. There's obviously a need for this because Bryant built this code for a client.
  • It would limit VizAlerts to Windows-only at this time since tabcmd doesn't run on Linux. We haven't explicitly made VizAlerts to run on Linux, but there's not much to prevent that. There's been at least one public ask on the forums for Linux support.
  • tabcmd would need to be installed on the same machine as VizAlerts which adds another step to the setup process.
  • My experience with tabcmd through v8.3 is that it's 50-100% slower than direct URL actions, I don't know how performance is with v9+.

If we did this the anticipated code changes would be:

  • Add a configuration option to tell VizAlerts where to find tabcmd
  • In vizalerts.py the get_viz_ref function would need to have all the tabcmd PDF options as arguments for content references
  • In tabhttp.py:
    • add the TabCmd code
    • for VIZ_PDF use tabcmd for the downloads
  • Update the documentation

tableau_email.py.txt

jdrummey avatar May 07 '16 12:05 jdrummey

I like the formatting features that this would add to VizAlerts, but am concerned with the things you already noted, Jonathan:

  • Slow
  • Windows-only
  • Additional setup requirements
  • Additional config requirements

Besides that, tabcmd can run only in series, rather than in parallel because sessions collide when you have multiple instances of it running at once. That being the case means that it would conflict with Issue #7 , adding multithreading to VizAlerts to ensure that at scale, we're processing them in a timely fashion with respect to when they were scheduled to run.

What might solve most, if not all of these problems is if we can perform all of the work that TabCmd performs, but without actually calling the command-line executable. As far as I am aware, tabcmd isn't really doing anything on the client side, it's just sending requests to Server. So my thought is that there must be a way to determine what calls are being made after the session is created and build those into tabhttp.py or whatever new form that library might take. If we can do that, we can probably avoid all of the problems introduced by making a call to tabcmd directly, and still get all the benefits.

@bryantbhowell , do you think this is possible? (hoping I got that mention right)

mcoles avatar May 09 '16 15:05 mcoles

One other suggestion was that PDF export features available via tabcmd would be a drop-in, optional feature in VizAlerts. I like that sentiment, but the problem with making something optional on the whole is that end-users who are not Admins may not be aware that certain functionality described as being in VizAlerts documentation and demo and such isn't available to them to use. So what happens when a user builds an alert with something like this (to mockup the arguments):

VIZ_PDF(myWorkbook/myView|fullworkbook|landscape)

...but the admin who configured VizAlerts did not opt to install Tabcmd? Ideally they would never get to this point, but since we have no way as of yet to ensure users know what features are or are not supported by the Admin, I'd think the best we can do right now is send them a failure email that specifically describes the problem as being that the Admin has not enabled this feature, and they should direct requests for it to [email protected].

mcoles avatar May 10 '16 16:05 mcoles

Tableau redid tabcmd in v.9 and it runs MUCH faster.

AirCooledNut avatar May 11 '16 16:05 AirCooledNut