-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: reflect new configuration setup
Signed-off-by: Panos Vagenas <[email protected]>
- Loading branch information
Showing
9 changed files
with
94 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,31 +6,26 @@ After registering with [Deep Search](https://ds4sd.github.io/), you can obtain y | |
|
||
|
||
--- | ||
### Configure a profile | ||
### Set up a profile | ||
|
||
=== "CLI" | ||
Configure a profile using [`deepsearch profile config`](../cli-reference.md#profile). | ||
Set up a [profile][profiles] using `deepsearch profile config`. | ||
In its basic form it looks like this: | ||
<div class="termy"> | ||
|
||
```console | ||
$ deepsearch profile config | ||
|
||
Host: # (1) | ||
Username: # (2) | ||
Api key: # (3) | ||
Host: https://ds.example.com # the Deep Search instance you are using | ||
Username: [email protected] # your username | ||
Api key: (hidden) # your API key | ||
``` | ||
|
||
</div> | ||
|
||
1. Input the Deep Search deployment host to use. | ||
2. Enter your `User name`. | ||
3. Enter your `API key`. | ||
|
||
By providing a profile name (via option `--profile-name`) you can configure multiple | ||
different profiles, which you can then easily switch between and manage. | ||
|
||
For details, check [Profiles](../guide/configuration.md#profiles). | ||
For details, check [Profiles][profiles]. | ||
|
||
### Validate the setup | ||
|
||
|
@@ -89,3 +84,6 @@ Here, we show a simple way to convert documents using [Deep Search](https://ds4s | |
``` | ||
|
||
--- | ||
|
||
|
||
[profiles]: ../guide/configuration.md#profiles |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
# Configuration | ||
|
||
The Toolkit can be configured both via the CLI and via | ||
environment variables. | ||
The Toolkit can be configured via the CLI and via environment variables. | ||
|
||
Besides *global* settings, the Toolkit also allows the configuration of multiple | ||
*profiles* for enabling users to easily work with different Deep Search deployments. | ||
|
||
## Profiles | ||
|
||
The Toolkit provides the capability of easily interacting with different Deep Search | ||
instances through the use of *profiles*. A user may define multiple profiles, identified | ||
by profile name, and can easily switch between them. | ||
|
||
### Overview | ||
|
||
For an overview of the profile management commands check `deepsearch profile --help`: | ||
|
@@ -32,8 +35,8 @@ $ deepsearch profile --help | |
|
||
### Profile setup | ||
|
||
To setup a profile use [`deepsearch profile config`](../cli-reference.md#profile), | ||
providing options as needed (for a full reference run with `--help`). | ||
To set up a profile use `deepsearch profile config`, providing options as needed (for a | ||
full reference check `deepsearch profile config --help`). | ||
|
||
Here is a basic invocation example: | ||
|
||
|
@@ -44,76 +47,70 @@ Username: [email protected] | |
Api key: | ||
``` | ||
|
||
> NOTE: If you had used the meanwhile deprecated `deepsearch login` command to set up a | ||
config file in the default location, that will automatically be migrated to a profile. | ||
!!! note | ||
If you had used the meanwhile deprecated `deepsearch login` command to set up a | ||
config file in the default location, that will automatically be migrated to a profile. | ||
|
||
### Usage | ||
|
||
Here some usage examples: | ||
|
||
=== "CLI" | ||
|
||
```console | ||
$ # configure a profile | ||
$ deepsearch profile config --profile-name foo --host ds-1.example.com ... | ||
$ # -> "foo" now available and selected as the active profile | ||
$ | ||
$ deepsearch cps projects list | ||
$ # -> outputs projects corresponding to "foo" | ||
$ | ||
$ # configure another profile | ||
$ deepsearch profile config --profile-name bar --host ds-2.example.com ... | ||
$ # -> "bar" now available and selected as the active profile | ||
$ | ||
$ deepsearch profile list | ||
$ # -> displays all profiles, with "bar" marked as the active one | ||
$ | ||
$ deepsearch cps projects list | ||
$ # -> outputs projects corresponding to "bar" | ||
$ | ||
$ # switch to previous profile | ||
$ deepsearch profile use foo | ||
$ # -> "foo" now selected as the active profile | ||
$ | ||
$ deepsearch cps projects list | ||
$ # -> outputs projects corresponding to "foo" | ||
``` | ||
|
||
=== "Python" | ||
|
||
```python | ||
from deepsearch.cps.client.api import CpsApi | ||
|
||
# using the active profile; let's assume that is "foo" | ||
api = CpsApi.from_env() | ||
print([p.name for p in api.projects.list()]) | ||
# -> outputs projects corresponding to "foo" | ||
|
||
# using a profile by name | ||
api = CpsApi.from_env(profile_name="bar") | ||
print([p.name for p in api.projects.list()]) | ||
# -> outputs projects corresponding to "bar" | ||
``` | ||
|
||
--- | ||
#### Usage in CLI | ||
|
||
```console | ||
$ # configure a profile | ||
$ deepsearch profile config --profile-name foo --host ds-1.example.com ... | ||
$ # -> "foo" now available and selected as the active profile | ||
$ | ||
$ deepsearch cps projects list | ||
$ # -> outputs projects corresponding to "foo" | ||
$ | ||
$ # configure another profile | ||
$ deepsearch profile config --profile-name bar --host ds-2.example.com ... | ||
$ # -> "bar" now available and selected as the active profile | ||
$ | ||
$ deepsearch profile list | ||
$ # -> displays all profiles, with "bar" marked as the active one | ||
$ | ||
$ deepsearch cps projects list | ||
$ # -> outputs projects corresponding to "bar" | ||
$ | ||
$ # switch to previous profile | ||
$ deepsearch profile use foo | ||
$ # -> "foo" now selected as the active profile | ||
$ | ||
$ deepsearch cps projects list | ||
$ # -> outputs projects corresponding to "foo" | ||
``` | ||
|
||
## Environment variables | ||
#### Usage in Python | ||
|
||
Under the hood, configuration management in the Toolkit is implemented based on [Pydantic | ||
Settings with dotenv support](https://docs.pydantic.dev/1.10/usage/settings). | ||
To use the active profile (recommended usage pattern): | ||
```python | ||
from deepsearch.cps.client.api import CpsApi | ||
|
||
Configuration is persisted in Toolkit-managed dotenv files, but can be overriden via | ||
environment variables. | ||
api = CpsApi.from_env() | ||
|
||
To see which environment variables are supported, check the relevant [Pydantic Settings | ||
classes][settings_file], also taking into account any defined prefixes. | ||
print([p.name for p in api.projects.list()]) | ||
# -> outputs projects corresponding to active profile | ||
``` | ||
|
||
For example you can set the profile for the scope of a single operation (e.g. a project | ||
listing) as follows: | ||
To use a specific profile: | ||
```python | ||
from deepsearch.cps.client.api import CpsApi | ||
|
||
```console | ||
DEEPSEARCH_PROFILE=bar deepsearch cps projects list | ||
api = CpsApi.from_env(profile_name="foo") | ||
|
||
print([p.name for p in api.projects.list()]) | ||
# -> outputs projects corresponding to "foo" | ||
``` | ||
|
||
## Environment variables | ||
|
||
Under the hood, the Toolkit leverages [Pydantic Settings with dotenv | ||
support][pydantic_settings], so configuration settings can be easily overriden via | ||
environment variables. This can be useful e.g. in a containerization scenario. | ||
|
||
To see which environment variables are supported, check the relevant [Pydantic Settings | ||
classes][settings_file], also taking into account any defined prefixes. | ||
|
||
[pydantic_settings]: https://docs.pydantic.dev/dev-v1/usage/settings | ||
[settings_file]: https://github.com/DS4SD/deepsearch-toolkit/blob/main/deepsearch/core/client/settings.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters