inferencesh 0.1.9__py3-none-any.whl → 0.1.11__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.
Potentially problematic release.
This version of inferencesh might be problematic. Click here for more details.
- inferencesh/sdk.py +35 -18
- {inferencesh-0.1.9.dist-info → inferencesh-0.1.11.dist-info}/METADATA +1 -1
- inferencesh-0.1.11.dist-info/RECORD +8 -0
- inferencesh-0.1.9.dist-info/RECORD +0 -8
- {inferencesh-0.1.9.dist-info → inferencesh-0.1.11.dist-info}/LICENSE +0 -0
- {inferencesh-0.1.9.dist-info → inferencesh-0.1.11.dist-info}/WHEEL +0 -0
- {inferencesh-0.1.9.dist-info → inferencesh-0.1.11.dist-info}/entry_points.txt +0 -0
- {inferencesh-0.1.9.dist-info → inferencesh-0.1.11.dist-info}/top_level.txt +0 -0
inferencesh/sdk.py
CHANGED
|
@@ -39,7 +39,6 @@ class File(BaseModel):
|
|
|
39
39
|
def __init__(self, **data):
|
|
40
40
|
super().__init__(**data)
|
|
41
41
|
if self._is_url(self.path):
|
|
42
|
-
print(f"Downloading URL: {self.path}")
|
|
43
42
|
self._download_url()
|
|
44
43
|
elif not os.path.isabs(self.path):
|
|
45
44
|
self.path = os.path.abspath(self.path)
|
|
@@ -49,26 +48,44 @@ class File(BaseModel):
|
|
|
49
48
|
"""Check if the path is a URL."""
|
|
50
49
|
parsed = urllib.parse.urlparse(path)
|
|
51
50
|
return parsed.scheme in ('http', 'https')
|
|
52
|
-
|
|
53
51
|
def _download_url(self) -> None:
|
|
54
52
|
"""Download the URL to a temporary file and update the path."""
|
|
55
53
|
original_url = self.path
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
54
|
+
tmp_file = None
|
|
55
|
+
try:
|
|
56
|
+
# Create a temporary file with a suffix based on the URL path
|
|
57
|
+
suffix = os.path.splitext(urllib.parse.urlparse(original_url).path)[1]
|
|
58
|
+
tmp_file = tempfile.NamedTemporaryFile(delete=False, suffix=suffix)
|
|
59
|
+
self._tmp_path = tmp_file.name
|
|
60
|
+
|
|
61
|
+
# Set up request with user agent
|
|
62
|
+
headers = {
|
|
63
|
+
'User-Agent': (
|
|
64
|
+
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) '
|
|
65
|
+
'AppleWebKit/537.36 (KHTML, like Gecko) '
|
|
66
|
+
'Chrome/91.0.4472.124 Safari/537.36'
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
req = urllib.request.Request(original_url, headers=headers)
|
|
70
|
+
|
|
71
|
+
# Download the file
|
|
72
|
+
print(f"Downloading URL: {original_url} to {self._tmp_path}")
|
|
73
|
+
try:
|
|
74
|
+
with urllib.request.urlopen(req) as response, open(self._tmp_path, 'wb') as out_file:
|
|
75
|
+
out_file.write(response.read())
|
|
76
|
+
self.path = self._tmp_path
|
|
77
|
+
except (urllib.error.URLError, urllib.error.HTTPError) as e:
|
|
78
|
+
raise RuntimeError(f"Failed to download URL {original_url}: {str(e)}")
|
|
79
|
+
except IOError as e:
|
|
80
|
+
raise RuntimeError(f"Failed to write downloaded file to {self._tmp_path}: {str(e)}")
|
|
81
|
+
except Exception as e:
|
|
82
|
+
# Clean up temp file if something went wrong
|
|
83
|
+
if tmp_file is not None and hasattr(self, '_tmp_path'):
|
|
84
|
+
try:
|
|
85
|
+
os.unlink(self._tmp_path)
|
|
86
|
+
except:
|
|
87
|
+
pass
|
|
88
|
+
raise RuntimeError(f"Error downloading URL {original_url}: {str(e)}")
|
|
72
89
|
|
|
73
90
|
def __del__(self):
|
|
74
91
|
"""Cleanup temporary file if it exists."""
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
inferencesh/__init__.py,sha256=pR0MXSJe41LgJkjGK-jhZR7LjqCFdRZtNTV6qcjYSTI,123
|
|
2
|
+
inferencesh/sdk.py,sha256=Czs31xNdlm9LB_PdCo5Vnknn46c98votVsRbv9gHezU,4870
|
|
3
|
+
inferencesh-0.1.11.dist-info/LICENSE,sha256=OsgqEWIh2el_QMj0y8O1A5Q5Dl-dxqqYbFE6fszuR4s,1086
|
|
4
|
+
inferencesh-0.1.11.dist-info/METADATA,sha256=RbW4TasZukB7XGe7wZsk6rR8pwuTs_fCiaMLvecmL-k,2584
|
|
5
|
+
inferencesh-0.1.11.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
6
|
+
inferencesh-0.1.11.dist-info/entry_points.txt,sha256=6IC-fyozAqW3ljsMLGCXxJ0_ui2Jb-2fLHtoH1RTnEE,45
|
|
7
|
+
inferencesh-0.1.11.dist-info/top_level.txt,sha256=TSMHg3T1ThMl1HGAWmzBClwOYH1ump5neof9BfHIwaA,12
|
|
8
|
+
inferencesh-0.1.11.dist-info/RECORD,,
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
inferencesh/__init__.py,sha256=pR0MXSJe41LgJkjGK-jhZR7LjqCFdRZtNTV6qcjYSTI,123
|
|
2
|
-
inferencesh/sdk.py,sha256=QOHT8As_SCGI93s6hd8i8tizOzSZ2bMneQCIc45IrXw,3959
|
|
3
|
-
inferencesh-0.1.9.dist-info/LICENSE,sha256=OsgqEWIh2el_QMj0y8O1A5Q5Dl-dxqqYbFE6fszuR4s,1086
|
|
4
|
-
inferencesh-0.1.9.dist-info/METADATA,sha256=n0_HTF7QFx9jhssc9EOJ5ByP74rWBLa7suS7Cbpn6Bc,2583
|
|
5
|
-
inferencesh-0.1.9.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
6
|
-
inferencesh-0.1.9.dist-info/entry_points.txt,sha256=6IC-fyozAqW3ljsMLGCXxJ0_ui2Jb-2fLHtoH1RTnEE,45
|
|
7
|
-
inferencesh-0.1.9.dist-info/top_level.txt,sha256=TSMHg3T1ThMl1HGAWmzBClwOYH1ump5neof9BfHIwaA,12
|
|
8
|
-
inferencesh-0.1.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|