From 6dd81a3e95a9d67be743815ff9bfcd465278b3e9 Mon Sep 17 00:00:00 2001 From: Maxime Date: Tue, 8 Sep 2015 21:56:27 +0000 Subject: [PATCH] Adding argparse for port and debug mode on bin/panoramix --- panoramix/bin/panoramix | 17 ++++++++++++++--- panoramix/models.py | 4 ++++ panoramix/views.py | 4 ++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/panoramix/bin/panoramix b/panoramix/bin/panoramix index 1ceb1b2d029ea..d33039567e8fe 100755 --- a/panoramix/bin/panoramix +++ b/panoramix/bin/panoramix @@ -1,19 +1,30 @@ #!/usr/bin/env python from panoramix import app, config from subprocess import Popen +import argparse if __name__ == "__main__": - if config.DEBUG: + parser = argparse.ArgumentParser( + description='Start a Panoramix web server') + parser.add_argument( + '-d', '--debug', action='store_true', + help="Start the web server in debug mode") + parser.add_argument( + '-p', '--port', default=config.PANORAMIX_WEBSERVER_PORT, + help="Specify the port on which to run the web server") + args = parser.parse_args() + args.debug = args.debug or config.DEBUG + if args.debug: app.run( host='0.0.0.0', - port=int(config.PANORAMIX_WEBSERVER_PORT), + port=int(args.port), debug=True) else: cmd = ( "gunicorn " "-w 8 " - "-b 0.0.0.0:{config.PANORAMIX_WEBSERVER_PORT} " + "-b 0.0.0.0:{args.port} " "panoramix:app").format(**locals()) print("Starting server with command: " + cmd) Popen(cmd, shell=True).wait() diff --git a/panoramix/models.py b/panoramix/models.py index 4f785cb36a65c..ecd9a65f41c97 100644 --- a/panoramix/models.py +++ b/panoramix/models.py @@ -390,6 +390,10 @@ class TableColumn(Model, AuditMixin): def __repr__(self): return self.column_name + @property + def isnum(self): + return self.type in ('LONG', 'DOUBLE', 'FLOAT') + class Cluster(Model, AuditMixin): __tablename__ = 'clusters' id = Column(Integer, primary_key=True) diff --git a/panoramix/views.py b/panoramix/views.py index be55baa87809c..e08ce7035de14 100644 --- a/panoramix/views.py +++ b/panoramix/views.py @@ -30,7 +30,7 @@ class TableColumnInlineView(CompactCRUDMixin, ModelView): datamodel = SQLAInterface(models.TableColumn) can_delete = False edit_columns = [ - 'column_name', 'description', 'table', 'groupby', 'filterable', + 'column_name', 'description', 'groupby', 'filterable', 'table', 'count_distinct', 'sum', 'min', 'max'] list_columns = [ 'column_name', 'type', 'groupby', 'filterable', 'count_distinct', @@ -63,7 +63,7 @@ class SqlMetricInlineView(CompactCRUDMixin, ModelView): list_columns = ['metric_name', 'verbose_name', 'metric_type' ] edit_columns = [ 'metric_name', 'description', 'verbose_name', 'metric_type', - 'table', 'expression'] + 'expression', 'table',] add_columns = edit_columns page_size = 100 appbuilder.add_view_no_menu(SqlMetricInlineView)