Skip to content

Commit

Permalink
Preparing pypi package
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Sep 5, 2015
1 parent d419279 commit efc54e0
Show file tree
Hide file tree
Showing 42 changed files with 172 additions and 59 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
*.pyc
*.db
tmp
panoramix_config.py
local_config.py
env
app.db
68 changes: 43 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,35 +61,17 @@ Installation
Follow these few simple steps to install Panoramix

```
# Clone the github repo
git clone https://github.com/mistercrunch/panoramix.git
# Get in that fresh new folder
cd panoramix
# You may want to create a python virtualenv
# virtualenv env
# source env/bin/activate
# pip install -r requirements.txt
# If you don't use a virtualenv, you'll have to sudo to install the reqs
sudo pip install -r requirements.txt
# Install panoramix
pip install panoramix
# Edit config.py, and read through the settings
# Note that alternatively, you can create a ``local_config.py`` and put it
# somewhere in your PYTHONPATH. The variables declared local_config.py
# will override the ones in ``config.py``, and won't create issues when
# you need to ``git pull`` the latest version of panoramix
vim config.py
# Create an admin user
fabmanager create-admin --app panoramix
# Create an admin account, the app will ask for username/password, ...
# This feature is out of Flask App Builder, the framework I used to build
# Panoramix
fabmanager create-admin
# Clone the github repo
git clone https://github.com/mistercrunch/panoramix.git
# Start the web server
python run.py
panoramix
```

After installation, you should be able to point your browser to the right
Expand All @@ -101,6 +83,42 @@ your datasources for Panoramix to be aware of, and they should show up in

Configuration
-------------

To configure your application, you need to create a file (module)
`panoramix_config.py` and make sure it is in your PYTHONPATH. Here are some
of the parameters you can copy / paste in that configuration module:

```
#---------------------------------------------------------
# Panoramix specifix config
#---------------------------------------------------------
ROW_LIMIT = 5000
WEBSERVER_THREADS = 8
PANORAMIX_WEBSERVER_PORT = 8088
#---------------------------------------------------------
#---------------------------------------------------------
# Flask App Builder configuration
#---------------------------------------------------------
# Your App secret key
SECRET_KEY = '\2\1thisismyscretkey\1\2\e\y\y\h'
# The SQLAlchemy connection string.
SQLALCHEMY_DATABASE_URI = 'sqlite:///tmp/panoramix.db'
# Flask-WTF flag for CSRF
CSRF_ENABLED = True
# Whether to run the web server in debug mode or not
DEBUG = True
```

