Skip to content

Commit

Permalink
Merge pull request tableau#1519 from tableau/development
Browse files Browse the repository at this point in the history
Development to master in prep of release 0.34
  • Loading branch information
bcantoni authored Oct 25, 2024
2 parents 196d73a + c3ea910 commit 1d98fda
Show file tree
Hide file tree
Showing 149 changed files with 3,347 additions and 1,407 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/meta-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- name: Get pip cache dir
id: pip-cache
shell: bash
run: |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: cache
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.python-version }}-pip-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-${{ matrix.python-version }}-pip-
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
Expand Down
16 changes: 15 additions & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,25 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']

runs-on: ${{ matrix.os }}

steps:
- name: Get pip cache dir
id: pip-cache
shell: bash
run: |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: cache
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-${{ matrix.python-version }}-pip-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-${{ matrix.python-version }}-pip-
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
Expand Down
18 changes: 9 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,42 @@ readme = "README.md"
dependencies = [
'defusedxml>=0.7.1', # latest as at 7/31/23
'packaging>=23.1', # latest as at 7/31/23
'requests>=2.31', # latest as at 7/31/23
'urllib3==2.2.2', # dependabot
'requests>=2.32', # latest as at 7/31/23
'urllib3>=2.2.2,<3',
'typing_extensions>=4.0.1',
]
requires-python = ">=3.7"
requires-python = ">=3.9"
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12"
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13"
]
[project.urls]
repository = "https://github.com/tableau/server-client-python"

[project.optional-dependencies]
test = ["black==23.7", "build", "mypy==1.4", "pytest>=7.0", "pytest-cov", "pytest-subtests",
test = ["black==24.8", "build", "mypy==1.4", "pytest>=7.0", "pytest-cov", "pytest-subtests",
"requests-mock>=1.0,<2.0"]

[tool.black]
line-length = 120
target-version = ['py37', 'py38', 'py39', 'py310', 'py311', 'py312']
target-version = ['py39', 'py310', 'py311', 'py312', 'py313']

[tool.mypy]
check_untyped_defs = false
disable_error_code = [
'misc',
# tableauserverclient\server\endpoint\datasources_endpoint.py:48: error: Cannot assign multiple types to name "FilePath" without an explicit "Type[...]" annotation [misc]
'annotation-unchecked' # can be removed when check_untyped_defs = true
]
files = ["tableauserverclient", "test"]
files = ["tableauserverclient", "test", "samples"]
show_error_codes = true
ignore_missing_imports = true # defusedxml library has no types
no_implicit_reexport = true
implicit_optional = true

[tool.pytest.ini_options]
testpaths = ["test"]
Expand Down
4 changes: 2 additions & 2 deletions samples/add_default_permission.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ def main():
for permission in new_default_permissions:
grantee = permission.grantee
capabilities = permission.capabilities
print("\nCapabilities for {0} {1}:".format(grantee.tag_name, grantee.id))
print(f"\nCapabilities for {grantee.tag_name} {grantee.id}:")

for capability in capabilities:
print("\t{0} - {1}".format(capability, capabilities[capability]))
print(f"\t{capability} - {capabilities[capability]}")

# Uncomment lines below to DELETE the new capability and the new project
# rules_to_delete = TSC.PermissionsRule(
Expand Down
13 changes: 6 additions & 7 deletions samples/create_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import os

from datetime import time
from typing import List

import tableauserverclient as TSC
from tableauserverclient import ServerResponseError
Expand Down Expand Up @@ -63,23 +62,23 @@ def main():

if args.file:
filepath = os.path.abspath(args.file)
print("Add users to site from file {}:".format(filepath))
added: List[TSC.UserItem]
failed: List[TSC.UserItem, TSC.ServerResponseError]
print(f"Add users to site from file {filepath}:")
added: list[TSC.UserItem]
failed: list[TSC.UserItem, TSC.ServerResponseError]
added, failed = server.users.create_from_file(filepath)
for user, error in failed:
print(user, error.code)
if error.code == "409017":
user = server.users.filter(name=user.name)[0]
added.append(user)
print("Adding users to group:{}".format(added))
print(f"Adding users to group:{added}")
for user in added:
print("Adding user {}".format(user))
print(f"Adding user {user}")
try:
server.groups.add_user(group, user.id)
except ServerResponseError as serverError:
if serverError.code == "409011":
print("user {} is already a member of group {}".format(user.name, group.name))
print(f"user {user.name} is already a member of group {group.name}")
else:
raise rError

Expand Down
2 changes: 1 addition & 1 deletion samples/create_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def main():
server.projects.populate_datasource_default_permissions(changed_project),
server.projects.populate_permissions(changed_project)
# Projects have default permissions set for the object types they contain
print("Permissions from project {}:".format(changed_project.id))
print(f"Permissions from project {changed_project.id}:")
print(changed_project.permissions)
print(
changed_project.default_workbook_permissions,
Expand Down
8 changes: 4 additions & 4 deletions samples/create_schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def main():
)
try:
hourly_schedule = server.schedules.create(hourly_schedule)
print("Hourly schedule created (ID: {}).".format(hourly_schedule.id))
print(f"Hourly schedule created (ID: {hourly_schedule.id}).")
except Exception as e:
print(e)

Expand All @@ -71,7 +71,7 @@ def main():
)
try:
daily_schedule = server.schedules.create(daily_schedule)
print("Daily schedule created (ID: {}).".format(daily_schedule.id))
print(f"Daily schedule created (ID: {daily_schedule.id}).")
except Exception as e:
print(e)

Expand All @@ -89,7 +89,7 @@ def main():
)
try:
weekly_schedule = server.schedules.create(weekly_schedule)
print("Weekly schedule created (ID: {}).".format(weekly_schedule.id))
print(f"Weekly schedule created (ID: {weekly_schedule.id}).")
except Exception as e:
print(e)
options = TSC.RequestOptions()
Expand All @@ -112,7 +112,7 @@ def main():
)
try:
monthly_schedule = server.schedules.create(monthly_schedule)
print("Monthly schedule created (ID: {}).".format(monthly_schedule.id))
print(f"Monthly schedule created (ID: {monthly_schedule.id}).")
except Exception as e:
print(e)

Expand Down
22 changes: 11 additions & 11 deletions samples/explore_datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,17 @@ def main():
if args.publish:
if default_project is not None:
new_datasource = TSC.DatasourceItem(default_project.id)
new_datasource.description = "Published with a description"
new_datasource = server.datasources.publish(
new_datasource, args.publish, TSC.Server.PublishMode.Overwrite
)
print("Datasource published. ID: {}".format(new_datasource.id))
print(f"Datasource published. ID: {new_datasource.id}")
else:
print("Publish failed. Could not find the default project.")

# Gets all datasource items
all_datasources, pagination_item = server.datasources.get()
print("\nThere are {} datasources on site: ".format(pagination_item.total_available))
print(f"\nThere are {pagination_item.total_available} datasources on site: ")
print([datasource.name for datasource in all_datasources])

if all_datasources:
Expand All @@ -69,20 +70,19 @@ def main():

# Populate connections
server.datasources.populate_connections(sample_datasource)
print("\nConnections for {}: ".format(sample_datasource.name))
print(
[
"{0}({1})".format(connection.id, connection.datasource_name)
for connection in sample_datasource.connections
]
)
print(f"\nConnections for {sample_datasource.name}: ")
print([f"{connection.id}({connection.datasource_name})" for connection in sample_datasource.connections])

# Demonstrate that description is editable
sample_datasource.description = "Description updated by TSC"
server.datasources.update(sample_datasource)

# Add some tags to the datasource
original_tag_set = set(sample_datasource.tags)
sample_datasource.tags.update("a", "b", "c", "d")
server.datasources.update(sample_datasource)
print("\nOld tag set: {}".format(original_tag_set))
print("New tag set: {}".format(sample_datasource.tags))
print(f"\nOld tag set: {original_tag_set}")
print(f"New tag set: {sample_datasource.tags}")

# Delete all tags that were added by setting tags to original
sample_datasource.tags = original_tag_set
Expand Down
16 changes: 7 additions & 9 deletions samples/explore_favorites.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import argparse
import logging
import tableauserverclient as TSC
from tableauserverclient import Resource
from tableauserverclient.models import Resource


def main():
Expand Down Expand Up @@ -39,15 +39,15 @@ def main():
# get all favorites on site for the logged on user
user: TSC.UserItem = TSC.UserItem()
user.id = server.user_id
print("Favorites for user: {}".format(user.id))
print(f"Favorites for user: {user.id}")
server.favorites.get(user)
print(user.favorites)

# get list of workbooks
all_workbook_items, pagination_item = server.workbooks.get()
if all_workbook_items is not None and len(all_workbook_items) > 0:
my_workbook: TSC.WorkbookItem = all_workbook_items[0]
server.favorites.add_favorite(server, user, Resource.Workbook.name(), all_workbook_items[0])
my_workbook = all_workbook_items[0]
server.favorites.add_favorite(user, Resource.Workbook, all_workbook_items[0])
print(
"Workbook added to favorites. Workbook Name: {}, Workbook ID: {}".format(
my_workbook.name, my_workbook.id
Expand All @@ -57,7 +57,7 @@ def main():
if views is not None and len(views) > 0:
my_view = views[0]
server.favorites.add_favorite_view(user, my_view)
print("View added to favorites. View Name: {}, View ID: {}".format(my_view.name, my_view.id))
print(f"View added to favorites. View Name: {my_view.name}, View ID: {my_view.id}")

all_datasource_items, pagination_item = server.datasources.get()
if all_datasource_items:
Expand All @@ -70,12 +70,10 @@ def main():
)

server.favorites.delete_favorite_workbook(user, my_workbook)
print(
"Workbook deleted from favorites. Workbook Name: {}, Workbook ID: {}".format(my_workbook.name, my_workbook.id)
)
print(f"Workbook deleted from favorites. Workbook Name: {my_workbook.name}, Workbook ID: {my_workbook.id}")

server.favorites.delete_favorite_view(user, my_view)
print("View deleted from favorites. View Name: {}, View ID: {}".format(my_view.name, my_view.id))
print(f"View deleted from favorites. View Name: {my_view.name}, View ID: {my_view.id}")

server.favorites.delete_favorite_datasource(user, my_datasource)
print(
Expand Down
2 changes: 1 addition & 1 deletion samples/explore_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def main():

if args.delete:
print("You can only delete the site you are currently in")
print("Delete site `{}`?".format(current_site.name))
print(f"Delete site `{current_site.name}`?")
# server.sites.delete(server.site_id)

elif args.create:
Expand Down
4 changes: 2 additions & 2 deletions samples/explore_webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ def main():
new_webhook.event = "datasource-created"
print(new_webhook)
new_webhook = server.webhooks.create(new_webhook)
print("Webhook created. ID: {}".format(new_webhook.id))
print(f"Webhook created. ID: {new_webhook.id}")

# Gets all webhook items
all_webhooks, pagination_item = server.webhooks.get()
print("\nThere are {} webhooks on site: ".format(pagination_item.total_available))
print(f"\nThere are {pagination_item.total_available} webhooks on site: ")
print([webhook.name for webhook in all_webhooks])

if all_webhooks:
Expand Down
Loading

0 comments on commit 1d98fda

Please sign in to comment.