Ottomata has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/395822 )

Change subject: Move common vars to profile.sh, add init_superset.sh
......................................................................


Move common vars to profile.sh, add init_superset.sh

Change-Id: I087486bca35cad224e139989c1397ac1cd7d2a37
---
M build_wheels.sh
M create_virtualenv.sh
A init_superset.sh
A profile.sh
M scap/checks.yaml
5 files changed, 40 insertions(+), 14 deletions(-)

Approvals:
  Ottomata: Verified; Looks good to me, approved



diff --git a/build_wheels.sh b/build_wheels.sh
index 55af781..ce54dc2 100755
--- a/build_wheels.sh
+++ b/build_wheels.sh
@@ -1,6 +1,9 @@
 # Install all dependencies into artifacts/$dist.  This should only be run
 # on a build server.
 
+# source common variables
+source $(dirname $0)/profile.sh
+
 sudo apt-get --yes install \
   python-pip \
   python-wheel \
@@ -18,8 +21,6 @@
 # will be byte for byte identical.
 export SOURCE_DATE_EPOCH=1512574740
 
-dist=$(lsb_release --codename --short)
-wheels_dir=$(dirname $0)/artifacts/$dist
 
 rm -rf $wheels_dir
 mkdir -p $wheels_dir
diff --git a/create_virtualenv.sh b/create_virtualenv.sh
index b7c75b1..80d25a9 100755
--- a/create_virtualenv.sh
+++ b/create_virtualenv.sh
@@ -1,14 +1,5 @@
-dist=$(lsb_release --codename --short)
-deploy_dir=$(dirname $0)
-wheels_dir=$deploy_dir/artifacts/$dist
-
-# Default deploy directory, should exist in production.
-if [ -e /srv/deployment/analytics/superset ]; then
-    venv=/srv/deployment/analytics/superset/venv
-# Else just use ../superset-venv for testing.
-else
-    venv=$deploy_dir/../superset-venv
-fi
+# source common variables
+source $(dirname $0)/profile.sh
 
 # remove any existing virtualenv
 rm -rfv $venv
diff --git a/init_superset.sh b/init_superset.sh
new file mode 100644
index 0000000..eedb2ba
--- /dev/null
+++ b/init_superset.sh
@@ -0,0 +1,21 @@
+# source common variables
+source $(dirname $0)/profile.sh
+
+admin_user=${1:-admin}
+admin_pass=${2:-admin}
+
+# If /etc/superset exists, assume that superset configs are here.
+# Putting this directory in PYTHONPATH will make superset use them.
+test -e /etc/superset && export PYTHONPATH=/etc/superset
+
+# Initialize superset.
+# See: https://superset.incubator.apache.org/installation.html
+
+# Create a Flask admin user.
+$venv/bin/fabmanager create-admin --app superset --username $admin_user 
--password $admin_pass --firstname Admin --lastname User --email 
analytics-ale...@wikimedia.org 
+
+# Initialize the database
+$venv/bin/superset db upgrade
+
+# Create default roles and permissions
+$venv/bin/superset init
diff --git a/profile.sh b/profile.sh
new file mode 100644
index 0000000..ba38b9f
--- /dev/null
+++ b/profile.sh
@@ -0,0 +1,13 @@
+# Common variables for build and deploy scripts.
+
+deploy_dir=$(dirname $0)
+dist=$(lsb_release --codename --short)
+wheels_dir=$deploy_dir/artifacts/$dist
+
+# Default deploy directory, should exist in production.
+if [ -e /srv/deployment/analytics/superset ]; then
+    venv=/srv/deployment/analytics/superset/venv
+# Else just use ../superset-venv for testing.
+else
+    venv=$deploy_dir/../superset-venv
+fi
diff --git a/scap/checks.yaml b/scap/checks.yaml
index 99dca85..121943a 100644
--- a/scap/checks.yaml
+++ b/scap/checks.yaml
@@ -1,5 +1,5 @@
 checks:
-  build_virtualenv:
+  create_virtualenv:
     type: command
     stage: promote
     timeout: 300

-- 
To view, visit https://gerrit.wikimedia.org/r/395822
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I087486bca35cad224e139989c1397ac1cd7d2a37
Gerrit-PatchSet: 1
Gerrit-Project: analytics/superset/deploy
Gerrit-Branch: master
Gerrit-Owner: Ottomata <ao...@wikimedia.org>
Gerrit-Reviewer: Ottomata <ao...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to