server-client-python icon indicating copy to clipboard operation
server-client-python copied to clipboard

Schedules cannot handle valid monthly schedules

Open jacalata opened this issue 1 year ago • 1 comments

The schedules code only allows the string "LastDay". (https://github.com/tableau/server-client-python/blob/b06a7a249f7b0123f8b99fc43bd45539ad5f9eec/tableauserverclient/models/interval_item.py#L249C3-L253C33)

It should also allow the strings "First", "Second"..."Fifth". https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_extract_and_encryption.htm#create_cloud_extract_refresh_task

While fixing this code, it would be ideal to reduce the duplication of elements e.g the array of valid hourly values is defined twice in the file.

jacalata avatar Feb 15 '24 20:02 jacalata

Another example of this is reported in #1369 which I closed as a duplicate.

bcantoni avatar May 04 '24 00:05 bcantoni

We're investigating a fix here (internal issue 16715720).

bcantoni avatar Sep 10 '24 22:09 bcantoni

Here are steps to reproduce the issue on Tableau Server.

  1. Login to Tableau Server and head to the Schedules settings page. (You'll need to be a server admin to edit these.)

  2. Create a new schedule, type Extract Refresh, under Frequency select Monthly, then under On change it to any value other than the default Day, then save the schedule image

  3. Run the script below (substituting your own values for the PAT, site and server) which will loop over all schedules and call get_by_id() on each one. This should trigger the ValueError exception.

import tableauserverclient as TSC


tableau_auth = TSC.PersonalAccessTokenAuth(
    'PAT-NAME',
    'PAT-VALUE',
    'SITE-NAME-OR-BLANK'
    )
server = TSC.Server('SERVER-URL', use_server_version=True)
server.auth.sign_in(tableau_auth)

all_sch, pagination = server.schedules.get()
for sch in all_sch:
    sc = server.schedules.get_by_id(sch.id)
    print(sc.id)

You should get the error with exceptions like the following:

Traceback (most recent call last):
  File "/Users/brian/.pyenv/versions/tools-3.12/lib/python3.12/site-packages/tableauserverclient/models/interval_item.py", line 259, in interval
    if not (1 <= int(interval_value) <= 31):
                 ^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: 'Monday'

ValueError: Invalid interval value for a monthly frequency: Monday.

bcantoni avatar Sep 13 '24 03:09 bcantoni

This is fixed in the development branch now and will be available in the next release (0.33). If anyone would like to test it before release, they can follow the steps here: https://tableau.github.io/server-client-python/docs/#install-from-the-development-branch

bcantoni avatar Sep 17 '24 23:09 bcantoni