将遗留的3Di模型设置导出到3Di API V3
项目描述
threedi-settings
将遗留模型设置(V2)文件转换为API V3资源。
安装
要获取此软件包提供的所有功能,请使用所有附加功能进行安装
$ pip install threedi-settings[cmd, api]
用法
在开始使用之前,请确保已正确设置以下环境变量
API_HOST=https://api.3di.live/v3.0 # no trailing slash
API_USERNAME=<your name goes here>
API_PASSWORD=<your password goes here>
这将为您提供命令行界面,让您可以将3Di模型设置转换为3Di API资源。有两种方式。要么使用模型*.ini
文件作为输入,要么使用*.sqlite
文件。
这两个命令都需要一个SIMULATION_ID
参数,因为API中只能在每个模拟的基础上定义设置。这为您提供了更多的灵活性来尝试不同的配置。
从SQLITE数据库文件导出
要使用存储在3Di模型sqlite数据库文件中的设置,请使用以下命令。请注意,数据库中存储的所有聚合设置也将导出到API V3。您可以通过--no-aggregations
标志来抑制此行为。
export-settings export-from-sqlite --help
Usage: export-settings export-from-sqlite [OPTIONS] SIMULATION_ID SQLITE_FILE
[SETTINGS_ROW]
"Create API V3 settings resources from legacy model sqlite file"
Arguments:
SIMULATION_ID [required]
SQLITE_FILE SQLITE model file. [required]
[SETTINGS_ROW] Specify the row id of the v2_global_settings entry you want
to export. [default: 1]
Options:
--aggregations / --no-aggregations
If the '--no-aggregations' option is not
explicitly set, the aggregation settings
found in the sqlite file will be exported,
too. [default: True]
--help Show this message and exit.
如果您不确定SETTINGS_ROW
参数,可以通过运行以下命令快速列出数据库中的现有行
global-settings ls --help
Usage: global-settings ls [OPTIONS] SQLITE_FILE
Shows id and name of existing global settings entries
Arguments:
SQLITE_FILE SQLITE model file. [required]
Options:
--help Show this message and exit.
从ini(和聚合)文件导出
如果您可以访问模型ini文件,以及可选的相应聚合文件,您可以使用
export-settings export-from-ini --help
Usage: export-settings export-from-ini [OPTIONS] SIMULATION_ID INI_FILE
[AGGREGATION_FILE]
"Create API V3 settings resources from legacy model ini file"
Arguments:
SIMULATION_ID [required]
INI_FILE Legacy model settings ini file. [required]
[AGGREGATION_FILE] Legacy model aggregation settings file.
Options:
--help Show this message and exit.
API V3模拟设置字段概述
API V3中大多数设置字段已被重命名。要了解所有可用字段、它们的描述、合适的默认值等,请使用describe-simulation-settings
命令。
describe-simulation-settings --help
Usage: describe-simulation-settings [OPTIONS]
Shows all API V3 simulation settings fields, help texts on how to use
them, suitable defaults, types etc.
Options:
--help Show this message and exit.
内部使用
此包还用于从API检索模拟设置资源,以便将它们进一步转换为3Di计算核心能够读取和处理的内部格式。
因此,您可以不安装上述额外内容或单个额外内容(如api
),这将提供threedi-api-client
需求,因此可以访问http模块。
- 免费软件:MIT许可
- 文档:https://threedi-settings.readthedocs.io。
致谢
此包是用Cookiecutter和audreyr/cookiecutter-pypackage项目模板创建的。
历史记录
0.0.6 (2021-05-05)
- 将常规设置重命名为物理设置
0.0.5 (2021-04-22)
-
更新readme中所需的env变量。
-
修复导出边缘情况。
0.0.4 (2021-04-16)
-
添加从sqlite文件导出的命令。
-
添加列出给定sqlite文件的全球设置条目的命令。
-
添加显示模拟设置API V3字段描述的命令。
0.0.3 (2021-04-07)
- 单元测试。
0.0.2 (2021-03-26)
-
设置适当的包,包括readme。
-
文档字符串和代码组织。
0.0.1 (2021-03-18)
- 首次发布在PyPI上。