一个Python实用程序,用于交互符合Mobility数据规范的数据端点,如openmobilityfoundation所设计的那样
atd-mds-client的Python项目详细描述
atd mds客户端
与Mobility Data Specification兼容的数据端点交互的Python实用程序,由openmobilityfoundation设计。在
这个客户的灵感来自City of Santa Monica MDS Provider Client。在
安装
安装库:
pipinstallatd-mds-client
或开发部门:
^{pr2}$入门
# Import standard libraies:importjsonfromdatetimeimportdatetime# Import the MDS Library:frommdsimport*# Provider Configurationprovider_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 rangemy_time=MDSTimeZone(date_time_now=datetime(2020,1,1,20),# Either Now or any date as specified by datetime, becomes end_timeoffset=3600,# Subtract 1 hour from date_time_now and becomes start_timetime_zone="US/Central",# US/Central)# Initialize the MDS Clientmds_client=MDSClient(config=provider_configuration,provider="amazing scooters")# Get tripstrips=mds_client.get_trips(# First the start time for the querystart_time=my_time.get_time_start(utc=True,# Transforms local time into UTCunix=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 UTCunix=True# Transforms format from ISO into Unix Epoch time))print(json.dumps(trips))
CD/CI
我们在部署中使用CircleCI,您可以在这个repo的.circleci
文件夹中看到构建脚本。基本流程包括两个步骤:
- 基于当前分支生成基本变量
- 根据当前分支更改包名称
- 生成包
- 用绳线展开
简而言之,部署包的唯一方法是在setup.py
中手动更改其版本号。如果更改是在主分支中进行的,则部署将进入生产阶段,对于开发分支,在将包部署到pypi之前,将在包的名称中添加后缀。在
发展
我们目前有两个分支:master和dev。master分支用于生产,我们的dev用于开发和测试。在
开发与主后缀
对于dev分支,构建脚本将在setup.py
中指定的包名上附加一个post-fix "-dev"
。例如,在dev branch文件setup.py
中,我们看到包名是name="atd-mds-client"
,当前版本是0.0.X
,如果要更改版本号并提交到dev分支,则部署脚本将使用新版本的atd-mds-client-dev
部署到pypi。在
拉动请求和本地开发
拉请求被CD/CI管道忽略,这意味着它们不会被构建。如果您需要为开发人员测试而构建的包:
- 在本地测试脚本
- 针对dev分支创建一个PR,确保在中更改了版本号设置.py在
- 将你的公关部门合并到开发部门
地方发展怎么样?在
目前,地方发展是无止境的。在开发和本地测试中包含源python包时,可以使用任何python机制或样式。在
测试
已经对mds库进行了一些最小的单元测试;但是,测试并不彻底,它只是作为测试基本功能的一种方法来实现的。在
有关更多说明和文档,请访问以下链接: https://github.com/cityofaustin/atd-mds-client/blob/master/tests
许可证
该软件包是在gpl3.0许可下分发的。在
- 项目
标签: