Giter Site home page Giter Site logo

hasadna / opentraincommunity Goto Github PK

View Code? Open in Web Editor NEW
24.0 21.0 14.0 96.6 MB

Opentrain repository for community data analysis of Israel Railways train delay data.

Shell 0.12% Python 14.75% JavaScript 2.84% HTML 38.40% CSS 23.26% Batchfile 0.01% Vue 1.85% Jupyter Notebook 18.76%

opentraincommunity's Introduction

Online Project Documentation

Interactive documentation is available at http://opentraincommunity.readthedocs.org/en/latest/

Requirements

  • Python 3.6
  • Postgres (dumps postgres 10)

Our server (otrain.org) runs with ubuntu 18.04, postgres 10 and python 3.6.7

Developer Environment Setup

The project runs on Python 3 with POSTGRES, and we recommend using a virtual environment for development. You can use the following command to setup a virtualenv called opentrain:

mkvirtualenv -p $(which python3) opentrain

You might need to first install the virtualenv package, via:

sudo pip install virtualenv

Then activate the environment:

cd opentrain
source bin/activate

Then install all of the required modules into your virtualenv using pip:

cd OpenTrainCommunity/train2
pip install -r requirements.txt

Note: Installation of numpy via pip might require fulfilling certain prerequisites.

sudo apt-get install postgresql libpq-dev

Database setup and import

Best way to start is to download the POSTGRES dump file.

  1. Download the latest sql dump from http://otrain.org/files/dumps/ (you can download the gz file)
python restore.py <name-of-sql-file>

Note that the script will gunzip the file. You might need to run,

pip install argparse

In case you have already set a postgres user name, you could face:

ERROR:  role "postgres" does not exist

In this case, create a user name postgres before running the script.

On mac platform you might also have to change l29 in clean_all.py to

postgres_cmd = "sudo -u your_macuser psql"

Alternativley, you can use fab and run the following commands:

fab create_db
fab restore_db:<path-to-sql-gz-file>

Now you can start the server.

python manage.py runserver 

Troubleshooting

  • If you receive the error fatal error: xlocale.h: No such file or directory, it is likely due to a glibc header name change. One suggested solution is to manually create a symlink to the new name:

    ln -s /usr/include/locale.h /usr/include/xlocale.h
    
  • If you receive the error symbol __res_maybe_init version GLIBC_PRIVATE not defined in libc.so.6 with link time reference, it is likely due to a psycopg bug and can likely be solved by upgrading psycopg2 to a later version like 2.7.3.1.

Files

opentraincommunity's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opentraincommunity's Issues

Provide way to treat two sub stations (different gtfs_id) as a single station

Example
1220: [u'לב המפרץ', u'חיפה לב המפרץ'], #  Leb Hmifratz
1230: [u'מרכזית מפרץ-עמק'], #  Merkazit Hmifratz - Emek (Lev Hmifratz)

These are in fact the same station although they have a different gtfs_id.
This causes a distortion of the data

Expected

Have a way to give alternative gtfs id's for a station.

Different background colors

When initially loading the homepage we see a light blue background

image

Then when the page loads, it becomes dark blue:

image

Then when the route is being chosen, the background becomes light blue again

image

Seems like it should be more consistent...

Chatbor Visualization page

Add new UI page which displays:

  1. Total cancellations per time period (today: since 00:00 today, past week, past month, total)
  2. Chart displaying routes
  3. Chart displaying hours of cancellations
  4. Table with details of each report + any images or metadata

Handle failure to download new GTFS data

  1. GTFS data should be for several days ahead (currently only today is requested from partridge)
  2. Chatbot should use yesterday's gtfs data if today's hasn't downloaded

This is a bigger change

Breadcrumb leads to a blank page

Reproduction steps:

  1. Select source and destination stations.
  2. Select from and to dates.
  3. Click „הצג מידע”.
  4. After the data will appear click on „מתחנת מוצא לתחנת יעד - חודש ושנה” at the top of the page.

The page turns blank at this step and I need to click Back in order to restore the page.

Thanks.

Requirements page contains a duplicate entry

train2/requirements.txt has duplicate entries of

django-cors-headers==2.0.0

thereby yielding this error

Double requirement given: django-cors-headers==2.0.0 (from -r requirements.txt (line 16)) (already in django-cors-headers==2.0.0 (from -r requirements.txt (line 10)), name='django-cors-headers')

