Skip to content

Commit

Permalink
Documentation improvements (tableau#385)
Browse files Browse the repository at this point in the history
* Delete .travis.yml

* Fix Ctrl+C failing on extra parameter in signal handler

* Remove outdated documentation for how to configure connection

* tabpy.py to use docopt

* Update tabpy-user with docopt

* Update CHANGELOG

* Fix code style
  • Loading branch information
0golovatyi authored Dec 24, 2019
1 parent 06572be commit fbf8f31
Show file tree
Hide file tree
Showing 21 changed files with 95 additions and 199 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test_coveralls_codestyle.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CI

on: [push, pull_request]
on: [pull_request]

jobs:
ubuntu-build:
Expand Down
2 changes: 1 addition & 1 deletion .pep8speaks.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File : .pep8speaks.yml

flake8:
max-line-length: 88
max-line-length: 98
14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

12 changes: 12 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@

### Improvements

- Minor code improvements.
- Documentation updates with referencing Tableau Help pages.
-

### Bug Fixes

- Fixed failing Ctrl+C handler.

## v0.8.9

### Improvements

- Added Ctrl+C handler
- Added configurable buffer size for HTTP requests
- Added anvoa to supported pre-deployed models in tabpy
Expand Down
18 changes: 4 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ be able to work on TabPy changes:
- Create a new branch for your changes.
- When changes are ready push them on github and create merge request.
- PIP packages - install all with
`pip install pytest pycodestyle autopep8 twine coverage --upgrade` command
`pip install pytest flake8 twine coverage --upgrade` command
- Node.js for npm packages - install from <https://nodejs.org>.
- NPM packages - install all with
`npm install markdown-toc markdownlint` command.
Expand All @@ -60,6 +60,7 @@ be able to work on TabPy changes:
4. Install all dependencies:

```sh
python -m pip install --upgrade pip
pip install -r requirements.txt
```

Expand Down Expand Up @@ -145,21 +146,10 @@ Access-Control-Allow-Methods = GET, OPTIONS, POST

## Code styling

`pycodestyle` is used to check Python code against our style conventions:
`flake8` is used to check Python code against our style conventions:

```sh
pycodestyle .
```

For reported errors and warnings either fix them manually or auto-format files with
`autopep8`.

Run the tool for a file. In the example below `-i`
option tells `autopep8` to update the file. Without the option it
outputs formatted code to the console.

```sh
autopep8 -i tabpy-server/server_tests/test_pwd_file.py
flake8 .
```

## Publishing TabPy Package
Expand Down
40 changes: 12 additions & 28 deletions docs/TableauConfiguration.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,24 @@ configure Tableau to use this service for evaluating Python code.

### Tableau Desktop

In Tableau Desktop version 10.1 or later:

1. Go to Help->Settings and Performance->Manage External Service Connection...
2. Enter the Server (localhost if running TabPy on the same computer) and the
Port (default is 9004).

![Screenshot of Configuration on Tableau Desktop](img/external-service-configuration.png)
To configure Tableau Desktop version 10.1 or later to connect to TabPy server
follow steps at Tableau
[Configure an external service connection](https://help.tableau.com/current/pro/desktop/en-us/r_connection_manage.htm#configure-an-external-service-connection)
documentation page.

### Tableau Server 2018.2 and Newer Versions

To configure Tableau Server 2018.2 and newer versions to connect to TabPy server
use [TSM command line tool](https://onlinehelp.tableau.com/current/server/en-us/tsm.htm).

To configure a non secure connection to TabPy server configuration:

```sh
tsm configuration set -k vizqlserver.extsvc.host -v <ip address or hostname>
tsm configuration set -k vizqlserver.extsvc.port -v <port or TabPy>
tsm pending-changes apply
```

To configure a secure connection to TabPy server use `tsm security vizql-extsvc enable`
command as described at
[TSM Security documentation page](https://onlinehelp.tableau.com/current/server/en-us/cli_security_tsm.htm#tsm_security_vizql-extsvc-ssl-enable).

<!-- markdownlint-disable MD013 -->

```sh
tsm security vizql-extsvc-ssl enable --connection-type <type> --extsvc-host <host_name> --extsvc-port <port> [options] [global options]
```
follow instructions on Tableau
[Configure Connections to External Services](https://onlinehelp.tableau.com/current/server/en-us/tsm.htm)
page.

<!-- markdownlint-enable MD013 -->
Specific details about how to configure a secure connection to TabPy, enable or
disable connections and other setting can be found at Tableau
[TSM Security documentation](https://onlinehelp.tableau.com/current/server/en-us/cli_security_tsm.htm#tsm_security_vizql-extsvc-ssl-enable)
page.

For how to configure a secure TabPy instance follow instructions at
For how to configure TabPy instance follow instructions at
[TabPy Server Config documentation](server-config.md).

### Tableau Server 2018.1 and Older Versions
Expand Down
Binary file removed docs/img/external-service-configuration.png
Binary file not shown.
6 changes: 3 additions & 3 deletions docs/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ If security is a significant concern within your organization,
you may want to consider the following as you use TabPy:

- The REST server and Python execution share the same Python session,
meaning that HTTP requests and user scripts are evaluated in the
same addressable memory and processor threads.
meaning that HTTP requests and user scripts are evaluated in the
same addressable memory and processor threads.
- The tabpy_tools client does not perform client-side validation of the
SSL certificate on TabPy Server.
- Python scripts can contain code which can harm security on the server
where the TabPy is running. For example, Python scripts can:
where the TabPy is running. For example, Python scripts can:
- Access the file system (read/write).
- Install new Python packages which can contain binary code.
- Execute operating system commands.
Expand Down
12 changes: 6 additions & 6 deletions docs/server-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,31 +209,31 @@ Passwords in the password file are hashed with PBKDF2.
with hosting OS mechanisms. Ideally the file should only be accessible
for reading with the account under which TabPy runs and TabPy admin account.**

There is a `tabpy-user-management` command provided with `tabpy` package to
operate with accounts in the password file. Run `tabpy-user-management -h`
There is a `tabpy-user` command provided with `tabpy` package to
operate with accounts in the password file. Run `tabpy-user -h`
to see how to use it.

After making any changes to the password file, TabPy needs to be restarted.

### Adding an Account

To add an account run `tabpy-user-management add`
To add an account run `tabpy-user add`
command providing user name, password (optional) and password file:

```sh
tabpy-user-management add -u <username> -p <password> -f <pwdfile>
tabpy-user add -u <username> -p <password> -f <pwdfile>
```

If the (recommended) `-p` argument is not provided a password for the user name
will be generated and displayed in the command line.

### Updating an Account

To update the password for an account run `tabpy-user-management update`
To update the password for an account run `tabpy-user update`
command:

```sh
tabpy-user-management update -u <username> -p <password> -f <pwdfile>
tabpy-user update -u <username> -p <password> -f <pwdfile>
```

If the (recommended) `-p` agrument is not provided a password for the user name
Expand Down
8 changes: 7 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
[pep8]
max-line-length = 98

[pycodestyle]
max-line-length = 88
max-line-length = 98

[flake8]
max-line-length = 98
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def read(fname):
"cloudpickle",
"configparser",
"decorator",
"docopt",
"future",
"genson",
"jsonschema",
Expand All @@ -82,7 +83,7 @@ def read(fname):
"console_scripts": [
"tabpy=tabpy.tabpy:main",
"tabpy-deploy-models=tabpy.models.deploy_models:main",
"tabpy-user-management=tabpy.utils.user_management:main",
"tabpy-user=tabpy.utils.tabpy_user:main",
],
},
setup_requires=["pytest-runner"],
Expand Down
2 changes: 1 addition & 1 deletion tabpy/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.8.9
0.8.10
18 changes: 14 additions & 4 deletions tabpy/tabpy.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
"""
TabPy application.
This file main() function is an entry point for
'tabpy' command.
TabPy Server.
Usage:
tabpy [-h] | [--help]
tabpy [--config <CONFIG>]
Options:
-h --help Show this screen.
--config <CONFIG> Path to a config file.
"""

import docopt
import os
from pathlib import Path

Expand All @@ -28,9 +35,12 @@ def read_version():


def main():
args = docopt.docopt(__doc__)
config = args["--config"] or None

from tabpy.tabpy_server.app.app import TabPyApp

app = TabPyApp()
app = TabPyApp(config)
app.run()


Expand Down
22 changes: 4 additions & 18 deletions tabpy/tabpy_server/app/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from argparse import ArgumentParser
import concurrent.futures
import configparser
import logging
Expand Down Expand Up @@ -44,13 +43,9 @@ class TabPyApp:

def __init__(self, config_file=None):
if config_file is None:
cli_args = self._parse_cli_arguments()
if cli_args.config is not None:
config_file = cli_args.config
else:
config_file = os.path.join(
os.path.dirname(__file__), os.path.pardir, "common", "default.conf"
)
config_file = os.path.join(
os.path.dirname(__file__), os.path.pardir, "common", "default.conf"
)

if os.path.isfile(config_file):
try:
Expand Down Expand Up @@ -98,7 +93,7 @@ def _create_tornado_web_app(self):
class TabPyTornadoApp(tornado.web.Application):
is_closing = False

def signal_handler(self, signal):
def signal_handler(self, signal, _):
logger.critical(f"Exiting on signal {signal}...")
self.is_closing = True

Expand Down Expand Up @@ -167,15 +162,6 @@ def try_exit(self):

return application

def _parse_cli_arguments(self):
"""
Parse command line arguments. Expected arguments:
* --config: string
"""
parser = ArgumentParser(description="Run TabPy Server.")
parser.add_argument("--config", help="Path to a config file.")
return parser.parse_args()

def _parse_config(self, config_file):
"""Provide consistent mechanism for pulling in configuration.
Expand Down
1 change: 0 additions & 1 deletion tabpy/tabpy_tools/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ def _gen_endpoint(self, name, obj, description, version=1, schema=[]):

endpoint_object = CustomQueryObject(query=obj, description=description,)

_schema = schema if schema is not None else []
return {
"name": name,
"version": version,
Expand Down
Loading

0 comments on commit fbf8f31

Please sign in to comment.