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

datasource item nullable project

Open peter-malcolm-bw opened this issue 2 years ago • 1 comments

Describe the bug A clear and concise description of what the bug is.

  • I am unable to list all of the datasources on the server.

  • This looks like the same issue as https://github.com/tableau/server-client-python/pull/1028 except with DatasourceItem instead of WorkbookItem

Versions Details of your environment, including:

  • Tableau Server version (or note if using Tableau Online) - Tableau Online
  • Python version: 3.9.12
  • TSC library version: 0.24

To Reproduce Steps to reproduce the behaviour. Please include a code snippet where possible.

import tableauserverclient as TSC

# log in to tableau server 

for datasource in TSC.Pager(server.datasources):
      print(datasource)

The error can be fixed by removing one line from datasource_item.py:

class DatasourceItem(object):
    
    ...
    
    @project_id.setter
    #@property_not_nullable  # TODO: remove this line 
    def project_id(self, value: str):
        self._project_id = value

Results What are the results or error messages received?

src/tableau_bot/refresh.py:142: in tableau_refresh
    for datasource in Pager(server.datasources):
../../Library/Caches/pypoetry/virtualenvs/tableau-bot-sFRF_OxE-py3.9/lib/python3.9/site-packages/tableauserverclient/server/pager.py:40: in __iter__
    current_item_list, last_pagination_item = self._endpoint(self._options)
../../Library/Caches/pypoetry/virtualenvs/tableau-bot-sFRF_OxE-py3.9/lib/python3.9/site-packages/tableauserverclient/server/endpoint/endpoint.py:205: in wrapper
    return func(self, *args, **kwargs)
../../Library/Caches/pypoetry/virtualenvs/tableau-bot-sFRF_OxE-py3.9/lib/python3.9/site-packages/tableauserverclient/server/endpoint/datasources_endpoint.py:77: in get
    all_datasource_items = DatasourceItem.from_response(server_response.content, self.parent_srv.namespace)
../../Library/Caches/pypoetry/virtualenvs/tableau-bot-sFRF_OxE-py3.9/lib/python3.9/site-packages/tableauserverclient/models/datasource_item.py:331: in from_response
    datasource_item = cls(project_id)
../../Library/Caches/pypoetry/virtualenvs/tableau-bot-sFRF_OxE-py3.9/lib/python3.9/site-packages/tableauserverclient/models/datasource_item.py:58: in __init__
    self.project_id = project_id
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <tableauserverclient.models.datasource_item.DatasourceItem object at 0x10995cdf0>, value = None

    @wraps(func)
    def wrapper(self, value):
        if value is None:
            error = "{0} must be defined.".format(func.__name__)
>           raise ValueError(error)
E           ValueError: project_id must be defined.

NOTE: Be careful not to post user names, passwords, auth tokens or any other private or sensitive information.

peter-malcolm-bw avatar Mar 20 '23 11:03 peter-malcolm-bw

yep - this should be simple enough to get in a new release very soon.

jacalata avatar Mar 25 '23 06:03 jacalata