Skip to content
This repository has been archived by the owner on Nov 10, 2022. It is now read-only.

remix/mds-provider

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%