Chapter 3 Installation
Currently, we use docker to deploy our environment
First Steps
Clone the repository with the command
git clone --recurse-submodules https://github.com/EHDEN/NetworkDashboards
. If you already cloned the repository without the--recurse-submodules
option, rungit submodule update --init
to fetch the superset submodule.Create a
.env
file on thedocker
directory, using.env-example
as a reference, setting all necessary environment variables (SUPERSET_MAPBOX_API_KEY
andDASHBOARD_VIEWER_SECRET_KEY
).2.1 If you will use this application as a third-party application and will iframe it, set the variable
SINGLE_APPLICATION_MODE
toFalse
and define the host of the main application on the variableMAIN_APPLICATION_HOST
. Also make sure to add this last host to the list ofALLOWED_HOSTS
.
Dashboard Viewer setup
If you wish to expose the dashboard viewer app through a specific domain(s) you must add it/them to the
ALLOWED_HOSTS
list on filedashboard_viewer/dashboard_viewer/settings.py
and remove the'*'
entry.In production, all of our docker services use prebuilt images present in DockerHub, however, if you are in development mode and are using the
docker-compose-dev.yml
, you should build the images for the dashboard containers withdocker-compose build
.Set up the database and create an admin account for the dashboard viewer app:
docker-compose run --rm dashboard ./docker-init.sh
.
Insert Concepts
The concepts table is not in the repository due to its dimension, therefore we use directly the Postgres console to insert this table in the installation.
Get your concept csv file from Athena
Copy the file into postgres container
docker cp concept.csv dashboard_viewer_postgres_1:/tmp/
Enter in the postgres container:
docker exec -it dashboard_viewer_postgres_1 bash
Enter in the
achilles
database (value of the variablePOSTGRES_ACHILLES_DB
on the .env file) with theroot
user (value of the variablePOSTGRES_ROOT_USER
on the .env file):psql achilles root
Create the
concept
tableCREATE TABLE concept ( INTEGER NOT NULL, concept_id VARCHAR(255) NOT NULL, concept_name VARCHAR(20) NOT NULL, domain_id VARCHAR(20) NOT NULL, vocabulary_id VARCHAR(20) NOT NULL, concept_class_id VARCHAR(1) NULL, standard_concept VARCHAR(50) NOT NULL, concept_code DATE NOT NULL, valid_start_date DATE NOT NULL, valid_end_date VARCHAR(1) NULL invalid_reason );
Copy the CSV file content to the table (this could take a while)
To get both
'
(single quotes) and"
(double quotes) on theconcept_name
column we use a workaround by setting the quote character to one that should never be in the text. Here we used\b
(backslash).COPY public.concept FROM '/tmp/concept.csv' WITH CSV HEADER '\t' QUOTE E'\b'; DELIMITER E
Create index in table (this could take a while):
CREATE INDEX concept_concept_id_index ON concept (concept_id); CREATE INDEX concept_concept_name_index ON concept (concept_name);
Set the owner of the
concept
table to theachilles
user (value of the variablePOSTGRES_ACHILLES_USER
on the .env file):ALTER TABLE concept OWNER TO achiller
Bring up the containers:
docker-compose up -d
.Run the command
docker-compose run --rm dashboard python manage.py generate_materialized_views
to create the materialized views on Postgres.
Superset setup
Bring up the containers:
docker-compose up -d
.Make sure that the container
superset-init
has finished before continuing. It is creating the necessary tables on the database and creating permissions and roles.If you used the default ports:
- Go to
http://localhost
to access the dashboard viewer app. - Go to
http://localhost:8088
to access superset.
- Go to
By default Superset’s admin user credentials are admin/admin. It is recommended that you change the password if you will use this in a production environment.
To any anonymous user view dashboards, add the following permissions to the public role:
- all datasource access on all_datasource_access
- can csrf token on Superset
- can dashboard on Superset
- can explore json on Superset
- can read on Chart
- can read on CssTemplate
- can read on Dashboard
- can time range on Api
For each dashboard you want anonymous users to be able to access, on the dashboard list page click edit (the pencil on the right) and add the “Admin” and “Public” roles to the “Roles with acess” field.
Dummy data
On a fresh installation, there are no achilles_results data so Superset’s dashboards will display “No results”. On the root of this repository, you can find the demo
directory where we have an ACHILLES results file with synthetic data that you can upload to a data source on the uploader app of the dashboard viewer (http://localhost/uploader). If you wish to compare multiple data sources, on the demo
directory there is also a python script that allows you to generate new ACHILLES results files, where it generates random count values based on the ranges of values for each set of analysis_id and stratums present on a base ACHILLES results file. So, from the one ACHILLES results fill we provided, you can have multiple data sources with different data.