Skip to content

CityofSantaMonica/mds-provider

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
mds
 
 
 
 
 
 
 
 
 
 
 
 

mds-provider

Tools for working with MDS provider data.

Developed and tested with Python 3.7+.

See mds-provider-services for real-world usage of many of these tools.

Installation

Install with pip:

pip install -e git+https://github.com/CityofSantaMonica/mds-provider@master#egg=mds-provider

Or with python directly:

git clone https://github.com/CityofSantaMonica/mds-provider.git
cd mds-provider
python setup.py install

Getting Started

Read from a Provider API

from datetime import datetime, timedelta

import mds

end = datetime.utcnow()
start = end - timedelta(hours=1)

client = mds.Client("provider_name", token="secret-token")

trips = client.get_trips(start_time=start, end_time=end)

Validate against the MDS schema

validator = mds.DataValidator.trips()

for error in validator.validate(trips):
    print(error)

Load into a Postgres database

db = mds.Database(user="user", password="password", host="host", db="database")

db.load_trips(trips)

Package organization

module description
mds Tools for working with Mobility Data Specification provider data
mds.api Request data from compatible API endpoints
mds.db Work with databases
mds.encoding Custom data encoding and decoding.
mds.fake Generate fake provider data for testing and development
mds.files Work with provider configuration and data payload files
mds.geometry Helpers for GeoJSON-based geometry objects
mds.github Data and helpers for MDS on GitHub.
mds.providers Parse Provider registry files
mds.schemas Validate data using the JSON schemas
mds.versions Work with MDS versions