Skip to content

Commit 96d437e

Browse files
Merge pull request #212 from skyflowapi/release/25.9.1
SK-2385: Public release for v2 Python SDK
2 parents d9484b1 + 255c8ec commit 96d437e

File tree

136 files changed

+5945
-2492
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+5945
-2492
lines changed

.github/workflows/shared-build-and-deploy.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ jobs:
2727
python -m pip install --upgrade pip
2828
pip install setuptools wheel twine
2929
30+
- name: Build and install skyflow package
31+
run: |
32+
python setup.py sdist bdist_wheel
33+
pip install dist/skyflow-*.whl
34+
3035
- name: Resolve Branch for the Tagged Commit
3136
id: resolve-branch
3237
if: ${{ inputs.tag == 'beta' || inputs.tag == 'public' }}

.github/workflows/shared-tests.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ jobs:
2323
with:
2424
name: "credentials.json"
2525
json: ${{ secrets.VALID_SKYFLOW_CREDS_TEST }}
26+
27+
- name: Build and install skyflow package
28+
run: |
29+
pip install --upgrade pip setuptools wheel
30+
python setup.py sdist bdist_wheel
31+
pip install dist/skyflow-*.whl
2632
2733
- name: 'Run Tests'
2834
run: |

README.md

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ table_name = '<SENSITIVE_DATA_TABLE>' # Replace with your actual table name
215215

