server-client-python
server-client-python copied to clipboard
Schedules cannot handle valid monthly schedules
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.
Another example of this is reported in #1369 which I closed as a duplicate.
We're investigating a fix here (internal issue 16715720).
Here are steps to reproduce the issue on Tableau Server.
-
Login to Tableau Server and head to the Schedules settings page. (You'll need to be a server admin to edit these.)
-
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
-
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.
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