covid-taskforce-cplp / hxldash-docker

[draft] Unofficial dockerized version of HXLdash ("Create data visualisations quickly by leveraging the HXL - Humanitarian eXchange Language") for local development. The hosted version (maintained by British Red Cross) is at https://hxldash.com/
The Unlicense
1 stars 0 forks source link

Document how to run the hxldash-docker on populate_database mode #7

Open fititnt opened 4 years ago

fititnt commented 4 years ago

With the commit https://github.com/covid-taskforce-cplp/hxldash-docker/commit/5be6d9e2d4d21b61d7a2e1f9c64ba72ddc576dd8 (note: it does not use the master branch, but a testing branch), while is pretty fast to just make it work to test the sample dataset, may (not tested) reset the database (or at least the 3 first rows) when using the image created at #6.

This issue is just to remember that, ideally, by default we should have some way to allow the user not automatically run the command to pre-populate the database, and this feature should be the default. So for pre-populate the database the user should intentionally interested in doing it.


Some referentes

hxldash-docker/docker-entrypoint.sh


python /usr/src/app/manage.py migrate

## This command run always with the lastest commit; the user does not have option to disable (Its bad)
python /usr/src/app/manage.py populate_database

python /usr/src/app/manage.py runserver 0.0.0.0:8000

fititnt/uwazi-docker/blob/master/docker-entrypoint.sh

See https://github.com/fititnt/uwazi-docker/blob/master/docker-entrypoint.sh. On this was a quick check on how to allow an initial run.

Potential alternative: research how other python/django apps do this type of initialization

Very likely already there is strategies on how to do this type of initialization instead of we just copy the concept from the uwazi-docker.

But, while the hxldash-docker may not be focused to be production-ready, if it can be used to be used in production with changes is a win-win for anyone later wanting to use it as reference. Anyway the license is public domain, so not even cite creators is need.

SimonbJohnson commented 4 years ago

@fititnt - a quick note, the populate command will not overwrite or reset the data, but rather append the new dashboards to what is already there

fititnt commented 4 years ago

@SimonbJohnson interesting, very interesting. I will document this.

If this already is implemented, eventually maybe is possible to implement an extra param on python manage.py populate_database to point to a different JSON file (but the default still the hxldash/management/commands/data.json).

Not sure how the file was generated, but since it already is a JSON, at some point (way, way on future) it could be possible to export the datasets on JSON that the same version of hxldash can be able to import.

SimonbJohnson commented 4 years ago

Yes, it would be pretty easy for it to load files this way.

The file is a list of config variables for a dash. They can currently be obtained from the raw html of the dashboard view page:

view-source:https://hxldash.com/view/319

It the config variable declared towards end.

fititnt commented 4 years ago

The https://github.com/SimonbJohnson/quickX3/issues/69 was already implemented. We're ready to change the Dockerfile to use the master branch and document better this feature.

Later this issue will be solved.