Skip to content

Commit ae68c09

Browse files
Sid MohanSid Mohan
authored andcommitted
pre-commit run pass
1 parent 750570e commit ae68c09

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

examples/uploading-file-types.ipynb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
"metadata": {},
123123
"outputs": [],
124124
"source": [
125-
"%pip list\n"
125+
"%pip list"
126126
]
127127
},
128128
{
@@ -141,8 +141,7 @@
141141
"source": [
142142
"input_file = \"/Users/sidmohan/Desktop/datafog-v2.4.0/datafog-python/tests/files/input_files/agi-builder-meetup.pdf\"\n",
143143
"output = datafog.DataFog.upload_file(uploaded_file_path=input_file)\n",
144-
"print(output)\n",
145-
"\n"
144+
"print(output)"
146145
]
147146
}
148147
],

src/datafog/__init__.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
import json
33
import logging
44
import tempfile
5+
from pathlib import Path
6+
57
import pandas as pd
68
import requests
79
import spacy
810
from unstructured.partition.auto import partition
9-
from io import BytesIO
10-
from pathlib import Path
1111

1212
from .__about__ import __version__
1313
from .pii_tools import PresidioEngine
@@ -40,7 +40,6 @@ def __init__(self):
4040
"""
4141
self.nlp = spacy.load("en_spacy_pii_fast")
4242

43-
4443
@staticmethod
4544
def client():
4645
"""
@@ -50,7 +49,7 @@ def client():
5049
DataFog: A new instance of the DataFog client.
5150
"""
5251
return DataFog()
53-
52+
5453
@staticmethod
5554
def upload_file(uploaded_file_path):
5655
uploaded_file_path = Path(uploaded_file_path)
@@ -60,7 +59,9 @@ def upload_file(uploaded_file_path):
6059
if not uploaded_file_path.exists():
6160
return "File not found."
6261
else:
63-
temp_file = tempfile.NamedTemporaryFile(delete=True, suffix=uploaded_file_path.suffix)
62+
temp_file = tempfile.NamedTemporaryFile(
63+
delete=True, suffix=uploaded_file_path.suffix
64+
)
6465
temp_file.write(bytes_data)
6566
elements = partition(temp_file.name)
6667
text = ""
@@ -69,7 +70,7 @@ def upload_file(uploaded_file_path):
6970
texts[uploaded_file_path.name] = text
7071

7172
return texts
72-
73+
7374
def __call__(self, input_source, privacy_operation):
7475
"""
7576
Process the input data and apply the specified privacy operation.

tests/test_datafog.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# test_datafog.py
22
import pytest
3-
import requests
43

54
from datafog import DataFog
65

@@ -9,11 +8,14 @@
98
def datafog():
109
return DataFog()
1110

11+
1212
def test_upload_file(datafog):
13-
uploaded_file="tests/files/input_files/agi-builder-meetup.pdf"
13+
uploaded_file = "tests/files/input_files/agi-builder-meetup.pdf"
1414
result = datafog.upload_file(uploaded_file_path=uploaded_file)
15-
file_text = result[uploaded_file.split('/')[-1]] # Extract the text using the file name as key
16-
assert "Cloudflare" in file_text # confirms that OCR is not on
15+
file_text = result[
16+
uploaded_file.split("/")[-1]
17+
] # Extract the text using the file name as key
18+
assert "Cloudflare" in file_text # confirms that OCR is not on
1719
assert "SF" in file_text
1820
assert "Laurie" in file_text
1921
assert "BentoML" in file_text

0 commit comments

Comments
 (0)