Skip to main content

atd-mds-client

A Python utility to interact data endpoints compliant with the Mobility Data Specification, as designed by the Open Mobility Foundation.

This client was inspired by the City of Santa Monica MDS Provider Client.

Installation

Install the library:

pip install atd-mds-client

Or the development branch:

pip install atd-mds-client-dev

Getting started

# Import standard libraies:
import json
from datetime import datetime

# Import the MDS Library:
from mds import *

# Provider Configuration
provider_configuration = {
    # Authentication type: "OAuth", "Bearer", "Basic" or "Custom"
    "auth_type": "Bearer",
    # If you have a Bearer authentication, provide the token:
    "token": "...secret...token...here",
    # Provide the URL endpoint of the provider:
    "mds_api_url": "https://mds.your-scooter-company.com/api/endpoint/v1",
    # (Optional) The Provider ID
    "provider_id": "...mds...provider...id",
    # Any additional HTTP Headers:
    "headers": {
        "App-Version": "3.0.0"
    },
    # Any additional settings:
    "time_format": "unix",
    "delay": 1, # Delay in seconds per http request
    "max_attempts": 3, # Max attempts if the http request fails
    "paging": True, # Enable/Disable pagination
    "timeout": 10, # Maximum time allowed for an HTTP request in seconds
    "version": "0.3.0", # MDS Version: "0.2.0", "0.3.0" or "0.4.0" or remove for custom driver
}

# Builds a time-zone aware date time range
my_time = MDSTimeZone(
    date_time_now=datetime(2020, 1, 1, 20), # Either Now or any date as specified by datetime, becomes end_time
    offset=3600,             # Subtract 1 hour from date_time_now and becomes start_time
    time_zone="US/Central",  # US/Central
)

 # Initialize the MDS Client
mds_client = MDSClient(config=provider_configuration, provider="amazing scooters")

# Get trips
trips = mds_client.get_trips(
    # First the start time for the query
    start_time=my_time.get_time_start(
        utc=True, # Transforms local time into UTC
        unix=True # Transforms format from ISO into Unix Epoch time
    ),
    # Now the end time:
    end_time=my_time.get_time_end(
        utc=True, # Transforms local time into UTC
        unix=True # Transforms format from ISO into Unix Epoch time
    )
)

print(json.dumps(trips))

CD/CI

We make use of CircleCI for our deployments, you can see the build script in the .circleci folder in this repo. The basic process consists of a couple steps:

  1. Generate basic variables based on the current branch
  2. Change the package name based on the current branch
  3. Builds the package
  4. Deploys with twine

In short, the only way to deploy a package is to change it's version number manually in setup.py. If the changes were made in the master branch, the deployment will go into production, for the dev branch, a postfix will be added to the name of the package before it is deployed to pypi.

Development

We currently have two branches: master and dev. The master branch is used in production, our dev is meant for development and testing.

Dev & Master Postfix

For the dev branch, the build script will attach a post fix "-dev" to the package name specified in setup.py. For example, in the dev branch file setup.py we see the package name is name="atd-mds-client" and the current version was 0.0.X, if you were to change the version number and commit to the dev branch, the deployment script will deploy to pypi as atd-mds-client-dev with the new version.

Pull Requests & Local Development

Pull requests are ignored by the CD/CI pipeline, meaning they do not get built. If you need a package built for dev testing:

  • Test your script locally
  • Create a PR against the dev branch, make sure you change the version number in setup.py
  • Merge your PR branch to the dev branch

How about local development?

At the moment, local development is open-ended. You may use any python mechanism or style when including source python packages in your development and local tests.

License

The package is distributed under the GPL 3.0 license.

Metadata

Release files for atd-mds-client-dev 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for atd-mds-client-dev 0.0.3
File Size Uploaded
atd-mds-client-dev-0.0.3.tar.gz 10.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for atd-mds-client-dev 0.0.3
File Interpreter ABI Platform
atd_mds_client_dev-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 38.9 kB

Release files / atd-mds-client-dev-0.0.3.tar.gz

Download URL atd-mds-client-dev-0.0.3.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
0cc170de1aae94a475cfc3e5932c4b86d7215ae92dfcb679423d325a0d908519
BLAKE2b-256 checksum
How to use checksums
4d57c1adcdd0fbe955d7d6f76f39bb0badb15dcfd22b1d1e8d93dada6d05dcea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.8.0 tqdm/4.42.0 CPython/3.7.6

Release files / atd_mds_client_dev-0.0.3-py3-none-any.whl

Download URL atd_mds_client_dev-0.0.3-py3-none-any.whl
Size 28.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
25c8c14ca743eec07b988bd6b528e2a432ef89a95464fa28a80d5b3e4397934d
BLAKE2b-256 checksum
How to use checksums
e52a4a32907d84731e24cc1a291bd5c6d7df04fa93ac06bff1d9cccc58cda790
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.8.0 tqdm/4.42.0 CPython/3.7.6

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page