Repository navigation
ValueError: invalid literal for int() with base 10: 'Second' #1369
Copy link
Copy link
Closed
Description
Describe the bug
When calling the IncrementalExtract refresh bridge refresh script as mentioned below We are getting below error. This worked successfully until last week.
Error:- ValueError: invalid literal for int() with base 10: 'Second'
Versions
Details of your environment, including:
Tableau Online
Python version: 3.8
TSC library version 3.22
To Reproduce
Steps to reproduce the behavior. Please include a code snippet where possible.
# Name of the data source in tableau
datasource = sys.argv[1]
tableau_auth = tsc.PersonalAccessTokenAuth(
token_name=personal_access_token_name,
personal_access_token=personal_access_token_secret,
site_id=site
)
server = tsc.Server(tableau_server, use_server_version=True)
server.auth.sign_in(tableau_auth)
# Get datasource id from datasource name
req_option = tsc.RequestOptions(pagesize=1000)
req_option.filter.update([tsc.Filter(tsc.RequestOptions.Field.Name, tsc.RequestOptions.Operator.Equals, datasource)])
all_datasources = list(tsc.Pager(server.datasources, req_option))
datasource_id = all_datasources[0].id
# Get 1000 tasks and then filter for only extract tasks under the datasource id of interest
# I don't believe you can filter tasks
all_extracts = list(tsc.Pager(server.tasks, tsc.RequestOptions(pagesize=1000)))
# The task type for incremental extracts is 'IncrementExtractTask' and full extracts is 'extractRefresh'
# The task type for incremental exrracts via Bridges is 'IncrementExtractViaBridgeTask'
extracts = [i for i in all_extracts if (i.target is not None and i.target.id == datasource_id) and ('IncrementExtractViaBridgeTask' == i.task_type)]
incremental_extract_obj = extracts[0]
# Trigger the incremental extract associated with the datasource
update_xml = server.tasks.run(incremental_extract_obj)
job_id = xmltodict.parse(update_xml)['tsResponse']['job']['@id']
print(f"Refresh extract job {job_id} created")
Results
What are the results or error messages received?
C:\>D:\Python\python.exe C:\TableauPythonScripts\TableauExtractIncRefTrigScript.py Datasource_name
==================
Traceback (most recent call last):
File "D:\Python\lib\site-packages\tableauserverclient\models\interval_item.py", line 183, in interval
if not (1 <= int(interval_value) <= 31):
ValueError: invalid literal for int() with base 10: 'Second'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\TableauPythonScripts\TableauExtractIncRefTrigScript.py", line 31, in <module>
all_extracts = list(tsc.Pager(server.tasks, tsc.RequestOptions(pagesize=1000)))
File "D:\Python\lib\site-packages\tableauserverclient\server\pager.py", line 40, in __iter__
current_item_list, last_pagination_item = self._endpoint(self._options)
File "D:\Python\lib\site-packages\tableauserverclient\server\endpoint\endpoint.py", line 190, in wrapper
return func(self, *args, **kwargs)
File "D:\Python\lib\site-packages\tableauserverclient\server\endpoint\tasks_endpoint.py", line 36, in get
all_tasks = TaskItem.from_response(server_response.content, self.parent_srv.namespace, task_type)
File "D:\Python\lib\site-packages\tableauserverclient\models\task_item.py", line 53, in from_response
return list(all_tasks)
File "D:\Python\lib\site-packages\tableauserverclient\models\task_item.py", line 51, in <genexpr>
all_tasks = (TaskItem._parse_element(x, ns) for x in all_tasks_xml)
File "D:\Python\lib\site-packages\tableauserverclient\models\task_item.py", line 64, in _parse_element
schedule_item_list = ScheduleItem.from_element(element, ns)
File "D:\Python\lib\site-packages\tableauserverclient\models\schedule_item.py", line 223, in from_element
) = cls._parse_element(schedule_xml, ns)
File "D:\Python\lib\site-packages\tableauserverclient\models\schedule_item.py", line 298, in _parse_element
interval_item = ScheduleItem._parse_interval_item(frequency_detail_elem, frequency, ns)
File "D:\Python\lib\site-packages\tableauserverclient\models\schedule_item.py", line 276, in _parse_interval_item
return MonthlyInterval(start_time, interval_value)
File "D:\Python\lib\site-packages\tableauserverclient\models\interval_item.py", line 151, in __init__
self.interval = str(interval_value)
File "D:\Python\lib\site-packages\tableauserverclient\models\interval_item.py", line 187, in interval
raise ValueError(error)
ValueError: Invalid interval value for a monthly frequency: Second.
Reactions are currently unavailable
Activity
jorwoods commentedon Apr 19, 2024
@apparao84 If you wrap your code in triple backticks, it will format it as code.
apparao84 commentedon Apr 19, 2024
@jorwoods We are not even able to retrieve/get any data from server.tasks library. Seems it is an issue with server.tasks library itself. If we run the same code for different library server.jobs or server.datasources we are able to print the data. We had this script running successfully for more than a year now and since last week it is not completing successfully.
We are running below same script provided in Tableau Server client API reference guide to print the data from server.tasks and getting below error.
Example code (Reference to code : https://tableau.github.io/server-client-python/docs/api-ref#tasks)
Error we are getting:
bcantoni commentedon May 4, 2024
I realized we have an existing bug open to deal with these interval types, so I'll close this issue in favor of the existing #1358