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-submodulesoption, rungit submodule update --initto fetch the superset submodule.Create a
.envfile on thedockerdirectory, using.env-exampleas a reference, setting all necessary environment variables (SUPERSET_MAPBOX_API_KEYandDASHBOARD_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_MODEtoFalseand 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_HOSTSlist on filedashboard_viewer/dashboard_viewer/settings.pyand 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 bashEnter in the
achillesdatabase (value of the variablePOSTGRES_ACHILLES_DBon the .env file) with therootuser (value of the variablePOSTGRES_ROOT_USERon the .env file):psql achilles rootCreate the
concepttableCREATE TABLE concept ( concept_id INTEGER NOT NULL, concept_name VARCHAR(255) NOT NULL, domain_id VARCHAR(20) NOT NULL, vocabulary_id VARCHAR(20) NOT NULL, concept_class_id VARCHAR(20) NOT NULL, standard_concept VARCHAR(1) NULL, concept_code VARCHAR(50) NOT NULL, valid_start_date DATE NOT NULL, valid_end_date DATE NOT NULL, invalid_reason VARCHAR(1) NULL );Copy the CSV file content to the table (this could take a while)
To get both
'(single quotes) and"(double quotes) on theconcept_namecolumn 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 DELIMITER E'\t' QUOTE E'\b';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
concepttable to theachillesuser (value of the variablePOSTGRES_ACHILLES_USERon the .env file):ALTER TABLE concept OWNER TO achillerBring up the containers:
docker-compose up -d.Run the command
docker-compose run --rm dashboard python manage.py generate_materialized_viewsto create the materialized views on Postgres.
Superset setup
Bring up the containers:
docker-compose up -d.Make sure that the container
superset-inithas 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://localhostto access the dashboard viewer app. - Go to
http://localhost:8088to 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.