Giter Club home page Giter Club logo

polismath's Introduction

polismath

The machine learning and data flow system powering pol.is.

Setup

To get running, you'll need to install Leinengen (v at least 2.0). From there, all clojure dependencies can be installed using lein deps. However, you'll also need the postgresql (client) installed (sudo apt-get install postgresql postgresql-client on ubuntu).

Configuration / Environment variables

There are a number of variables for tuning and tweaking the system, many of which are exposed via environment variables. The ones you're most frequently to need to tweak for one reason or another:

  • MATH_ENV: This defaults to dev, for local development environments. Traditionally we've set this to prod and preprod for our production and pre-production deployments specifically. This value is used in keying the math export json blobs as found in the math_main and other tables in the database. This makes it possible to run multiple math environments (dev, testing, prod, preprod) all on the same database of votes. When you start the math server, you will need to run it with the same MATH_ENV setting as you ran the math worker with.
  • POLL_FROM_DAYS_AGO: This defaults to 10 (at the time of this writing). Conversations which have had vote or moderation activity in the specified range will be loaded into memory, and will be updated. This prevents old inactive conversations from being loaded into memory every time the poller starts.

You'll also need to pass database credentials and such.

Please see src/polismath/components/config.clj for the complete listing of environment variables.

  • DATABASE_URL: url for the database, in heroku format: postgres://<username>:<password>@<url>:<port>/<database-id>
  • WEBSERVER_PASS & WEBSERVER_USERNAME, to the polisServer instance, primarily for uathenticated api calls to send email notifications to users when their exports are done, via the polisServer.
  • DATABASE_IGNORE_SSL - certain database deployments (Docker in particular) may not accept ssl

Dev setup

Once you have all that stuff set up, you can run lein repl. From there you can run (run! system/poller-system) to start the poller, and (stop!) to stop it.

This application uses Stuart Sierra's Component library for REPL-reloadability, and places the system in the system var. So if you need to access one of the components that gets passed through to some code in the application for testing, that's where you'll want to grab it. We'll soon be switching to Mount over Component, for more automated reloadability, and less hassle having to pass around and think about the system object to test things.

To see some example REPL usage, take a look at the comment block at the bottom of dev/user.clj.

You can run tests using lein test. Since Clojure is slow to start though, you may find it easier to run the runner/-main function (see the test directory) from within your REPL process. There is an example of this in the dev/user.clj file above. There are rough units tests for most of the basic math things, and one or two higher level integration tests. Looking forward to setting up clojure.spec and some generative testing!

If you're not familiar with Clojure, you may wish to take a look at the Clojure related wiki pages.

Licensing

Please see LICENSE

polismath's People

Contributors

metasoarous avatar mbjorkegren avatar factoidforrest avatar crkrenn avatar audreyt avatar

Watchers

 avatar

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.