Skip to content

Commit c481a5f

Browse files
SK-2415 Addressed review comments
1 parent 8e3e949 commit c481a5f

File tree

3 files changed

+46
-32
lines changed

3 files changed

+46
-32
lines changed

README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ config = {
128128
}
129129

130130
# Initialize Skyflow client
131-
client = (
131+
skyflow_client = (
132132
Skyflow.builder()
133133
.add_vault_config(config)
134134
.set_log_level(LogLevel.ERROR)
@@ -164,7 +164,7 @@ insert_response = skyflow_client.vault('<VAULT_ID>').insert(insert_request)
164164
print('Insert response:', insert_response)
165165
```
166166

167-
## Upgrade from V1 to V2
167+
## Upgrade from v1 to v2
168168

169169
Upgrade from `skyflow-python` v1 using the dedicated guide in [docs/migrate_to_v2.md](docs/migrate_to_v2.md).
170170

@@ -646,6 +646,8 @@ The SDK accepts one of several types of credentials object.
646646
JSON-formatted string containing service account credentials. Use when integrating with secret management systems or when credentials are passed programmatically.
647647

648648
```python
649+
import os
650+
649651
credentials = {
650652
"credentials_string": os.getenv("SKYFLOW_CREDENTIALS")
651653
}
@@ -717,7 +719,7 @@ Digitally sign data tokens with a service account's private key to add an extra
717719
718720
## Logging
719721

720-
The SDK provides logging using python's inbuilt `logging` library. By default the logging level of the SDK is set to `LogLevel.ERROR`. This can be changed by using `set_log_level(log_level)` as shown below:
722+
The SDK provides logging using Python's inbuilt `logging` library. By default the logging level of the SDK is set to `LogLevel.ERROR`. This can be changed by using `set_log_level(log_level)` as shown below:
721723

722724
Currently, the following five log levels are supported:
723725

@@ -737,7 +739,15 @@ When `LogLevel.ERROR` is passed, only ERROR logs will be printed.
737739
### Example: Setting LogLevel to INFO
738740

739741
```python
740-
from skyflow import Skyflow, LogLevel
742+
from skyflow import Skyflow, LogLevel, Env
743+
744+
# Define vault configuration
745+
vault_config = {
746+
'vault_id': '<VAULT_ID>',
747+
'cluster_id': '<CLUSTER_ID>',
748+
'env': Env.PROD,
749+
'credentials': {'api_key': '<API_KEY>'}
750+
}
741751

742752
skyflow_client = (
743753
Skyflow.builder()
@@ -754,6 +764,8 @@ skyflow_client = (
754764
Wrap your calls to the Skyflow SDK in try/except blocks as a best practice. Use the `SkyflowError` class to identify errors coming from Skyflow versus general request/response errors.
755765

756766
```python
767+
from skyflow.error import SkyflowError
768+
757769
try:
758770
# ...call the Skyflow SDK
759771
pass

docs/auth_credentials.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Authentication credentials options
22

3-
> **Note:** Only one type of credential can be used at a time. If multiple credentials are provided, the order of precedence depends on how they are passed to the configuration.
3+
> **Note:** Only one type of credential can be used at a time. If multiple credentials are provided, the last one added takes precedence.
44
55
1. **API keys**
66
A unique identifier used to authenticate and authorize requests to an API.
@@ -41,4 +41,4 @@
4141
```
4242

4343
5. **Environment variables**
44-
If no credentials are explicitly provided the SDK automatically looks for the SKYFLOW_CREDENTIALS environment variable. This variable must return an object like one of the examples above.
44+
If no credentials are explicitly provided, the SDK automatically looks for the `SKYFLOW_CREDENTIALS` environment variable. This variable must contain a JSON string like one of the examples above.

docs/migrate_to_v2.md

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# Migrate from V1 to V2
1+
# Migrate from v1 to v2
22

3-
This guide outlines the steps required to migrate the Skyflow Python SDK from version 1 (V1) to version 2 (V2).
3+
This guide outlines the steps required to migrate the Skyflow Python SDK from version 1 (v1) to version 2 (v2).
44

55
## Authentication
66

7-
In V2, multiple authentication options have been introduced. You can now provide credentials in the following ways:
7+
In v2, multiple authentication options have been introduced. You can now provide credentials in the following ways:
88

99
- **Passing credentials in ENV** (`SKYFLOW_CREDENTIALS`) (**Recommended**)
1010
- **API Key**
@@ -14,7 +14,7 @@ In V2, multiple authentication options have been introduced. You can now provide
1414

1515
These options allow you to choose the authentication method that best suits your use case.
1616

17-
### V1 (Old): Passing the token provider function below as a parameter to the Configuration.
17+
### v1 (Old): Passing the token provider function below as a parameter to the Configuration.
1818

1919
```python
2020
# User defined function to provide access token to the vault apis
@@ -26,7 +26,7 @@ def token_provider():
2626
return bearer_token
2727
```
2828

29-
#### V2 (New): Passing one of the following:
29+
#### v2 (New): Passing one of the following:
3030

3131
```python
3232
# Option 1: API Key (Recommended)
@@ -60,23 +60,23 @@ credentials = {
6060

6161
### Initializing the client
6262

63-
In V2, we have introduced a Builder design pattern for client initialization and added support for multi-vault. This allows you to configure multiple vaults during client initialization.
63+
In v2, we have introduced a Builder design pattern for client initialization and added support for multi-vault. This allows you to configure multiple vaults during client initialization.
6464

6565
During client initialization, you can pass the following parameters:
6666

6767
- **`vault_id`** and **`cluster_id`**: These values are derived from the vault ID & vault URL.
6868
- **`env`**: Specify the environment (e.g., SANDBOX or PROD).
6969
- **`credentials`**: The necessary authentication credentials.
7070

71-
#### V1 (Old):
71+
#### v1 (Old):
7272

7373
```python
7474
# Initializing a Skyflow Client instance with a SkyflowConfiguration object
7575
config = Configuration('<VAULT_ID>', '<VAULT_URL>', token_provider)
7676
client = Client(config)
7777
```
7878

79-
#### V2 (New):
79+
#### v2 (New):
8080

8181
```python
8282
# Initializing a Skyflow Client instance
@@ -101,14 +101,14 @@ client = (
101101

102102
### Request & Response Structure
103103

104-
In V2, with the introduction of constructor parameters, you can now pass parameters to `InsertRequest`. This request needs
104+
In v2, with the introduction of constructor parameters, you can now pass parameters to `InsertRequest`. This request needs
105105
- **`table_name`**: The name of the table.
106106
- **`values`**: An array of objects containing the data to be inserted.
107107
The response will be of type `InsertResponse` class, which contains `inserted_fields` and errors.
108108

109109
**Note:** Similar patterns apply to other operations like Get, Update, Delete. See the [README](../README.md) for complete examples.
110110

111-
#### V1 (Old): Request Building
111+
#### v1 (Old): Request Building
112112

113113
```python
114114
client.insert(
@@ -127,9 +127,11 @@ client.insert(
127127
)
128128
```
129129

130-
#### V2 (New): Request Building
130+
#### v2 (New): Request Building
131131

132132
```python
133+
from skyflow.vault.data import InsertRequest
134+
133135
# Prepare Insertion Data
134136
insert_data = [
135137
{
@@ -152,7 +154,7 @@ insert_request = InsertRequest(
152154
response = skyflow_client.vault(primary_vault_config.get('<VAULT_ID>')).insert(insert_request)
153155
```
154156

155-
#### V1 (Old): Response Structure
157+
#### v1 (Old): Response Structure
156158

157159
```json
158160
{
@@ -170,7 +172,7 @@ response = skyflow_client.vault(primary_vault_config.get('<VAULT_ID>')).insert(i
170172
}
171173
```
172174

173-
#### V2 (New): Response Structure
175+
#### v2 (New): Response Structure
174176

175177
```python
176178
InsertResponse(
@@ -186,40 +188,40 @@ InsertResponse(
186188

187189
### Request Options
188190

189-
In V2, we have introduced constructor parameters, allowing you to set options as key-value pairs as parameters in request.
191+
In v2, we have introduced constructor parameters, allowing you to set options as key-value pairs as parameters in request.
190192

191-
#### V1 (Old):
193+
#### v1 (Old):
192194

193195
```python
194196
options = InsertOptions(
195197
tokens = True
196198
)
197199
```
198200

199-
#### V2 (New):
201+
#### v2 (New):
200202

201203
```python
202204
insert_request = InsertRequest(
203-
table=table_name, # Replace with the table name
204-
values=insert_data,
205-
return_tokens=False, # Do not return tokens
206-
continue_on_error=False, # Stop inserting if any record fails
207-
upsert='<UPSERT_COLUMN>', # Replace with the column name used for upsert logic
208-
token_mode=TokenMode.DISABLE, # Disable BYOT
209-
tokens='<TOKENS>' # Replace with tokens when TokenMode is ENABLE.
205+
table=table_name, # Replace with the table name
206+
values=insert_data,
207+
return_tokens=False, # Do not return tokens
208+
continue_on_error=False, # Stop inserting if any record fails
209+
upsert='<UPSERT_COLUMN>', # Replace with the column name used for upsert logic, if any
210+
token_mode=TokenMode.DISABLE, # Disable BYOT
211+
tokens='<TOKENS>' # Set with tokens when TokenMode is ENABLE
210212
)
211213
```
212214

213215
### Error Structure
214216

215-
In V2, we have enriched the error details to provide better debugging capabilities.
217+
In v2, we have enriched the error details to provide better debugging capabilities.
216218
The error response now includes:
217219
- **http_status**: The HTTP status code.
218220
- **grpc_code**: The gRPC code associated with the error.
219221
- **details** & **message**: A detailed description of the error.
220222
- **request_id**: A unique request identifier for easier debugging.
221223

222-
#### V1 (Old) Error Structure:
224+
#### v1 (Old) Error Structure:
223225

224226
```json
225227
{
@@ -228,7 +230,7 @@ The error response now includes:
228230
}
229231
```
230232

231-
#### V2 (New) Error Structure:
233+
#### v2 (New) Error Structure:
232234

233235
```python
234236
{

0 commit comments

Comments
 (0)