216216
# Create Insert Request
217217
insert_request = InsertRequest(
218-
table_name=table_name,
218+
table=table_name,
219219
values=insert_data,
220220
return_tokens=True, # Optional: Get tokens for inserted data
221221
continue_on_error=True # Optional: Continue on partial errors
@@ -273,7 +273,7 @@ options = InsertOptions(
273273

274274
```python
275275
insert_request = InsertRequest(
276-
table_name=table_name, # Replace with the table name
276+
table=table_name, # Replace with the table name
277277
values=insert_data,
278278
return_tokens=False, # Do not return tokens
279279
continue_on_error=False, # Stop inserting if any record fails
@@ -474,7 +474,7 @@ try:
474474

475475
# Step 2: Create Insert Request
476476
insert_request = InsertRequest(
477-
table_name='table1', # Specify the table in the vault where the data will be inserted
477+
table='table1', # Specify the table in the vault where the data will be inserted
478478
values=insert_data, # Attach the data (records) to be inserted
479479
return_tokens=True, # Specify if tokens should be returned upon successful insertion
480480
continue_on_error=True # Optional: Continue on partial errors
@@ -551,7 +551,7 @@ try:
551551

552552
# Step 2: Build an InsertRequest object with the table name and the data to insert
553553
insert_request = InsertRequest(
554-
table_name='<TABLE_NAME>', # Replace with the actual table name in your Skyflow vault
554+
table='<TABLE_NAME>', # Replace with the actual table name in your Skyflow vault
555555
values=insert_data, # Attach the data to be inserted
556556
)
557557

@@ -608,7 +608,7 @@ try:
608608

609609
# Step 4: Build the InsertRequest object with the data records to insert
610610
insert_request = InsertRequest(
611-
table_name='table1', # Specify the table in the vault where the data will be inserted
611+
table='table1', # Specify the table in the vault where the data will be inserted
612612
values=insert_data, # Attach the data (records) to be inserted
613613
return_tokens=True, # Specify if tokens should be returned upon successful insertion
614614
continue_on_error=True # Specify to continue inserting records even if an error occurs for some records
@@ -686,7 +686,7 @@ try:
686686

687687
# Step 3: Build the InsertRequest object with the upsertData
688688
insert_request = InsertRequest(
689-
table_name='table1', # Specify the table in the vault where the data will be inserted
689+
table='table1', # Specify the table in the vault where the data will be inserted
690690
values=insert_data, # Attach the data (records) to be inserted
691691
return_tokens=True, # Specify if tokens should be returned upon successful insertion
692692
upsert='cardholder_name' # Specify the field to be used for upsert operations (e.g., cardholder_name)
@@ -1897,23 +1897,24 @@ ReidentifyTextResponse(
18971897
```
18981898

18991899
### Deidentify File
1900-
To deidentify files, use the `deidentify_file` method. The `DeidentifyFileRequest` class creates a deidentify file request, which includes the file to be deidentified and various configuration options.
1900+
To deidentify files, use the `deidentify_file` method. The `DeidentifyFileRequest` class creates a deidentify file request, supports providing either a file or a file path in class FileInput for de-identification, along with various configuration options.
19011901

19021902
#### Construct a Deidentify File request
19031903
```python
19041904
from skyflow.error import SkyflowError
19051905
from skyflow.utils.enums import DetectEntities, MaskingMethod, DetectOutputTranscriptions
1906-
from skyflow.vault.detect import DeidentifyFileRequest, TokenFormat, Transformations, Bleep
1906+
from skyflow.vault.detect import DeidentifyFileRequest, TokenFormat, Transformations, Bleep, FileInput
19071907
"""
19081908
This example demonstrates how to deidentify file, along with corresponding DeidentifyFileRequest schema.
19091909
"""
19101910
try:
19111911
# Initialize Skyflow client
19121912
# Step 1: Open file for deidentification
1913-
file = open('<FILE_PATH>', 'rb') # Open the file in read-binary mode
1913+
file_path="<FILE_PATH>"
1914+
file = open(file_path, 'rb') # Open the file in read-binary mode
19141915
# Step 2: Create deidentify file request
19151916
request = DeidentifyFileRequest(
1916-
file=file, # File object to deidentify
1917+
file=FileInput(file), # File to de-identify (can also provide a file path)
19171918
entities=[DetectEntities.SSN, DetectEntities.CREDIT_CARD], # Entities to detect
19181919

19191920
# Token format configuration
@@ -1971,7 +1972,7 @@ except Exception as error:
19711972
```python
19721973
from skyflow.error import SkyflowError
19731974
from skyflow.utils.enums import DetectEntities, MaskingMethod, DetectOutputTranscriptions
1974-
from skyflow.vault.detect import DeidentifyFileRequest, TokenFormat, Bleep
1975+
from skyflow.vault.detect import DeidentifyFileRequest, TokenFormat, Bleep, FileInput
19751976
"""
19761977
* Skyflow Deidentify File Example
19771978
*
@@ -1985,7 +1986,7 @@ try:
19851986
file = open('sensitive_document.txt', 'rb') # Open the file in read-binary mode
19861987
# Step 2: Create deidentify file request
19871988
request = DeidentifyFileRequest(
1988-
file=file, # File object to deidentify
1989+
file=FileInput(file), # File to de-identify (can also provide a file path)
19891990
entities=[
19901991
DetectEntities.SSN,
19911992
DetectEntities.CREDIT_CARD
@@ -2038,7 +2039,6 @@ DeidentifyFileResponse(
20382039
],
20392040
run_id='83abcdef-2b61-4a83-a4e0-cbc71ffabffd',
20402041
status='SUCCESS',
2041-
errors=[]
20422042
)
20432043
```
20442044

@@ -2121,7 +2121,7 @@ except Exception as error:
21212121
print('Unexpected Error:', error) # Print the stack trace for debugging purposes
21222122
```
21232123

2124-
Sample Response
2124+
Sample Response:
21252125
```python
21262126
DeidentifyFileResponse(
21272127
file='TXkgY2FyZCBudW1iZXIgaXMgW0NSRURJVF9DQVJEXQpteSBzZWNvbmQ…', # Base64 encoded file content
@@ -2142,7 +2142,26 @@ DeidentifyFileResponse(
21422142
],
21432143
run_id='48ec05ba-96ec-4641-a8e2-35e066afef95',
21442144
status='SUCCESS',
2145-
errors=[]
2145+
)
2146+
```
2147+
2148+
Incase of invalid/expired RunId:
2149+
2150+
```python
2151+
DeidentifyFileResponse(
2152+
file_base64=None,
2153+
file=None,
2154+
type='UNKNOWN',
2155+
extension=None,
2156+
word_count=None,
2157+
char_count=None,
2158+
size_in_kb=0.0,
2159+
duration_in_seconds=None,
2160+
page_count=None,
2161+
slide_count=None,
2162+
entities=[],
2163+
run_id='1e9f321f-dd51-4ab1-a014-21212fsdfsd',
2164+
status='UNKNOWN'
21462165
)
21472166
```
21482167

samples/detect_api/deidentify_file.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from skyflow.error import SkyflowError
22
from skyflow import Env, Skyflow, LogLevel
33
from skyflow.utils.enums import DetectEntities, MaskingMethod, DetectOutputTranscriptions
4-
from skyflow.vault.detect import DeidentifyFileRequest, TokenFormat, Transformations, DateTransformation, Bleep
4+
from skyflow.vault.detect import DeidentifyFileRequest, TokenFormat, Transformations, DateTransformation, Bleep, FileInput
55

66
"""
77
* Skyflow Deidentify File Example
@@ -39,7 +39,7 @@ def perform_file_deidentification():
3939
file = open(file_path, 'rb')
4040
# Step 5: Configure Deidentify File Request with all options
4141
deidentify_request = DeidentifyFileRequest(
42-
file=file, # File object to deidentify
42+
file=FileInput(file), # File to de-identify (can also provide a file path)
4343
entities=[DetectEntities.SSN, DetectEntities.CREDIT_CARD], # Entities to detect
4444
allow_regex_list=['<YOUR_REGEX_PATTERN>'], # Optional: Patterns to allow
4545
restrict_regex_list=['<YOUR_REGEX_PATTERN>'], # Optional: Patterns to restrict

samples/vault_api/insert_byot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def perform_secure_data_insertion_with_byot():
7070
]
7171

7272
insert_request = InsertRequest(
73-
table_name=table_name,
73+
table=table_name,
7474
values=insert_data,
7575
token_mode=TokenMode.ENABLE, # Enable Bring Your Own Token (BYOT)
7676
tokens=tokens, # Specify tokens to use for BYOT

samples/vault_api/insert_records.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def perform_secure_data_insertion():
4747

4848
# Step 5: Create Insert Request
4949
insert_request = InsertRequest(
50-
table_name=table_name,
50+
table=table_name,
5151
values=insert_data,
5252
return_tokens=True, # Optional: Get tokens for inserted data
5353
continue_on_error=True # Optional: Continue on partial errors

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
if sys.version_info < (3, 8):
99
raise RuntimeError("skyflow requires Python 3.8+")
10-
current_version = '2.1.0b1'
10+
current_version = '1.15.8.dev0+a22b9c6'
1111

1212
setup(
1313
name='skyflow',

0 commit comments

Comments
 (0)