8000 Revert "Development to master branch merge" by renoyjohnm · Pull Request #1513 · tableau/server-client-python · GitHub
[go: up one dir, main page]

Skip to content

Revert "Development to master branch merge" #1513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions .github/workflows/meta-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,6 @@ 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 F438 }} on ${{ matrix.os }}
Expand Down
16 changes: 1 addition & 15 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,11 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

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.32', # latest as at 7/31/23
'urllib3>=2.2.2,<3',
'requests>=2.31', # latest as at 7/31/23
'urllib3==2.2.2', # dependabot
'typing_extensions>=4.0.1',
]
requires-python = ">=3.9"
requires-python = ">=3.7"
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.13"
"Programming Language :: Python :: 3.12"
]
[project.urls]
repository = "https://github.com/tableau/server-client-python"

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

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

[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", "samples"]
files = ["tableauserverclient", "test"]
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(f"\nCapabilities for {grantee.tag_name} {grantee.id}:")
print("\nCapabilities for {0} {1}:".format(grantee.tag_name, grantee.id))

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

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

from datetime import time
from typing import List

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

if args.file:
filepath = os.path.abspath(args.file)
print(f"Add users to site from file {filepath}:")
added: list[TSC.UserItem]
failed: list[TSC.UserItem, TSC.ServerResponseError]
print("Add users to site from file {}:".format(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(f"Adding users to group:{added}")
print("Adding users to group:{}".format(added))
for user in added:
print(f"Adding user {user}")
print("Adding user {}".format(user))
try:
server.groups.add_user(group, user.id)
except ServerResponseError as serverError:
if serverError.code == "409011":
print(f"user {user.name} is already a member of group {group.name}")
print("user {} is already a member of group {}".format(user.name, 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(f"Permissions from project {changed_project.id}:")
print("Permissions from project {}:".format(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(f"Hourly schedule created (ID: {hourly_schedule.id}).")
print("Hourly schedule created (ID: {}).".format(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(f"Daily schedule created (ID: {daily_schedule.id}).")
print("Daily schedule created (ID: {}).".format(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(f"Weekly schedule created (ID: {weekly_schedule.id}).")
print("Weekly schedule created (ID: {}).".format(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(f"Monthly schedule created (ID: {monthly_schedule.id}).")
print("Monthly schedule created (ID: {}).".format(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,17 +51,16 @@ 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(f"Datasource published. ID: {new_datasource.id}")
print("Datasource published. ID: {}".format(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(f"\nThere are {pagination_item.total_available} datasources on site: ")
print("\nThere are {} datasources on site: ".format(pagination_item.total_available))
print([datasource.name for datasource in all_datasources])

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

# Populate connections
server.datasources.populate_connections(sample_datasource)
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)
print("\nConnections for {}: ".format(sample_datasource.name))
print(
[
"{0}({1})".format(connection.id, connection.datasource_name)
for connection in sample_datasource.connections
]
)

# 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(f"\nOld tag set: {original_tag_set}")
print(f"New tag set: {sample_datasource.tags}")
print("\nOld tag set: {}".format(original_tag_set))
print("New tag set: {}".format(sample_datasource.tags))

# Delete all tags that were added by setting tags to original
sample_datasource.tags = original_tag_set
Expand Down
16 changes: 9 additions & 7 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.models import Resource
from tableauserverclient 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(f"Favorites for user: {user.id}")
print("Favorites for user: {}".format(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 = all_workbook_items[0]
server.favorites.add_favorite(user, Resource.Workbook, 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])
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(f"View added to favorites. View Name: {my_view.name}, View ID: {my_view.id}")
print("View added to favorites. View Name: {}, View ID: {}".format(my_view.name, my_view.id))

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

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

server.favorites.delete_favorite_view(user, my_view)
print(f"View deleted from favorites. View Name: {my_view.name}, View ID: {my_view.id}")
print("View deleted from favorites. View Name: {}, View ID: {}".format(my_view.name, 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(f"Delete site `{current_site.name}`?")
print("Delete site `{}`?".format(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(f"Webhook created. ID: {new_webhook.id}")
print("Webhook created. ID: {}".format(new_webhook.id))

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

if all_webhooks:
Expand Down
Loading
Loading
0