Skip to content

Commit

Permalink
Import / export of the dashboards. (apache#1197)
Browse files Browse the repository at this point in the history
* Implement import / export dashboard functionality.

* Address comments from discussion.

* Add function descriptions.

* Minor fixes

* Fix tests for python 3.

* Export datasources.

* Implement tables import.

* Json.loads does not support trailing commas.

* Improve alter_dict func

* Resolve comments.

* Refactor tests

* Move params_dict and alter_params to the ImportMixin

* Fix flask menues.
  • Loading branch information
bkyryliuk authored Oct 12, 2016
1 parent cd2ab42 commit 73cd2ea
Show file tree
Hide file tree
Showing 10 changed files with 827 additions and 26 deletions.
6 changes: 6 additions & 0 deletions caravel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ def checkout(dbapi_con, con_record, con_proxy):
if app.config.get('ENABLE_PROXY_FIX'):
app.wsgi_app = ProxyFix(app.wsgi_app)

if app.config.get('UPLOAD_FOLDER'):
try:
os.makedirs(app.config.get('UPLOAD_FOLDER'))
except OSError:
pass


class MyIndexView(IndexView):
@expose('/')
Expand Down
4 changes: 2 additions & 2 deletions caravel/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,7 @@ def load_multiformat_time_series_data():
'string0': ['%Y-%m-%d %H:%M:%S.%f', None],
'string3': ['%Y/%m/%d%H:%M:%S.%f', None],
}
for col in obj.table_columns:
for col in obj.columns:
dttm_and_expr = dttm_and_expr_dict[col.column_name]
col.python_date_format = dttm_and_expr[0]
col.dbatabase_expr = dttm_and_expr[1]
Expand All @@ -1069,7 +1069,7 @@ def load_multiformat_time_series_data():
tbl = obj

print("Creating some slices")
for i, col in enumerate(tbl.table_columns):
for i, col in enumerate(tbl.columns):
slice_data = {
"granularity_sqla": col.column_name,
"datasource_id": "8",
Expand Down
28 changes: 28 additions & 0 deletions caravel/migrations/versions/b46fa1b0b39e_add_params_to_tables.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""Add json_metadata to the tables table.
Revision ID: b46fa1b0b39e
Revises: ef8843b41dac
Create Date: 2016-10-05 11:30:31.748238
"""

# revision identifiers, used by Alembic.
revision = 'b46fa1b0b39e'
down_revision = 'ef8843b41dac'

from alembic import op
import logging
import sqlalchemy as sa


def upgrade():
op.add_column('tables',
sa.Column('params', sa.Text(), nullable=True))


def downgrade():
try:
op.drop_column('tables', 'params')
except Exception as e:
logging.warning(str(e))

Loading

0 comments on commit 73cd2ea

Please sign in to comment.