Skip to content

Commit

Permalink
v0.8: Make tabpy pip package (#332)
Browse files Browse the repository at this point in the history
### Improvements

- TabPy is pip package now
- Models are deployed with updated script
  • Loading branch information
0golovatyi committed Aug 20, 2019
1 parent 227024e commit 1d06980
Show file tree
Hide file tree
Showing 99 changed files with 877 additions and 875 deletions.
9 changes: 8 additions & 1 deletion .coveragerc
Expand Up @@ -4,4 +4,11 @@ exclude_lines =
if __name__ == .__main__.:

# Only show one number after decimal point in report.
precision = 1
precision = 1

[run]
omit =
tabpy/models/*
tabpy/tabpy.py
tabpy/utils/*
tests/*
1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

7 changes: 4 additions & 3 deletions .gitignore
Expand Up @@ -117,12 +117,13 @@ package-lock.json
.idea/

# TabPy server artifacts
tabpy-server/install.log
tabpy-server/tabpy_server/query_objects
tabpy-server/tabpy_server/staging
tabpy/tabpy_server/state.ini
tabpy/tabpy_server/query_objects
tabpy/tabpy_server/staging

# VS Code
*.code-workspace
.vscode

# etc
setup.bat
Expand Down
24 changes: 24 additions & 0 deletions .scrutinizer.yml
@@ -0,0 +1,24 @@
build:
environment:
python: 3.6
nodes:
analysis:
project_setup:
override:
- pip install sklearn pandas numpy textblob nltk scipy
tests:
override:
- py-scrutinizer-run
-
command: pylint-run
use_website_config: true
tests: true
checks:
python:
code_rating: true
duplicate_code: true
filter:
excluded_paths:
- '*/test/*'
dependency_paths:
- 'lib/*'
7 changes: 3 additions & 4 deletions .travis.yml
Expand Up @@ -2,13 +2,12 @@ os: linux
language: python
python: 3.6
install:
- ./startup.sh --no-startup --print-install-logs
- pip install pytest pytest-cov coveralls
- npm install -g markdownlint-cli
script:
- source utils/set_env.sh
- pytest tests/unit --cov=tabpy-server/tabpy_server --cov=tabpy-tools/tabpy_tools --cov-append
- pytest tests/integration
- pip install -e .
- py.test tests/unit --cov=tabpy --cov-append
- py.test tests/integration --cov=tabpy --cov-append
- markdownlint .
after_success:
- coveralls
16 changes: 0 additions & 16 deletions .vscode/launch.json

This file was deleted.

10 changes: 7 additions & 3 deletions CHANGELOG
@@ -1,7 +1,11 @@
# TabPy Changelog
# Changelog

This file lists notable changes for TabPy project releases.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## v0.8

### Improvements

- TabPy is pip package now
- Models are deployed with updated script

## v0.7

Expand Down
81 changes: 46 additions & 35 deletions CONTRIBUTING.md
@@ -1,21 +1,26 @@
# TabPy Contributing Guide

<!-- markdownlint-disable MD004 -->

<!-- toc -->

- [Environment Setup](#environment-setup)
- [Prerequisites](#prerequisites)
- [Cloning TabPy Repository](#cloning-tabpy-repository)
- [Setting Up Environment](#setting-up-environment)
- [Unit Tests](#unit-tests)
- [Integration Tests](#integration-tests)
- [Tests](#tests)
* [Unit Tests](#unit-tests)
* [Integration Tests](#integration-tests)
- [Code Coverage](#code-coverage)
- [TabPy in Python Virtual Environment](#tabpy-in-python-virtual-environment)
- [Documentation Updates](#documentation-updates)
- [TabPy with Swagger](#tabpy-with-swagger)
- [Code styling](#code-styling)
- [Publishing TabPy Package](#publishing-tabpy-package)

<!-- tocstop -->

<!-- markdownlint-enable MD004 -->

## Environment Setup

The purpose of this guide is to enable developers of Tabpy to install the project
Expand All @@ -27,12 +32,18 @@ These are prerequisites for an environment required for a contributor to
be able to work on TabPy changes:

- Python 3.6.5:
- To see which version of Python you have installed, run ```python --version```.
- To see which version of Python you have installed, run `python --version`.
- git
- TabPy repo:
- Get the latest TabPy repository with `git clone https://github.com/tableau/TabPy.git`
- Get the latest TabPy repository with
`git clone https://github.com/tableau/TabPy.git`.
- 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 --upgrade` command
- Node.js for npm packages - install from <https://nodejs.org>.
- NPM packages - install all with
`npm install markdown-toc markdownlint` command.

## Cloning TabPy Repository

Expand All @@ -46,32 +57,29 @@ be able to work on TabPy changes:
cd TabPy
```

Before making any code changes run environment setup script.
For Windows run this command from the repository root folder:
4. Register TabPy repo as a pip package:

```sh
utils\set_env.cmd
```
```sh
pip install -e .
```

and for Linux or Mac the next command from the repository root folder:
## Tests

To run the whole test suite execute the following command:

```sh
source utils/set_env.sh
pytest
```

## Unit Tests
### Unit Tests

TabPy has test suites for `tabpy-server` and `tabpy-tools` components.
To run the unit tests use `pytest` which you may need to install first
(see [https://docs.pytest.org](https://docs.pytest.org) for details):
Unit tests suite can be executed with the following command:

```sh
pytest tests/unit
```

Check `pytest` documentation for how to run individual tests or set of tests.

## Integration Tests
### Integration Tests

Integration tests can be executed with the next command:

Expand Down Expand Up @@ -106,13 +114,19 @@ TOC for markdown file is built with [markdown-toc](https://www.npmjs.com/package
markdown-toc -i docs/server-startup.md
```

To check markdown style for all the documentation use `markdownlint`:

```sh
markdownlint .
```

These checks will run as part of the build if you submit a pull request.

## TabPy with Swagger

You can invoke the TabPy Server API against a running TabPy instance with Swagger.

- Make CORS related changes in TabPy configuration file: update `tabpy-server\state.ini`
- Make CORS related changes in TabPy configuration file: update `tabpy/tabpy-server/state.ini`
file in your local repository to have the next settings:

```config
Expand All @@ -131,32 +145,29 @@ Access-Control-Allow-Methods = GET, OPTIONS, POST

## Code styling

`pycodestyle` is used to check Python code against our style conventions.
You can run install it and run locally for files where modifications were made:
`pycodestyle` is used to check Python code against our style conventions:

```sh
pip install pycodestyle
```

And then run it for files where modifications were made, e.g.:

```sh
pycodestyle tabpy-server/server_tests/test_pwd_file.py
pycodestyle .
```

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

To install `autopep8` run the next command:
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
pip install autopep8
autopep8 -i tabpy-server/server_tests/test_pwd_file.py
```

Then you can 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.
## Publishing TabPy Package

Execute the following commands to build and publish a new version of
TabPy package:

```sh
autopep8 -i tabpy-server/server_tests/test_pwd_file.py
python setup.py sdist bdist_wheel
python -m twine upload dist/*
```
7 changes: 7 additions & 0 deletions MANIFEST.in
@@ -0,0 +1,7 @@
include \
CHANGELOG \
LICENSE \
VERSION \
tabpy/tabpy_server/state.ini \
tabpy/tabpy_server/static/* \
tabpy/tabpy_server/common/default.conf
6 changes: 2 additions & 4 deletions README.md
Expand Up @@ -14,13 +14,11 @@ TabPy (the Tableau Python Server) is an external service implementation which ex
Tableau's capabilities by allowing users to execute Python scripts and saved functions
via Tableau's table calculations.

All documentation is in the [docs](docs) folder. Consider reading it in this
order:
Consider reading TabPy documentation in the following order:

* [About TabPy](docs/about.md)
* [TabPy Server Download Instructions](docs/server-download.md)
* [TabPy Installation Instructions](docs/server-install.md)
* [TabPy Server Configuration Instructions](docs/server-config.md)
* [TabPy Server Startup Instructions](docs/server-startup.md)
* [Running TabPy in Python Virtual Environment](docs/tabpy-virtualenv.md)
* [Authoring Python calculations in Tableau](docs/TableauConfiguration.md).
* [TabPy Tools](docs/tabpy-tools.md)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
0.7
0.8
4 changes: 4 additions & 0 deletions docs/FAQ.md
Expand Up @@ -3,6 +3,10 @@
<!-- markdownlint-disable MD004 -->

<!-- toc -->

- [Startup Issues](#startup-issues)
* [AttributeError: module 'tornado.web' has no attribute 'asynchronous'](#attributeerror-module-tornadoweb-has-no-attribute-asynchronous)

<!-- tocstop -->

<!-- markdownlint-enable MD004 -->
Expand Down

0 comments on commit 1d06980

Please sign in to comment.