This file also allows you to define configuration parameters used by
Flask App Builder, the web framework used by Panoramix. Please consult
the [Flask App Builder Documentation](http://flask-appbuilder.readthedocs.org/en/latest/config.html) for more information on how to configure Panoramix.


* From the UI, enter the information about your clusters in the
``Admin->Clusters`` menu by hitting the + sign.

Expand Down
67 changes: 67 additions & 0 deletions alembic.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# A generic, single database configuration.

[alembic]
# path to migration scripts
script_location = migrations

# template used to generate migration files
# file_template = %%(rev)s_%%(slug)s

# max length of characters to apply to the
# "slug" field
#truncate_slug_length = 40

# set to 'true' to run the environment during
# the 'revision' command, regardless of autogenerate
# revision_environment = false

# set to 'true' to allow .pyc and .pyo files without
# a source .py file to be detected as revisions in the
# versions/ directory
# sourceless = false

# version location specification; this defaults
# to help/versions. When using multiple version
# directories, initial revisions must be specified with --version-path
# version_locations = %(here)s/bar %(here)s/bat help/versions

# the output encoding used when revision files
# are written from script.py.mako
# output_encoding = utf-8

sqlalchemy.url = scheme://localhost/panoramix

# Logging configuration
[loggers]
keys = root,sqlalchemy,alembic

[handlers]
keys = console

[formatters]
keys = generic

[logger_root]
level = WARN
handlers = console
qualname =

[logger_sqlalchemy]
level = WARN
handlers =
qualname = sqlalchemy.engine

[logger_alembic]
level = INFO
handlers =
qualname = alembic

[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic

[formatter_generic]
format = %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %H:%M:%S
4 changes: 2 additions & 2 deletions app/__init__.py → panoramix/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
logging.getLogger().setLevel(logging.DEBUG)

app = Flask(__name__)
app.config.from_object('config')
app.config.from_object('panoramix.config')
db = SQLA(app)

class MyIndexView(IndexView):
Expand All @@ -22,4 +22,4 @@ class MyIndexView(IndexView):

get_session = appbuilder.get_session

from app import views
from panoramix import views
19 changes: 19 additions & 0 deletions panoramix/bin/panoramix
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env python
from panoramix import app, config
from subprocess import Popen


if __name__ == "__main__":
if config.DEBUG:
app.run(
host='0.0.0.0',
port=int(config.PANORAMIX_WEBSERVER_PORT),
debug=True)
else:
cmd = (
"gunicorn "
"-w 8 "
"-b 0.0.0.0:{config.PANORAMIX_WEBSERVER_PORT} "
"panoramix:app").format(**locals())
print("Starting server with command: " + cmd)
Popen(cmd, shell=True).wait()
2 changes: 1 addition & 1 deletion config.py → panoramix/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,6 @@
#APP_THEME = "yeti.css"

try:
from local_config import *
from panoramix_config import *
except:
pass
File renamed without changes.
2 changes: 1 addition & 1 deletion app/models.py → panoramix/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import requests
import textwrap

from app import db, get_session, utils
from panoramix import db, get_session

QueryResult = namedtuple('namedtuple', ['df', 'query', 'duration'])

Expand Down
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 0 additions & 4 deletions app/utils.py → panoramix/utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import config
from datetime import datetime
import parsedatetime
from app import db




def parse_human_datetime(s):
Expand Down
7 changes: 3 additions & 4 deletions app/views.py → panoramix/views.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
from datetime import datetime
import logging
import json
import logging

from flask import request, redirect, flash, Response
from flask.ext.appbuilder.models.sqla.interface import SQLAInterface
from flask.ext.appbuilder import ModelView, CompactCRUDMixin, BaseView, expose
from app import appbuilder, db, models, viz, utils, app, get_session
from flask.ext.appbuilder.security.decorators import has_access, permission_name
import config
from flask.ext.appbuilder.security.decorators import has_access
from pydruid.client import doublesum
from wtforms.validators import ValidationError
from flask.ext.appbuilder.actions import action

from panoramix import appbuilder, db, models, viz, utils, app

def validate_json(form, field):
try:
Expand Down
5 changes: 2 additions & 3 deletions app/viz.py → panoramix/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
from flask import flash, request
import pandas as pd
from collections import OrderedDict
from app import utils
from app.highchart import Highchart, HighchartBubble
from panoramix import utils
from panoramix.highchart import Highchart, HighchartBubble
from wtforms import Form, SelectMultipleField, SelectField, TextField
import config
import logging
from pydruid.utils.filters import Dimension, Filter


CHART_ARGS = {
Expand Down
19 changes: 0 additions & 19 deletions run.py

This file was deleted.

32 changes: 32 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from setuptools import setup, find_packages

version = '0.2'

setup(
name='panoramix',
description=(
"A interactive data visualization platform build on SqlAlchemy "
"and druid.io"),
version=version,
packages=find_packages(),
package_data={'': ['panoramix/alembic.ini']},
include_package_data=True,
zip_safe=False,
scripts=['panoramix/bin/panoramix'],
install_requires=[
'flask-appbuilder>=1.4.5',
'flask-alembic>=1.2.1',
'gunicorn>=19.3.0',
'pandas>=0.16.2',
'pydruid>=0.2.2',
'parsedatetime>=1.5',
'python-dateutil>=2.4.2',
'requests>=2.7.0',
'sqlparse>=0.1.16',
],
author='Maxime Beauchemin',
author_email='[email protected]',
url='https://github.com/mistercrunch/panoramix',
download_url=(
'https://github.com/mistercrunch/panoramix/tarball/' + version),
)

0 comments on commit efc54e0

Please sign in to comment.