Skip to content

Commit

Permalink
Merge pull request #24 from aurelio-labs/simonas/bump-0.0.16
Browse files Browse the repository at this point in the history
chore: bump 0.0.16
  • Loading branch information
simjak authored Nov 19, 2024
2 parents 6488329 + bef5c4a commit 63e9434
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 30 deletions.
50 changes: 29 additions & 21 deletions aurelio_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,31 +198,39 @@ def extract_file(
initial_wait = WAIT_TIME_BEFORE_POLLING if polling_interval > 0 else wait
fields["wait"] = str(initial_wait)

if file_path:
filename = pathlib.Path(file_path).name
multipart_encoder = MultipartEncoder(
fields={**fields, "file": (filename, open(file_path, "rb"))}
)
else:
filename = getattr(file, "name", "document.pdf")
multipart_encoder = MultipartEncoder(
fields={**fields, "file": (filename, file)}
)

session_timeout = wait + 1 if wait > 0 else None

for attempt in range(1, retries + 1):
try:
session_timeout = wait + 1 if wait > 0 else None
response = requests.post(
client_url,
data=multipart_encoder,
headers={
**self.headers,
"Content-Type": multipart_encoder.content_type,
},
timeout=session_timeout,
)
if file_path:
with open(file_path, "rb") as file_buffer:
filename = pathlib.Path(file_path).name
multipart_encoder = MultipartEncoder(
fields={**fields, "file": (filename, file_buffer)}
)
response = requests.post(
client_url,
data=multipart_encoder,
headers={
**self.headers,
"Content-Type": multipart_encoder.content_type,
},
timeout=session_timeout,
)
else:
filename = getattr(file, "name", "document.pdf")
multipart_encoder = MultipartEncoder(
fields={**fields, "file": (filename, file)}
)
response = requests.post(
client_url,
data=multipart_encoder,
headers={
**self.headers,
"Content-Type": multipart_encoder.content_type,
},
timeout=session_timeout,
)

if response.status_code == 200:
extract_response = ExtractResponse(**response.json())
Expand Down
7 changes: 2 additions & 5 deletions examples/02_extract.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -20,9 +20,7 @@
"from aurelio_sdk import AurelioClient\n",
"import os\n",
"\n",
"client = AurelioClient(\n",
" debug=True,\n",
")\n",
"client = AurelioClient(debug=True)\n",
"\n",
"print(client.base_url)\n"
]
Expand Down Expand Up @@ -69,7 +67,6 @@
"\n",
"# From a local file\n",
"file_path = \"data/video/how_to_overcome_our_mistakes.mp4\"\n",
"file_path = \"/Users/jakit/Desktop/Swypit Inner Circle Steven Guilfoile.mp4\"\n",
"\n",
"response_video_file: ExtractResponse = client.extract_file(\n",
" file_path=file_path, quality=\"low\", chunk=False, wait=-1\n",
Expand Down
4 changes: 2 additions & 2 deletions examples/03_extract_async.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -20,7 +20,7 @@
"from aurelio_sdk import AsyncAurelioClient\n",
"import os\n",
"\n",
"client = AsyncAurelioClient(debug=True, api_key=os.environ[\"AURELIO_API_KEY_STAGING\"], base_url=os.environ[\"BASE_URL_STAGING\"])\n",
"client = AsyncAurelioClient(debug=True)\n",
"print(client.base_url)\n"
]
},
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[tool.poetry]
name = "aurelio-sdk"
version = "0.0.15"
version = "0.0.16"
description = "Aurelio Platform SDK"
authors = ["Team <[email protected]>"]
readme = "README.md"
packages = [{ include = "aurelio_sdk" }]

[project]
name = "aurelio-sdk"
version = "0.0.15"
version = "0.0.16"
license = { file = "LICENSE" }

[tool.poetry.dependencies]
Expand Down

0 comments on commit 63e9434

Please sign in to comment.