City Proto Generated Python SDK
Project description
Protos
proto 文件仓库。
内容
city.agent: 智能体city.cognition: 认知city.comm: 通信city.config: 配置文件基本组件city.elec: 电网city.event: 城市事件city.geo: 坐标体系city.map: 地图city.routing: 路径规划city.social: 社交city.streetview: 街景city.sync: 全局同步器city.traffic: 交通city.traffic_light: 信控city.trip: 出行与日程city.wargame: 兵棋city.water: 水网
STYLE
以buf作为 linter,按 buf 的要求作为标准。
另外,为避免二义性,所有不在完全相同命名空间下的跨文件引用均需要写出完成包名。
在相同命名空间下的,不要引入包名(主要是针对xxx.proto与xxx_service.proto)。
参考:
- https://developers.google.com/protocol-buffers/docs/style
- https://github.com/uber/prototool/blob/dev/style/README.md
关于 enum: prefer uber 的 style
- 独立定义 enum,不嵌入 message
- enum 的 item 名称加 enum name 作为前缀
约定
- 所有浮点数采用 double 精度。
- .proto 中不包含任何
option,需要指定option的目标语言采用buf managed mode进行管理。 - 采用聚合性质的 message 作为 mongodb collection 的语义表示,并便于开发 Golang 的数据读取代理。
BSON兼容性
完全支持通过 Golang struct tag 机制实现 bson 到 pb 的快速转换,并删去不能在 bson 中体现的语义:
- 所有的
oneof由 optional 替代,oneof的功能依靠约定实现。- 原因:struct tag 无法正确处理
oneof,bson无法体现oneof语义,oneof语义实际作用价值不大,目前主要体现在map_position与departure中。
- 原因:struct tag 无法正确处理
- 所有的
float替换为double。- 原因:
bson中没有float32,python没有float32,C++在 64 位 CPU 上采用float32与float64计算速度相同。
- 原因:
- 所有的
uint32替换为int32。- 原因:
bson中没有uint,python没有uint,同时简化C++与go代码编写(统一用int32)。
- 原因:
- 枚举在
bson中存储由字符串替换为整数。- struct tag 无法正确处理字符串形式的枚举。
- 丰富
bson中的 external 数据项,解决关联到原始数据的问题。
更新与Golang/Python库发布
完成git仓库修改后,执行以下命令:
git tag v${major}.${minor}.${patch} # 例如 v0.1.0,设置版本号
git push --tags # 推送版本号
Golang库使用
go get -u git.fiblab.net/sim/protos@v${major}.${minor}.${patch}
Python库使用
pip install pycityproto --extra-index-url https://__token__:glpat-fq6C-NTr45Z_Te4BV4kC@git.fiblab.net/api/v4/projects/26/packages/pypi/simple
安装 grpcio 的过程中,如果出现
pip install fails with "No such file or directory: 'c++': 'c++'"
代表缺少 C++相关依赖。在 Debian 镜像上,执行:
sudo apt install build-essential
在 alpine 镜像上,执行:
apk add g++
JS/TS
NPM
首先,保证项目已经能够正确访问NPM服务
npm config set @fiblab:registry https://git.fiblab.net/api/v4/projects/26/packages/npm/
npm config set -- '//git.fiblab.net/api/v4/projects/26/packages/npm/:_authToken' "glpat-sdKgi23Ns3KvfpyrREzy"
然后,使用npm install命令安装SDK:
npm install @fiblab/cityproto
Yarn
首先,保证项目已经能够正确访问NPM服务
yarn config set @fiblab:registry https://git.fiblab.net/api/v4/projects/26/packages/npm/
# 以下未经测试
yarn config set -- '//git.fiblab.net/api/v4/projects/26/packages/npm/:_authToken' "glpat-sdKgi23Ns3KvfpyrREzy"
然后,使用npm install命令安装SDK:
yarn add @fiblab/cityproto
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pycityproto-1.12.0.tar.gz.
File metadata
- Download URL: pycityproto-1.12.0.tar.gz
- Upload date:
- Size: 90.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94fc61ebe74d25b5a6b3c39e29f65b2717910c6f78e4a33764e86541251d379b
|
|
| MD5 |
ee9beb812afdf91cccd774cb7f942959
|
|
| BLAKE2b-256 |
1d33a01ed0b5424d6c53be1d41f71756939400fe344fd891f0f60aaa157d635b
|
File details
Details for the file pycityproto-1.12.0-py3-none-any.whl.
File metadata
- Download URL: pycityproto-1.12.0-py3-none-any.whl
- Upload date:
- Size: 184.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f497fe05a3992119a811f4ec71cebe05c116a647eeb491791efe959c99a22e2c
|
|
| MD5 |
7951f81dda00e25d5ebc2266d6967519
|
|
| BLAKE2b-256 |
6dc3cf2ff6a32b30e3d6c46307321a64dc935441193c4b09c696f7b317e35b64
|