Skip to content
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

Running TabPy on AWS #566

Open
wants to merge 105 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
5d96601
Create AWS-TabPy-Deployment.md
AmirMK Sep 22, 2022
4b2cbcd
Create test.md
AmirMK Sep 22, 2022
b2ff180
Add files via upload
AmirMK Sep 22, 2022
49c46ed
Delete test.md
AmirMK Sep 22, 2022
3fddbb8
Update AWS-TabPy-Deployment.md
AmirMK Sep 23, 2022
7533249
Update README.md
AmirMK Sep 23, 2022
ede205e
Delete 8-EC2_Connect.png
AmirMK Sep 26, 2022
8c8c777
Add files via upload
AmirMK Sep 26, 2022
1f184e5
Delete 8-EC2_Connect.png
AmirMK Sep 26, 2022
6eb2dfa
Add files via upload
AmirMK Sep 26, 2022
6e997fe
Delete 8-EC2_Connect.png
AmirMK Sep 26, 2022
77fe79e
Add files via upload
AmirMK Sep 26, 2022
d587e19
Delete 8-EC2_Connect.png
AmirMK Sep 26, 2022
d2e572d
Add files via upload
AmirMK Sep 26, 2022
6304a95
Delete 8-EC2_Connect.png
AmirMK Sep 26, 2022
7f98841
Add files via upload
AmirMK Sep 26, 2022
8a3d361
Delete 14-Application_Load_Balancer.png
AmirMK Sep 26, 2022
e92e0b4
Add files via upload
AmirMK Sep 26, 2022
302eb54
Delete 14-1-Application_Load_Balancer.png
AmirMK Sep 26, 2022
70a4417
Add files via upload
AmirMK Sep 26, 2022
1d42ec6
Delete 14-Application_Load_Balancer.png
AmirMK Sep 26, 2022
91f6ca9
Add files via upload
AmirMK Sep 26, 2022
5af660b
Delete 14-Application_Load_Balancer.png
AmirMK Sep 26, 2022
8f09a94
Add files via upload
AmirMK Sep 26, 2022
2989b65
Delete 14-Application_Load_Balancer.png
AmirMK Sep 26, 2022
c6a9d08
Add files via upload
AmirMK Sep 26, 2022
414c1cc
Delete 14-Application_Load_Balancer.png
AmirMK Sep 26, 2022
f9eca36
Add files via upload
AmirMK Sep 26, 2022
30b0a36
Delete 14-Application_Load_Balancer.png
AmirMK Sep 26, 2022
49d1e3b
Add files via upload
AmirMK Sep 26, 2022
ccd462b
Update AWS-TabPy-Deployment.md
AmirMK Sep 26, 2022
c9ed777
Add files via upload
AmirMK Sep 26, 2022
b5e9046
Update AWS-TabPy-Deployment.md
AmirMK Sep 26, 2022
c1058ea
Add files via upload
AmirMK Sep 27, 2022
831264c
Update AWS-TabPy-Deployment.md
AmirMK Sep 27, 2022
9fc9500
Update AWS-TabPy-Deployment.md
AmirMK Sep 27, 2022
f0774ae
Delete 14-Application_Load_Balancer.png
AmirMK Sep 27, 2022
c8b4f7d
Add files via upload
AmirMK Sep 27, 2022
fb9349d
Update AWS-TabPy-Deployment.md
AmirMK Sep 27, 2022
c8300a9
Add files via upload
AmirMK Sep 27, 2022
77b289c
Update AWS-TabPy-Deployment.md
AmirMK Sep 27, 2022
45843b0
Delete rr1.png
AmirMK Sep 27, 2022
ba658c2
Delete rr3.png
AmirMK Sep 27, 2022
5d6c745
Delete rr2.png
AmirMK Sep 27, 2022
d99cb5c
Delete 14-Application_Load_Balancer.png
AmirMK Sep 27, 2022
838593d
Update AWS-TabPy-Deployment.md
AmirMK Sep 27, 2022
9971da4
Add files via upload
AmirMK Sep 27, 2022
c73bcb2
Update AWS-TabPy-Deployment.md
AmirMK Sep 27, 2022
d62cc18
Update AWS-TabPy-Deployment.md
AmirMK Sep 27, 2022
0008654
Delete tt2.png
AmirMK Sep 27, 2022
fce5113
Update AWS-TabPy-Deployment.md
AmirMK Sep 27, 2022
8fc9d0e
Update AWS-TabPy-Deployment.md
AmirMK Sep 27, 2022
2ecc0b5
Update AWS-TabPy-Deployment.md
AmirMK Sep 27, 2022
4184338
Update AWS-TabPy-Deployment.md
AmirMK Sep 27, 2022
2400940
Update setup.py
AmirMK Sep 29, 2022
71035a2
Add files via upload
AmirMK Sep 30, 2022
ac86c5e
Update AWS-TabPy-Deployment.md
AmirMK Sep 30, 2022
19a0c28
Update setup.py
AmirMK Sep 30, 2022
b7fb48c
Update setup.py
AmirMK Oct 22, 2022
299bf2f
Update setup.py
AmirMK Oct 22, 2022
5ebb6b2
Update setup.py
AmirMK Oct 23, 2022
402249b
Update setup.py
AmirMK Oct 24, 2022
429edbe
Update setup.py
AmirMK Oct 24, 2022
358a840
Update setup.py
AmirMK Oct 24, 2022
f721838
Update setup.py
AmirMK Oct 24, 2022
9d2e230
Update setup.py
AmirMK Oct 25, 2022
37b723b
Update README.md
AmirMK Oct 25, 2022
90bf22f
Add files via upload
AmirMK Oct 25, 2022
1d4c16f
Update Dockerfile
AmirMK Oct 25, 2022
d778f1d
Update Dockerfile
AmirMK Oct 25, 2022
c32f362
Update Dockerfile
AmirMK Oct 25, 2022
6060336
Update Dockerfile
AmirMK Oct 25, 2022
45bb449
Update Procfile
AmirMK Oct 25, 2022
8697c14
Update setup.py
AmirMK Oct 25, 2022
4ed1d02
Update Procfile
AmirMK Oct 25, 2022
93b1e43
Update setup.py
AmirMK Dec 7, 2022
5204d42
Update app.py
AmirMK Dec 9, 2022
490e891
Update setup.py
AmirMK Dec 9, 2022
6ff7b3b
Update Procfile
AmirMK Dec 9, 2022
f1ae147
Update app.py
AmirMK Dec 9, 2022
e613190
Update app.py
AmirMK Dec 9, 2022
e43513b
Update setup.py
AmirMK Dec 9, 2022
938885d
Update base_handler.py
AmirMK Dec 9, 2022
91e58d4
Update app.py
AmirMK Dec 9, 2022
135e1ce
Update app.py
AmirMK Dec 9, 2022
833aecd
Update query_plane_handler.py
AmirMK Dec 9, 2022
6f050d2
Update query_plane_handler.py
AmirMK Dec 9, 2022
af6558c
Update base_handler.py
AmirMK Dec 9, 2022
41d2acf
Update query_plane_handler.py
AmirMK Dec 9, 2022
481b70c
Update setup.py
AmirMK Dec 9, 2022
1813f97
Update Procfile
AmirMK Dec 9, 2022
7750802
Update base_handler.py
AmirMK Dec 9, 2022
83c47ad
Update base_handler.py
AmirMK Dec 9, 2022
8bcf697
Update base_handler.py
AmirMK Dec 9, 2022
90b1901
Update base_handler.py
AmirMK Dec 19, 2022
ab856aa
Update base_handler.py
AmirMK Dec 20, 2022
a5a243f
Update app.py
AmirMK Dec 21, 2022
07ba1b3
Update app.py
AmirMK Dec 21, 2022
d67d3a9
Update __init__.py
AmirMK Dec 21, 2022
925f640
Update base_handler.py
AmirMK Dec 21, 2022
6ce3b2e
Create static_handler.py
AmirMK Dec 21, 2022
2a05714
Update static_handler.py
AmirMK Dec 21, 2022
c19789b
Update setup.py
AmirMK Dec 21, 2022
9b0f0e3
Update Procfile
AmirMK Dec 21, 2022
acbe5f6
Update Procfile
AmirMK Dec 21, 2022
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
3 changes: 2 additions & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
web: export TABPY_PORT=$PORT && export TABPY_PWD_FILE=./file.txt && tabpy-user add -u $USERNAME -p $PASSWORD -f ./file.txt && tabpy
web: export TABPY_PORT=$PORT && export TABPY_PWD_FILE=./file.txt && tabpy-user add -u $USERNAME -p $PASSWORD -f ./file.txt && python3 external_files.py && python3 -m spacy download en_core_web_sm && tabpy

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/tabpy?label=PyPI%20Python%20versions)
[![PyPI version](https://badge.fury.io/py/tabpy.svg)](https://pypi.python.org/pypi/tabpy/)

[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/tableau/tabpy)
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/AmirMK/TabPy-Amir)

TabPy (the Tableau Python Server) is an Analytics Extension implementation which
expands Tableau's capabilities by allowing users to execute Python scripts and
Expand All @@ -24,6 +24,7 @@ Consider reading TabPy documentation in the following order:
* [TabPy Server Configuration Instructions](docs/server-config.md)
* [Running TabPy in Virtual Environment](docs/tabpy-virtualenv.md)
* [Running TabPy on Heroku](docs/deploy-to-heroku.md)
* [Running TabPy on AWS](docs/AWS-TabPy-Deployment.md)
* [Authoring Python calculations in Tableau](docs/TableauConfiguration.md).
* [TabPy Tools](docs/tabpy-tools.md)

Expand Down
187 changes: 187 additions & 0 deletions docs/AWS-TabPy-Deployment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
# TabPy Deployment for Tableau Cloud (AWS)
The goal of this document is to walk through all steps required to deploy TabPy on AWS with SSL connection. Although in the document we are using AWS cloud as the deployment platform, the architecture and solution is generalized to any other cloud platforms. The solution building process comprises three main steps:

* Running TabPy on EC2 instance
* Request SSL certification with a registered domain
* Set up an application load balancer with HTTPS

## 1. Running TabPy on EC2 Instance
AWS EC2 instance is employed as a virtual server to host python and run TabPy. The most important point in this part is we are not going to configure TabPy with HTTPS and will use load balancer with HTTPS instead:


![alt text](https://github.com/AmirMK/TabPy-Amir/blob/master/docs/img/AWS-Deployment/0-Overall.png)


Below is the walk through process to set-up an EC2 instance and install and configure TabPy. If you already have EC2 instance with TabPy up and run you may skip this section. You can find the official AWS documentation on set up Amazon EC2 [here](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/get-set-up-for-amazon-ec2.html).

## 1.1. EC2 Instance Set-up

From your AWS console go to EC2 and lunch an instance.
In the **Lunch an instance** section, select a name and the OS for your instance (ubuntu is recommended) as well as the instance type:

![alt text](https://github.com/AmirMK/TabPy-Amir/blob/master/docs/img/AWS-Deployment/1-Create_EC2.png)

Then you have the option to create **key pair** for your instance. That would be most useful when you want to transfer files from your local machine to your EC2 instance. So it is recommended to create the key with *ppk* format and store in the safe location:

![alt text](https://github.com/AmirMK/TabPy-Amir/blob/master/docs/img/AWS-Deployment/2-EC2_Keypair.png)
![alt text](https://github.com/AmirMK/TabPy-Amir/blob/master/docs/img/AWS-Deployment/3-EC2_Create_Keypair.png)

Next step is to create the **security group**. To do that click the edit bottom for security group section:

![alt text](https://github.com/AmirMK/TabPy-Amir/blob/master/docs/img/AWS-Deployment/4-Network_Setting.png)

Pick a meaningful name and description for the security group and make sure two **inbound rules** are added:

* *ssh* type with port 22 (Assuming the OS for your VM is Linux then we should enable ssh port othewise it should be the port consitent to the OS for example if the OS was Window the we would need to enable RDP)
* *Custom TCP* type with port 9004.

Although TabPy by default runs on port 9004 the port number can be configured on the TabPy configuration. If you want to run TabPy with a different port number, make sure you have the corresponding inbound rule a.k.a. *Custom TCP with your desirable port number*.

![alt text](https://github.com/AmirMK/TabPy-Amir/blob/master/docs/img/AWS-Deployment/5-TCP_Setting.png)

In the last part you have the option to increase the storage or number of instance as well. Then go ahead a click **Lunch instance**. It may take few mins for AWS to lunch the instance. You can see the list of running instance by going to **EC2 dashboard** and **Instance (running)**:

![alt text](https://github.com/AmirMK/TabPy-Amir/blob/master/docs/img/AWS-Deployment/6-EC2_Running_1.png)

![alt text](https://github.com/AmirMK/TabPy-Amir/blob/master/docs/img/AWS-Deployment/7-EC2_Running_2.png)

## 1.2. Install Python and TabPy

To install any software or package you need to connect to your EC2 instance. There are multiple ways to connect to your instance including [ssh connection](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstancesLinux.html) (for mac) and [putty](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/putty.html) (for windows) however the most straight forward method is using the AWS UI:

![alt text](https://github.com/AmirMK/TabPy-Amir/blob/master/docs/img/AWS-Deployment/8-EC2_Connect.png)

After connecting to the EC2 you need to run the following commands.

`sudo apt update`

`sudo apt install python3-pip`

`sudo python3 –m pip install —upgrade pip`

`sudo pip3 install tabpy`

This commands basically install the latest version of Python and install TabPy package. If you need any other python package you can install it similarly with pip command:

`sudo pip3 install [your-python-package]`

## 1.3. TabPy Configuration

The next step is to set the authentication for TabPy which is mandatory for Tableau Cloud. To do that you may create `.conf` file by stating the location of `.txt` file to store the user names and password (Please note TabPy supports basic authentication.). In the below example the file name is `pass.txt`:

`[TabPy]`

`TABPY_PWD_FILE = pass.txt`

you can find more about TabPy configuration [here](https://github.com/tableau/TabPy/blob/master/docs/server-config.md)

the `pass.txt` file needs to be created and be available on the same server as TabPy server. The next step is add user(s) for TabPy with below command:

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

you can find more about TabPy authentication command [here](https://github.com/tableau/TabPy/blob/master/docs/server-config.md#authentication)

At this stage, If we run TabPy from the current terminal, TabPy will be attached to the current terminal. On the other word, as soon as you close your borrower/terminal then TabPy will be shut down. Hence, we need to make sure TabPy is running as a service on background. Depend on the OS of your EC2 instance there are multiple ways to run TabPy at background. For ubuntu one of the most useful application to create sessions at background is [Tmux](https://github.com/tmux/tmux/wiki). Below is the summary of steps to run TabPy at background in ubuntu using Tmux. You can find more comprehensive reference for Tumx [here](https://tmuxcheatsheet.com/).

* Create a new session: `tmux new-session -s [session_name]`
* Connect to the session: `tmux attach-session -t [session_name]`
* Run TabPy with the custom configuration `tabpy --config [configuration file name.conf]`
* Disconnect from the session `Crtl + b + d`


Now TabPy is up and running on your EC2 instance and you are able to connect **Tableau Desktop** and **Tableau Server** with host-name as the **pubic IP** address for EC2 instance and port number as 9004. However, connecting to **Tableau Cloud** still is not possible as it requires SSL connection which we are going to discuss in the next parts

# 2. Domain Name Registeration and SSL Certification

Tableau Cloud establishes a connection only with external servers that are configured with a trusted **3rd party certificate authority (CA)** and not with a self-signed certificate, a certificate from a private PKI, or a certificate that is not trusted by an established 3rd party CA. Hence, we need to have a valid TLS/SSL certificate from a trusted 3rd party certificate authority (CA) which required having a registered domain.
Request SSL TLS/SSL can be done with AWS certificate manager however requesting the certificate requires a registered domain. Below is the walk though process to registered a domain (if you do not have one) with AWS Route 53 and request a SSL certificate.You can find AWS official documentation about registering a new domain [here](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/domain-register.html) and about requesting a public certificate [here](https://docs.aws.amazon.com/acm/latest/userguide/gs-acm-request-public.html).

## 2.1.Register a Domain

A registered domain to host the SSL certification is mandatory. If you already have a register domain you may skip this section otherwise you can register one with **AWS Route 53** as follow:
From AWS console go to **AWS Route 53** and select a domain name (usually there is a yearly fee associate to a domain)

After submitting the request it may take couple of mins for AW to verify the domain registration. You will get a notification email when the domain is registered successfully. And then you will see it as part of **Registered domain**

![alt text](https://github.com/AmirMK/TabPy-Amir/blob/master/docs/img/AWS-Deployment/9-Domain_Registory.png)

## 2.2. Request SSL Certificate

The next step is to request the SSL certification via **AWS certificate manager**. To do that, From AWS console go to **AWS Certificate Manager** and select request and then submit a request for a public certificate:

![alt text](https://github.com/AmirMK/TabPy-Amir/blob/master/docs/img/AWS-Deployment/10-Request%20Certificate.png)

Then you need to pick a valid name for your domain. When you pick the name, make sure you select **Add another name to this certificate** and add *.your-domain as below:

![alt text](https://github.com/AmirMK/TabPy-Amir/blob/master/docs/img/AWS-Deployment/11-Public_Certificate.png)

When you submit the request you may see the domain request as *pending*. Go back to **AWS certificate manager** portal and click on the *certification ID* correspond to the registered domain and select **Create records**:

![alt text](https://github.com/AmirMK/TabPy-Amir/blob/master/docs/img/AWS-Deployment/12-AWS_DNS_Record.png)

Few mins after creating record the status of certificate will turn into **issued**:

![alt text](https://github.com/AmirMK/TabPy-Amir/blob/master/docs/img/AWS-Deployment/13-AWD_DNS_Issued.png)

# 3. Application Load Balancer

Application load balancer is used to route the requests to the EC2 instance on which TabPy is running. Below is the walk though process to create an application load balancer and use it as proxy for the TabPy server. You can learn more application load balancer [here](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/introduction.html).

## 3.1. Create Load Balancer

From AWS console go to EC2 and then scroll down and find **Load Balancers** and create an **application load balancer**

![alt text](https://github.com/AmirMK/TabPy-Amir/blob/master/docs/img/AWS-Deployment/14-Application_Load_Balancer_.png)

Pick a name for your load balancer and make sure the VPC is the same as VPC for your EC2 instance similar for mappings (you need to pick at least two availability zones):

![alt text](https://github.com/AmirMK/TabPy-Amir/blob/master/docs/img/AWS-Deployment/15-APB_Setting.png)


## 3.2.Security Group and Target Group

The best practice is to create a new security group instead of using default ones. To do that remove any default security group and click on **create security group**. Pick a name and description for the security group and make sure the VPC is the same VPC that your TabPy EC2 instance is running on.
For the inbound and outbound rules make sure it is set to *HTTPS* type with port range 443. The outbound type can be *All traffic*

![alt text](https://github.com/AmirMK/TabPy-Amir/blob/master/docs/img/AWS-Deployment/16-APB_Security_Group_Basic.png)

You can learn more about AWS application load balancer security group [here](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-update-security-groups.html).

After creating the security group go back to the load balancer page and select the created security group;

![alt text](https://github.com/AmirMK/TabPy-Amir/blob/master/docs/img/AWS-Deployment/17-APB_Security_Group_Setting.png)

Next set up listeners and routing by selecting HTTPS as protocol with port 443 and then select **create a target group**

![alt text](https://github.com/AmirMK/TabPy-Amir/blob/master/docs/img/AWS-Deployment/18-APB_Security_Group_Listener.png)

For the target group set the target type to **instance**, pick a name and make sure protocol is HTTP with port 9004 (This is port on which TabPy is running on EC2 instance):

![alt text](https://github.com/AmirMK/TabPy-Amir/blob/master/docs/img/AWS-Deployment/19-APB_Security_Group_Config.png)

Finally select the instance on which your are running TabPy and **include as pending below**

![alt text](https://github.com/AmirMK/TabPy-Amir/blob/master/docs/img/AWS-Deployment/20-APB_Security_Group_Target.png)

After creating the target group go back to your load balancer page and select the created target group (you should see it as part of drop down menu)

![alt text](https://github.com/AmirMK/TabPy-Amir/blob/master/docs/img/AWS-Deployment/21-APB_Security_Group_HTTPS.png)

In the last section ‘Secure listen setting’ select your registered domain as :


## 3.2.Route Traffic to Load Balancer

The final step is to route the web traffic to the load balancer.
From AWS console go to **AWS Route 53** dashboard and under **DSN management** select **Hosted zones** and then select the registers domain you created. Then create a record and assign a record name (This would be the host-name for TabPy connection to Tableau Cloud) and make sure rest of the configuration is as below:

![alt text](https://github.com/AmirMK/TabPy-Amir/blob/master/docs/img/AWS-Deployment/22-APB_Security_Group_Final.png)

After creating the record you should have it as pat of:

![alt text](https://github.com/AmirMK/TabPy-Amir/blob/master/docs/img/AWS-Deployment/23-Create_Record_1.png)

It may take couple of mins for record to get effective and working. When the record gets effective you will be able to connect Tableau cloud/Desktop/Server to the TabPy server with secured connection via SSL. To connect to TabPy, your hostname would be the record name, port number is 443:

![alt text](https://github.com/AmirMK/TabPy-Amir/blob/master/docs/img/AWS-Deployment/25-TOL_Connection.png)

Binary file added docs/img/AWS-Deployment/0-Overall.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/AWS-Deployment/1-Create_EC2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/AWS-Deployment/12-AWS_DNS_Record.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/AWS-Deployment/13-AWD_DNS_Issued.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/AWS-Deployment/15-APB_Setting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/AWS-Deployment/2-EC2_Keypair.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/AWS-Deployment/23-Create_Record_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/AWS-Deployment/24-Create_Record_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/AWS-Deployment/25-TOL_Connection.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/AWS-Deployment/3-EC2_Create_Keypair.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/AWS-Deployment/4-Network_Setting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/AWS-Deployment/5-TCP_Setting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/AWS-Deployment/6-EC2_Running_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/AWS-Deployment/7-EC2_Running_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/AWS-Deployment/8-EC2_Connect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/AWS-Deployment/9-Domain_Registory.png
19 changes: 19 additions & 0 deletions external_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 25 14:59:23 2022

@author: ameimand
"""

import requests
URL = 'https://raw.githubusercontent.com/arunponnusamy/object-detection-opencv/master/yolov3.txt'
response = requests.get(URL)
open('yolov3.txt', 'wb').write(response.content)

URL = 'https://pjreddie.com/media/files/yolov3.weights'
response = requests.get(URL)
open('yolov3.weights', 'wb').write(response.content)

URL = 'https://raw.githubusercontent.com/pjreddie/darknet/master/cfg/yolov3.cfg'
response = requests.get(URL)
open('yolov3.cfg', 'wb').write(response.content)
8 changes: 7 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,17 @@ def read(fname):
"requests",
"scipy",
"simplejson",
"sklearn",
"scikit-learn",
"textblob",
"tornado",
"twisted",
"urllib3",
"networkx",
"community",
"opencv-python-headless",
"spacy",
"pyflightdata",
"salesforce-merlion",
],
entry_points={
"console_scripts": [
Expand Down
8 changes: 5 additions & 3 deletions tabpy/tabpy_server/app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from tabpy.tabpy_server.psws.callbacks import init_model_evaluator, init_ps_server
from tabpy.tabpy_server.psws.python_service import PythonService, PythonServiceHandler
from tabpy.tabpy_server.handlers import (
BaseStaticHandler,
EndpointHandler,
EndpointsHandler,
EvaluationPlaneHandler,
Expand Down Expand Up @@ -85,12 +86,12 @@ def run(self):
init_model_evaluator(self.settings, self.tabpy_state, self.python_service)

protocol = self.settings[SettingsParameters.TransferProtocol]
ssl_options = None
ssl_options = None
if protocol == "https":
ssl_options = {
"certfile": self.settings[SettingsParameters.CertificateFile],
"keyfile": self.settings[SettingsParameters.KeyFile],
}
}
elif protocol != "http":
msg = f"Unsupported transfer protocol {protocol}."
logger.critical(msg)
Expand Down Expand Up @@ -166,7 +167,8 @@ def try_exit(self):
),
(
self.subdirectory + r"/(.*)",
tornado.web.StaticFileHandler,
#tornado.web.StaticFileHandler,
BaseStaticHandler,
dict(
path=self.settings[SettingsParameters.StaticPath],
default_filename="index.html",
Expand Down
1 change: 1 addition & 0 deletions tabpy/tabpy_server/handlers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from tabpy.tabpy_server.handlers.management_handler import ManagementHandler

from tabpy.tabpy_server.handlers.endpoint_handler import EndpointHandler
from tabpy.tabpy_server.handlers.static_handler import BaseStaticHandler
from tabpy.tabpy_server.handlers.endpoints_handler import EndpointsHandler
from tabpy.tabpy_server.handlers.evaluation_plane_handler import EvaluationPlaneDisabledHandler
from tabpy.tabpy_server.handlers.evaluation_plane_handler import EvaluationPlaneHandler
Expand Down
3 changes: 2 additions & 1 deletion tabpy/tabpy_server/handlers/base_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ class BaseHandler(tornado.web.RequestHandler):
def initialize(self, app):
self.tabpy_state = app.tabpy_state
# set content type to application/json
self.set_header("Content-Type", "application/json")
self.set_header("Content-Type", "application/json")
self.set_header("Strict-Transport-Security", "preload; max-age=2592000")
self.protocol = self.settings[SettingsParameters.TransferProtocol]
self.port = self.settings[SettingsParameters.Port]
self.python_service = app.python_service
Expand Down
2 changes: 1 addition & 1 deletion tabpy/tabpy_server/handlers/query_plane_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def _query(self, po_name, data, uid, qry):
if isinstance(response, QuerySuccessful):
response_json = response.to_json()
md5_tag = md5(response_json.encode("utf-8")).hexdigest()
self.set_header("Etag", f'"{md5_tag}"')
self.set_header("Etag", f'"{md5_tag}"')
return (QuerySuccessful, response.for_json(), gls_time)
else:
self.logger.log(logging.ERROR, f"Failed query, response: {response}")
Expand Down
16 changes: 16 additions & 0 deletions tabpy/tabpy_server/handlers/static_handler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import base64
import binascii
import concurrent
import json
import logging
import tornado.web
import uuid




class BaseStaticHandler(tornado.web.StaticFileHandler):
def set_extra_headers(self, path):
# set content type to application/json
self.set_header("Strict-Transport-Security", "preload; max-age=2592000")
#self._headers["testheader"] = "test"