-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
123 additions
and
2 deletions.
There are no files selected for viewing
111 changes: 111 additions & 0 deletions
111
apps/opik-documentation/documentation/docs/tracing/sdk_configuration.mdx
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 |
---|---|---|
@@ -0,0 +1,111 @@ | ||
--- | ||
sidebar_position: 5 | ||
sidebar_label: Python SDK Configuration | ||
toc_min_heading_level: 2 | ||
toc_max_heading_level: 4 | ||
--- | ||
|
||
import Tabs from "@theme/Tabs"; | ||
import TabItem from "@theme/TabItem"; | ||
|
||
# Python SDK Configuration | ||
|
||
The recommended approach to configuring the Python SDK is to use the `opik configure` command. This will prompt you for the necessary information and save it to a configuration file. | ||
|
||
<Tabs> | ||
<TabItem value="Opik Cloud" title="Opik Cloud"> | ||
|
||
If you are using the Cloud version of the platform, you can configure the SDK by running: | ||
|
||
```python | ||
import opik | ||
|
||
opik.configure(use_local=False) | ||
``` | ||
|
||
You can also configure the SDK by calling [`configure`](https://www.comet.com/docs/opik/python-sdk-reference/cli.html) from the Command line: | ||
|
||
```bash | ||
opik configure | ||
``` | ||
|
||
</TabItem> | ||
<TabItem value="Self-hosting" title="Self-hosting"> | ||
If you are self-hosting the platform, you can configure the SDK by running: | ||
|
||
```python | ||
import opik | ||
|
||
opik.configure(use_local=True) | ||
``` | ||
|
||
or from the Command line: | ||
|
||
```bash | ||
opik configure --use_local | ||
``` | ||
|
||
</TabItem> | ||
</Tabs> | ||
|
||
The `configure` methods will prompt you for the necessary information and save it to a configuration file (`~/.opik.config`). | ||
|
||
## Advanced usage | ||
|
||
In addition to the `configure` method, you can also configure the Python SDK in a couple of different ways: | ||
1. Using a configuration file | ||
2. Using environment variables | ||
|
||
### Using a configuration file | ||
|
||
The `configure` method is a helper method to help you create the Opik SDK configuration file but you can also manually create the configuration file. | ||
|
||
The Opik configuration file follows the [TOML](https://github.com/toml-lang/toml) format, here is an example configuration file: | ||
|
||
<Tabs> | ||
<TabItem value="Opik Cloud" title="Opik Cloud"> | ||
|
||
```toml | ||
[opik] | ||
url_override = https://www.comet.com/opik/api | ||
workspace = <Workspace name> | ||
api_key = <API Key> | ||
``` | ||
|
||
</TabItem> | ||
<TabItem value="Self-hosting" title="Self-hosting"> | ||
```toml | ||
[opik] | ||
url_override = http://localhost:5173/api | ||
workspace = default | ||
``` | ||
</TabItem> | ||
</Tabs> | ||
|
||
|
||
You can find a full list of the the configuration options in the [Configuration values section](/tracing/sdk_configuration#configuration-values) below. | ||
|
||
:::tip | ||
By default, the SDK will look for the configuration file in your home directory (`~/.opik.config`). If you would like to specify a different location, you can do so by setting the `OPIK_CONFIG_PATH` environment variable. | ||
::: | ||
|
||
### Using environment variables | ||
|
||
If you do not wish to use a configuration file, you can set environment variables to configure the SDK. The most common configuration values are: | ||
|
||
- `OPIK_URL_OVERRIDE`: The URL of the Opik server to use - Defaults to `https://www.comet.com/opik/api` | ||
- `OPIK_API_KEY`: The API key to use - Only required if you are using the Opik Cloud version of the platform | ||
- `OPIK_WORKSPACE`: The workspace to use - Only required if you are using the Opik Cloud version of the platform | ||
|
||
You can find a full list of the the configuration options in the [Configuration values section](/tracing/sdk_configuration#configuration-values) below. | ||
|
||
### Configuration values | ||
|
||
Here is a list of the configuration values that you can set: | ||
|
||
| Configuration Name | Environment variable | Description | | ||
| url_override | `OPIK_URL_OVERRIDE` | The URL of the Opik server to use - Defaults to `https://www.comet.com/opik/api` | | ||
| api_key | `OPIK_API_KEY` | The API key to use - Only required if you are using the Opik Cloud version of the platform | | ||
| workspace | `OPIK_WORKSPACE` | The workspace to use - Only required if you are using the Opik Cloud version of the platform | | ||
| project_name | `OPIK_PROJECT_NAME` | The project name to use | | ||
| default_flush_timeout | `OPIK_DEFAULT_FLUSH_TIMEOUT` | The default flush timeout to use - Defaults to no timeout | |
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