cannot proceed from here : (

rest_framework_swagger's API doc generation can't handle query params

schema_view = get_swagger_view(title='Pastebin API')

rest_framework_swagger generates docs at:
http://otrain.org/api/docs

API endpoints that require query parameters (as opposed to URL-supplied parameters) do not have those parameters generated in the documentation. Pressing the Try it out! button, for instance, will return a 500 error for:

http://otrain.org/api/docs/#!/general/general_goto_sleep
http://otrain.org/api/docs/#!/routes/routes_all_by_date
http://otrain.org/api/docs/#!/stats/stats_from_to_full
http://otrain.org/api/docs/#!/stats/stats_path_info_full
http://otrain.org/api/docs/#!/stats/stats_route_info
http://otrain.org/api/docs/#!/stops/stops_from_to
http://otrain.org/api/docs/#!/trips/trips_list_compact

This is a known issue with this package ever since YAML was deprecated. The various workarounds mentioned on the internet don't seem to work with list_route's defined on ViewSets, which is how the functions are defined. Also, the rest_framework_swagger package is not being maintained.

Some related discussions:
marcgibbons/django-rest-swagger#549
marcgibbons/django-rest-swagger#629
https://stackoverflow.com/questions/41104615/how-can-i-specify-the-parameter-for-post-requests-while-using-apiview-with-djang
https://stackoverflow.com/questions/28203070/how-to-show-query-parameter-options-in-django-rest-framework-swagger

image

UI: Remove "יציאה מהתחנה" columns

The delay with which the train left the station isn't interesting and can be removed.
The remaining three columns can be united into a single one, displaying ontime arrival in green, and delays in red. Early arrival to the station can be considered ontime arrival.

See here for screenshot: https://prnt.sc/kcv66z

Unable to know if a station was skipped

@ekeydar We said previously that we are unable to know if a train station was skipped during a trip. Why is this so? Can't we simply compare it to the published train schedule? For instance, the schedule says train #29 is supposed to go on Monday from Bat Galim 10:09 to Hof HaCarmel 10:16 to Tel Aviv Univ 11:00. If train #29 doesn't arrive at Hof HaCarmel and later arrives at Tel Aviv Univ, then we can safely say that Hof HaCarmel was skipped and include this fact in our statistics.

The biggest problem I can see with this solution is station closures. Once in a while, a station is closed due to construction or rail improvements, in which case it would be difficult to distinguish these two cases. Is there a way to also request a formatted table of station closures, dates of closures, etc.? (Perhaps we can use a simple heuristic -- if > 10 train arrivals at station X are skipped, then we can assume the station is simply closed, instead of a single train needing to 'catch up' on its delayed route).

Even having a general statistic "this station did not provide service to train users X% of the time it was supposed to provide service (either due to construction or due to stops being skipped)" would be a very helpful statistic, even if we can't provide the exact reason.

Top 10 "route" delays this month

  1. Choose 10 pairs of source and destination stations, manually as a first step.
  2. Calculate delay for each route / timeslot / day permutation
  3. Select top 10 routes with largest number of delays (delay > 5 mins)
  4. Click on a route will display the matching route summary page and allow selecting a more specific route.

Add chatbot info page and link to it from first message

Create a page that explains what the chatbot does and what information is collected.
Add a link to it in the first message:

"אני בוט שאוסף דיווחים על רכבות שבוטלו"
"(קרא עוד כאן...)"

Crossfilter: graphs should have the same dimensions on axis

Each delay graph has its own dimension, which prevents visual comparison between the max. delay and average delay graphs (for example).

The maximal dimension of the three graphs should be picked and used. This should be updated each time the filter is changed.

Incorrect behavior with months containing two digits

The TimeParser.parseMonth function incorrectly handles inputs where the first digit of the month is not a leading zero (i.e. 10/11/12). As a result, any searches for those months are incorrectly shown to the user.

Steps to reproduce:

  • From the homepage search for any origin and destination with either October, November, or December as the month.
  • For example:
    • מוצא: ראשון לציון משה דיין
    • יעד: כפר סבא
    • December 2013
  • Search and select any of the resulting routes
  • Note that the displayed info is from February 2013 instead of December 2013 (example URL).

Due to the current parseMonth function, October 2015 becomes December 2014, November 2015 becomes January 2015, and December 2015 becomes February 2015.

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.