Coder Social home page Coder Social logo

hisparc / publicdb Goto Github PK

View Code? Open in Web Editor NEW
8.0 14.0 4.0 12.27 MB

The HiSPARC Public Database

Home Page: https://data.hisparc.nl/

License: GNU General Public License v3.0

Makefile 0.10% Python 55.61% JavaScript 19.89% CSS 2.96% HTML 20.84% Shell 0.48% Dockerfile 0.12%
outreach derived-data cosmic-rays

publicdb's Introduction

HiSPARC Public Database README

https://img.shields.io/github/actions/workflow/status/HiSPARC/publicdb/tests.yml?branch=master

Overview

The HiSPARC Public Database is a Django application which stores derived data and displays it for public use. It exposes an API to download raw detector data from the datastore, as well as an API to participate in analysis sessions.

To run and test the code, you can use Docker to setup a contained test environment.

Important information regarding provisioning the production servers

When you first run ansible on a freshly-installed system, you're likely to run into an error like:

sudo: sorry, you must have a tty to run sudo

You can fix that by manually logging into the machine, and typing:

$ sudo visudo

And changing the line:

Defaults requiretty

to:

Defaults !requiretty

Also, lock the root account and the user account. First, make sure to add your public key to ~/.ssh/authorized_keys, with the mode of both the directory and the file set to 0600. First make sure to test logging in without a password!!! Only then, lock the accounts:

$ sudo passwd -l root
$ sudo passwd -l hisparc

The only way to get into the machine is via SSH, so don't lock yourself out! (Actually, there is another way. With console access, you can reboot in single user mode.)

Provisioning production servers

We use Ansible for all our provisioning needs. You can run it from the top repository directory. First install ansible and its requirements:

$ pip install ansible
$ ansible-galaxy install -r requirements.yml

At that location, there is a file called ansible.cfg which sets up a few config values. To run the playbook, issue:

$ ansible-playbook provisioning/playbook.yml

Beware, however, that this will run provisioning for all production servers. It is very useful to limit the hosts for which to run the provisioner, e.g.:

$ ansible-playbook provisioning/playbook.yml --limit publicdb

If you want to check first what the provisioner would like to change, without actually changing anything, use the -C option:

$ ansible-playbook provisioning/playbook.yml --limit publicdb --check

Running a provisioner from a remote location

The servers can not be accessed directly from outside the university network. However, if there is a jump server available, it can easily be configured to automatically be used by setting it in your ssh configuration.

Add this to your .ssh/config:

Host hisparc-data hisparc-raw
    ProxyJump notchpeak1.chpc.utah.edu

Running with Docker-compose

Install and start Docker, then in this directory do:

$ docker-compose up -d

If this is the first run you should now run database migrations:

$ docker-compose exec publicdb ./manage.py migrate

In order to populate the database you can use a dump of the production database:

$ docker-compose exec -T postgres pg_restore --username=hisparc --dbname=publicdb < publicdb_dump.sql

or create some fake data:

$ docker-compose exec publicdb ./manage.py createfakedata

To clean the database again to fill it with new fake data use:

$ docker-compose exec publicdb ./manage.py flush --noinput
$ docker-compose exec publicdb ./manage.py loaddata publicdb/histograms/fixtures/initial_generator_state.json
$ docker-compose exec publicdb ./manage.py loaddata publicdb/histograms/fixtures/initial_types.json

To run the tests use:

$ docker-compose exec publicdb make coveragetests

Hints for running a development publicdb server

In order to create a tiny copy of the datastore for development purposes, do:

$ python scripts/download_test_datastore.py

To generate the histograms for the downloaded data:

$ ./manage.py updatehistograms

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.