Skip to content

Commit faf7473

Browse files
authored
Zendesk Deps Update (#418)
* initial changes for zendesk deps * update versions and changelog --------- Co-authored-by: nikpocuca <[email protected]>
1 parent 7a8b396 commit faf7473

File tree

7 files changed

+75
-5
lines changed

7 files changed

+75
-5
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 0.5.12-dev0
2+
3+
### Fixes
4+
5+
Fixed zendesk dependency warning
6+
17
## 0.5.11
28

39
### Features

requirements/connectors/zendesk.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-c ../common/constraints.txt
2+
3+
httpx
4+
aiofiles
5+
bs4
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# This file was autogenerated by uv via the following command:
2+
# uv pip compile ./connectors/zendesk.in --output-file ./connectors/zendesk.txt --no-strip-extras --python-version 3.9
3+
aiofiles==24.1.0
4+
# via -r ./connectors/zendesk.in
5+
anyio==4.8.0
6+
# via httpx
7+
beautifulsoup4==4.13.3
8+
# via bs4
9+
bs4==0.0.2
10+
# via -r ./connectors/zendesk.in
11+
certifi==2025.1.31
12+
# via
13+
# httpcore
14+
# httpx
15+
exceptiongroup==1.2.2
16+
# via anyio
17+
h11==0.14.0
18+
# via httpcore
19+
httpcore==1.0.7
20+
# via httpx
21+
httpx==0.28.1
22+
# via -r ./connectors/zendesk.in
23+
idna==3.10
24+
# via
25+
# anyio
26+
# httpx
27+
sniffio==1.3.1
28+
# via anyio
29+
soupsieve==2.6
30+
# via beautifulsoup4
31+
typing-extensions==4.12.2
32+
# via
33+
# anyio
34+
# beautifulsoup4

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ def load_requirements(file: Union[str, Path]) -> List[str]:
133133
"singlestore": load_requirements("requirements/connectors/singlestore.in"),
134134
"vectara": load_requirements("requirements/connectors/vectara.in"),
135135
"vastdb": load_requirements("requirements/connectors/vastdb.in"),
136+
"zendesk": load_requirements("requirements/connectors/zendesk.in"),
136137
}
137138

138139
embed_reqs = {

unstructured_ingest/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.5.11" # pragma: no cover
1+
__version__ = "0.5.12-dev0" # pragma: no cover

unstructured_ingest/v2/processes/connectors/zendesk/client.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
from dataclasses import dataclass
33
from typing import Dict, List
44

5-
import httpx
6-
5+
from unstructured_ingest.utils.dep_check import requires_dependencies
76
from unstructured_ingest.v2.errors import ProviderError, RateLimitError, UserAuthError, UserError
87
from unstructured_ingest.v2.logger import logger
98

@@ -42,7 +41,10 @@ def __lt__(self, other):
4241

4342
class ZendeskClient:
4443

44+
@requires_dependencies(["httpx"], extras="zendesk")
4545
def __init__(self, token: str, subdomain: str, email: str):
46+
import httpx
47+
4648
# should be okay to be blocking.
4749
url_to_check = f"https://{subdomain}.zendesk.com/api/v2/groups.json"
4850
auth = f"{email}/token", token
@@ -57,7 +59,10 @@ def __init__(self, token: str, subdomain: str, email: str):
5759
self._email = email
5860
self._auth = auth
5961

62+
@requires_dependencies(["httpx"], extras="zendesk")
6063
def wrap_error(self, e: Exception) -> Exception:
64+
import httpx
65+
6166
if not isinstance(e, httpx.HTTPStatusError):
6267
logger.error(f"unhandled exception from Zendesk client: {e}", exc_info=True)
6368
return e
@@ -88,10 +93,12 @@ def wrap_error(self, e: Exception) -> Exception:
8893
logger.error(f"unhandled http status error from Zendesk client: {e}", exc_info=True)
8994
return e
9095

96+
@requires_dependencies(["httpx"], extras="zendesk")
9197
async def get_articles_async(self) -> List[ZendeskArticle]:
9298
"""
9399
Retrieves article content from Zendesk asynchronously.
94100
"""
101+
import httpx
95102

96103
articles: List[ZendeskArticle] = []
97104

@@ -117,7 +124,10 @@ async def get_articles_async(self) -> List[ZendeskArticle]:
117124
]
118125
return articles
119126

