futurehouse-client 0.3.18.dev25__py3-none-any.whl → 0.3.18.dev80__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- futurehouse_client/clients/rest_client.py +42 -21
- {futurehouse_client-0.3.18.dev25.dist-info → futurehouse_client-0.3.18.dev80.dist-info}/METADATA +1 -1
- {futurehouse_client-0.3.18.dev25.dist-info → futurehouse_client-0.3.18.dev80.dist-info}/RECORD +5 -5
- {futurehouse_client-0.3.18.dev25.dist-info → futurehouse_client-0.3.18.dev80.dist-info}/WHEEL +1 -1
- {futurehouse_client-0.3.18.dev25.dist-info → futurehouse_client-0.3.18.dev80.dist-info}/top_level.txt +0 -0
@@ -8,6 +8,7 @@ import inspect
|
|
8
8
|
import json
|
9
9
|
import logging
|
10
10
|
import os
|
11
|
+
import sys
|
11
12
|
import tempfile
|
12
13
|
import time
|
13
14
|
import uuid
|
@@ -63,24 +64,14 @@ from futurehouse_client.utils.monitoring import (
|
|
63
64
|
)
|
64
65
|
|
65
66
|
logger = logging.getLogger(__name__)
|
66
|
-
|
67
|
+
logging.basicConfig(
|
68
|
+
level=logging.INFO,
|
69
|
+
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
70
|
+
stream=sys.stdout,
|
71
|
+
)
|
72
|
+
logging.getLogger("httpx").setLevel(logging.WARNING)
|
67
73
|
TaskRequest.model_rebuild()
|
68
74
|
|
69
|
-
retry_if_connection_error = retry_if_exception_type((
|
70
|
-
# From requests
|
71
|
-
Timeout,
|
72
|
-
ConnectionError,
|
73
|
-
RequestException,
|
74
|
-
# From httpx
|
75
|
-
ConnectError,
|
76
|
-
ConnectTimeout,
|
77
|
-
ReadTimeout,
|
78
|
-
ReadError,
|
79
|
-
NetworkError,
|
80
|
-
RemoteProtocolError,
|
81
|
-
CloseError,
|
82
|
-
))
|
83
|
-
|
84
75
|
FILE_UPLOAD_IGNORE_PARTS = {
|
85
76
|
".ruff_cache",
|
86
77
|
"__pycache__",
|
@@ -111,6 +102,27 @@ class InvalidTaskDescriptionError(Exception):
|
|
111
102
|
"""Raised when the task description is invalid or empty."""
|
112
103
|
|
113
104
|
|
105
|
+
class FileUploadError(RestClientError):
|
106
|
+
"""Raised when there's an error uploading a file."""
|
107
|
+
|
108
|
+
|
109
|
+
retry_if_connection_error = retry_if_exception_type((
|
110
|
+
# From requests
|
111
|
+
Timeout,
|
112
|
+
ConnectionError,
|
113
|
+
RequestException,
|
114
|
+
# From httpx
|
115
|
+
ConnectError,
|
116
|
+
ConnectTimeout,
|
117
|
+
ReadTimeout,
|
118
|
+
ReadError,
|
119
|
+
NetworkError,
|
120
|
+
RemoteProtocolError,
|
121
|
+
CloseError,
|
122
|
+
FileUploadError,
|
123
|
+
))
|
124
|
+
|
125
|
+
|
114
126
|
class SimpleOrganization(BaseModel):
|
115
127
|
id: int
|
116
128
|
name: str
|
@@ -207,10 +219,6 @@ class TaskResponseVerbose(TaskResponse):
|
|
207
219
|
shared_with: list[SimpleOrganization] | None = None
|
208
220
|
|
209
221
|
|
210
|
-
class FileUploadError(RestClientError):
|
211
|
-
"""Raised when there's an error uploading a file."""
|
212
|
-
|
213
|
-
|
214
222
|
class RestClient:
|
215
223
|
REQUEST_TIMEOUT: ClassVar[float] = 30.0 # sec
|
216
224
|
MAX_RETRY_ATTEMPTS: ClassVar[int] = 3
|
@@ -999,6 +1007,12 @@ class RestClient:
|
|
999
1007
|
"""
|
1000
1008
|
file_name = file_name or file_path.name
|
1001
1009
|
file_size = file_path.stat().st_size
|
1010
|
+
|
1011
|
+
# Skip empty files
|
1012
|
+
if file_size == 0:
|
1013
|
+
logger.warning(f"Skipping upload of empty file: {file_path}")
|
1014
|
+
return
|
1015
|
+
|
1002
1016
|
total_chunks = (file_size + self.CHUNK_SIZE - 1) // self.CHUNK_SIZE
|
1003
1017
|
|
1004
1018
|
logger.info(f"Uploading {file_path} as {file_name} ({total_chunks} chunks)")
|
@@ -1122,7 +1136,7 @@ class RestClient:
|
|
1122
1136
|
|
1123
1137
|
Raises:
|
1124
1138
|
RestClientError: If there is an error downloading the file.
|
1125
|
-
FileNotFoundError: If the destination directory does not exist.
|
1139
|
+
FileNotFoundError: If the destination directory does not exist or if the file is not found.
|
1126
1140
|
"""
|
1127
1141
|
destination_path = Path(destination_path)
|
1128
1142
|
# Ensure the destination directory exists
|
@@ -1137,6 +1151,13 @@ class RestClient:
|
|
1137
1151
|
with open(destination_path, "wb") as f:
|
1138
1152
|
for chunk in response.iter_bytes(chunk_size=8192):
|
1139
1153
|
f.write(chunk)
|
1154
|
+
|
1155
|
+
# Check if the downloaded file is empty
|
1156
|
+
if destination_path.stat().st_size == 0:
|
1157
|
+
# Remove the empty file
|
1158
|
+
destination_path.unlink()
|
1159
|
+
raise FileNotFoundError(f"File not found or is empty: {file_path}")
|
1160
|
+
|
1140
1161
|
logger.info(f"File {file_path} downloaded to {destination_path}")
|
1141
1162
|
except HTTPStatusError as e:
|
1142
1163
|
logger.exception(
|
{futurehouse_client-0.3.18.dev25.dist-info → futurehouse_client-0.3.18.dev80.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: futurehouse-client
|
3
|
-
Version: 0.3.18.
|
3
|
+
Version: 0.3.18.dev80
|
4
4
|
Summary: A client for interacting with endpoints of the FutureHouse service.
|
5
5
|
Author-email: FutureHouse technical staff <hello@futurehouse.org>
|
6
6
|
Classifier: Operating System :: OS Independent
|
{futurehouse_client-0.3.18.dev25.dist-info → futurehouse_client-0.3.18.dev80.dist-info}/RECORD
RENAMED
@@ -1,7 +1,7 @@
|
|
1
1
|
futurehouse_client/__init__.py,sha256=ddxO7JE97c6bt7LjNglZZ2Ql8bYCGI9laSFeh9MP6VU,344
|
2
2
|
futurehouse_client/clients/__init__.py,sha256=tFWqwIAY5PvwfOVsCje4imjTpf6xXNRMh_UHIKVI1_0,320
|
3
3
|
futurehouse_client/clients/job_client.py,sha256=Fi3YvN4k82AuXCe8vlwxhkK8CXS164NQrs7paj9qIek,11096
|
4
|
-
futurehouse_client/clients/rest_client.py,sha256=
|
4
|
+
futurehouse_client/clients/rest_client.py,sha256=Qv54VFcGnCDbOoGFmfx8AZsXyAyZyZ4weK9RGKVePOE,47214
|
5
5
|
futurehouse_client/models/__init__.py,sha256=ta3jFLM_LsDz1rKDmx8rja8sT7WtSKoFvMgLF0yFpvA,342
|
6
6
|
futurehouse_client/models/app.py,sha256=yfZ9tyw4VATVAfYrU7aTdCNPSljLEho09_nIbh8oZDY,23174
|
7
7
|
futurehouse_client/models/client.py,sha256=n4HD0KStKLm6Ek9nL9ylP-bkK10yzAaD1uIDF83Qp_A,1828
|
@@ -10,7 +10,7 @@ futurehouse_client/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
|
|
10
10
|
futurehouse_client/utils/general.py,sha256=A_rtTiYW30ELGEZlWCIArO7q1nEmqi8hUlmBRYkMQ_c,767
|
11
11
|
futurehouse_client/utils/module_utils.py,sha256=aFyd-X-pDARXz9GWpn8SSViUVYdSbuy9vSkrzcVIaGI,4955
|
12
12
|
futurehouse_client/utils/monitoring.py,sha256=UjRlufe67kI3VxRHOd5fLtJmlCbVA2Wqwpd4uZhXkQM,8728
|
13
|
-
futurehouse_client-0.3.18.
|
14
|
-
futurehouse_client-0.3.18.
|
15
|
-
futurehouse_client-0.3.18.
|
16
|
-
futurehouse_client-0.3.18.
|
13
|
+
futurehouse_client-0.3.18.dev80.dist-info/METADATA,sha256=XVCM841O8K4E7OWwDGUZPI3c1Odio5nnBk-HOCHBj4Q,12766
|
14
|
+
futurehouse_client-0.3.18.dev80.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
|
15
|
+
futurehouse_client-0.3.18.dev80.dist-info/top_level.txt,sha256=TRuLUCt_qBnggdFHCX4O_BoCu1j2X43lKfIZC-ElwWY,19
|
16
|
+
futurehouse_client-0.3.18.dev80.dist-info/RECORD,,
|
File without changes
|