
Communications Mining 用户指南
re
. It assumes you have installed the CLI. For more details, check the installation instructions.
The quick setup section is a short step-by-step reference for how to get started and configure the CLI. The rest of the page contains detailed instructions and goes into all of the available options.
Install the command line tool for your platform (Linux, Mac, and Windows are supported).
Create a named context to avoid having to enter your tenant endpoint and API token every time. Provide your tenant endpoint:
re config add --name main --endpoint https://<my_api_endpoint>/
re config add --name main --endpoint https://<my_api_endpoint>/
You will be asked to paste your API token:
I A new context `main` will be created.
Enter API token [none]: MYSUPERSECRETTOKEN
I New context `main` was created.
I A new context `main` will be created.
Enter API token [none]: MYSUPERSECRETTOKEN
I New context `main` was created.
尝试运行命令以检查是否一切正常,例如
re get datasets
re get datasets
-c
或--context
全局标志,以在命令中使用特定上下文,例如
re -c main get datasets
re -c main get datasets
--token
、 --endpoint
和--proxy
等) 一次性覆盖任何上下文设置。命令行参数优先于上下文设置。
re
将提示您以交互方式输入令牌。
例如,列出可用的数据集
➜ re --endpoint https://acme.reinfer.io get datasets
input: Enter API token [none]: MYSUPERSECRETAPITOKEN
Name ID Updated (UTC) Title
InvestmentBank/collateral-streams aa9dda7c059e5a8d 2019-04-30 17:25:03 IB Collateral Streams
InvestmentBank/george-test 1aaeacd49dfce8a0 2019-05-10 15:32:34 Test Dataset
InvestmentBank/margin-call b9d50fb2b38c3af5 2019-05-08 07:51:09 IB Margin Call
InvestmentBank/margin-call-large 6d00b9f69ab059f6 2019-05-11 09:23:43 IB Margin Call Large
➜ re --endpoint https://acme.reinfer.io get datasets
input: Enter API token [none]: MYSUPERSECRETAPITOKEN
Name ID Updated (UTC) Title
InvestmentBank/collateral-streams aa9dda7c059e5a8d 2019-04-30 17:25:03 IB Collateral Streams
InvestmentBank/george-test 1aaeacd49dfce8a0 2019-05-10 15:32:34 Test Dataset
InvestmentBank/margin-call b9d50fb2b38c3af5 2019-05-08 07:51:09 IB Margin Call
InvestmentBank/margin-call-large 6d00b9f69ab059f6 2019-05-11 09:23:43 IB Margin Call Large
--token
指定令牌➜ re --endpoint https://acme.reinfer.io --token MYSUPERSECRETAPITOKEN get datasets
➜ re --endpoint https://acme.reinfer.io --token MYSUPERSECRETAPITOKEN get datasets
这通常不是一个好主意,因为 API 令牌将存储在您的 Shell 历史记录中。 最好将 API 令牌存储在环境变量中。
➜ re --endpoint https://acme.reinfer.io --token $REINFER_TOKEN get datasets
➜ re --endpoint https://acme.reinfer.io --token $REINFER_TOKEN get datasets
但是,这仍然过于冗长、重复和不安全。
在某些情况下,使用命令行标志提供配置可能很有用。但是,建议使用 CLI 的方式是配置命名上下文。有关更多详细信息,请查看以下部分。
re
命令的设置和凭据的集合。 当您指定上下文以运行命令时,设置和凭据将用于运行该命令。 配置文件中可以存储多个上下文。
上下文有助于避免在使用每个命令时手动指定令牌、端点和其他配置。上下文由以下部分组成:
- 用作上下文标识符的好记名称
- 用于对发出请求的用户进行身份验证的API 令牌
- CLI 将向其发出请求的端点
- (可选) 用于所有请求的HTTP 代理
- (可选)是否接受来自端点的无效 TLS 证书(仅适用于内部/开发 Communications Mining™ 集群)
您可以指定在未显式引用任何上下文时使用的默认上下文。
-c
和--context
标志可用于使用特定上下文具有的名称,您可以在命令行上将其指定为单个命令的参数。
创建上下文
re config add
re config add
如果在不使用任何选项的情况下运行,则该命令将以交互方式询问上下文名称、端点和令牌。
➜ re config add
* Context name: acme-prod
I A new context `acme-prod` will be created
* Enter API token [none]: MYSUPERSECRETTOKEN
* Endpoint [https://reinfer.io/]: https://acme.reinfer.io
I Default context set to `acme-prod`
I New context `acme-prod` was created
➜ re config add
* Context name: acme-prod
I A new context `acme-prod` will be created
* Enter API token [none]: MYSUPERSECRETTOKEN
* Endpoint [https://reinfer.io/]: https://acme.reinfer.io
I Default context set to `acme-prod`
I New context `acme-prod` was created
创建第一个上下文时,系统会将其设置为活动上下文
➜ re config add --name acme-dev --endpoint https://acme.reinfer.io/
I A new context `acme-dev` will be created.
* Enter API token [none]: MYSUPERSECRETTOKEN
I Default context set to `acme-dev`
I New context `acme-dev` was created.
➜ re config add --name acme-dev --endpoint https://acme.reinfer.io/
I A new context `acme-dev` will be created.
* Enter API token [none]: MYSUPERSECRETTOKEN
I Default context set to `acme-dev`
I New context `acme-dev` was created.
如果添加已存在名称的上下文,则会更新该上下文。
# Edit the acme-dev context if it already exists
re config add acme-dev
# Edit the acme-dev context if it already exists
re config add acme-dev
re config add -h
。其中最重要的是:
名称 | 说明 |
--name <name> | 将要创建或更新的上下文的名称 |
--endpoint <endpoint> | 将用于此上下文的 Communications Mining™ 集群端点 |
--token <token> | 将用于此上下文的重新推断 API 令牌 |
--proxy <proxy> | 指定后将用于所有请求的 HTTP 代理的 URL |
当前上下文将用于所有后续命令。 以下内容将打印当前上下文的所有数据集。
re get datasets
re get datasets
--token
、 --endpoint
和--proxy
一次性覆盖任何上下文设置。re --proxy http://proxy.example get datasets
re --proxy http://proxy.example get datasets
使用上下文
-c
或--context
全局标志,以在命令中使用特定上下文,例如
re -c my-context get datasets
re -c my-context get datasets
重新配置
re config
命令的作用域内。 子命令用于创建、更新、设置默认值和删除上下文等。
For all the available options, check the command reference.
配置目录的位置因操作系统而异。Communications Mining™ 命令行工具遵循这些操作系统默认设置,通常可在以下位置找到配置目录
- Linux 上的
~/.config/reinfer
- macOS 上的
$HOME/.config/reinfer
- Windows 上的
%AppData%\reinfer
contexts.json
中,例如 Linux 上的~/.config/reinfer/contexts.json
。 它看起来像这样
{
"current_context": "prod",
"contexts": [
{
"name": "prod",
"endpoint": "https://acme.reinfer.io/",
"token": "MYSUPERSECRETTOKEN",
"accept_invalid_certificates": false,
"proxy": null
}
]
}
{
"current_context": "prod",
"contexts": [
{
"name": "prod",
"endpoint": "https://acme.reinfer.io/",
"token": "MYSUPERSECRETTOKEN",
"accept_invalid_certificates": false,
"proxy": null
}
]
}