127+
@requires_dependencies(["httpx"], extras="zendesk")
120128
async def get_comments_async(self, ticket_id: int) -> List["Comment"]:
129+
import httpx
130+
121131
comments_url = f"https://{self._subdomain}.zendesk.com/api/v2/tickets/{ticket_id}/comments"
122132

123133
try:
@@ -138,7 +148,9 @@ async def get_comments_async(self, ticket_id: int) -> List["Comment"]:
138148
for entry in response.json()["comments"]
139149
]
140150

151+
@requires_dependencies(["httpx"], extras="zendesk")
141152
def get_users(self) -> List[dict]:
153+
import httpx
142154

143155
users: List[dict] = []
144156

@@ -154,7 +166,10 @@ def get_users(self) -> List[dict]:
154166

155167
return users
156168

169+
@requires_dependencies(["httpx"], extras="zendesk")
157170
async def get_tickets_async(self) -> List["ZendeskTicket"]:
171+
import httpx
172+
158173
tickets: List["ZendeskTicket"] = []
159174
tickets_url = f"https://{self._subdomain}.zendesk.com/api/v2/tickets"
160175

@@ -179,10 +194,13 @@ async def get_tickets_async(self) -> List["ZendeskTicket"]:
179194

180195
return tickets
181196

197+
@requires_dependencies(["httpx"], extras="zendesk")
182198
async def get_article_attachments_async(self, article_id: str):
183199
"""
184200
Handles article attachments such as images and stores them as UTF-8 encoded bytes.
185201
"""
202+
import httpx
203+
186204
article_attachment_url = (
187205
f"https://{self._subdomain}.zendesk.com/api/v2/help_center/"
188206
f"articles/{article_id}/attachments"

unstructured_ingest/v2/processes/connectors/zendesk/zendesk.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77
from time import time
88
from typing import Any, AsyncGenerator, List, Literal
99

10-
import aiofiles
11-
import bs4
1210
from pydantic import BaseModel, Field, Secret
1311

1412
from unstructured_ingest.utils.data_prep import batch_generator
13+
from unstructured_ingest.utils.dep_check import requires_dependencies
1514
from unstructured_ingest.utils.html import HtmlMixin
1615
from unstructured_ingest.v2.errors import UserAuthError
1716
from unstructured_ingest.v2.interfaces import (
@@ -290,13 +289,17 @@ def download_embedded_files(
290289
session=session,
291290
)
292291

292+
@requires_dependencies(["bs4", "aiofiles"], extras="zendesk")
293293
async def handle_articles_async(
294294
self, client: ZendeskClient, batch_file_data: ZendeskBatchFileData
295295
):
296296
"""
297297
Processes the article information, downloads the attachments for each article,
298298
and updates the content accordingly.
299299
"""
300+
import aiofiles
301+
import bs4
302+
300303
# Determine the download path
301304
download_path = self.get_download_path(batch_file_data)
302305

@@ -327,12 +330,15 @@ async def handle_articles_async(
327330
file_data=batch_file_data, download_path=download_path
328331
)
329332

333+
@requires_dependencies(["aiofiles"], extras="zendesk")
330334
async def handle_tickets_async(
331335
self, client: ZendeskClient, batch_file_data: ZendeskBatchFileData
332336
) -> DownloadResponse:
333337
"""
334338
Processes a batch of tickets asynchronously, writing their details and comments to a file.
335339
"""
340+
import aiofiles
341+
336342
# Determine the download path
337343
download_path = self.get_download_path(batch_file_data)
338344
if download_path is None:

0 commit comments

Comments
 (0)