inferencesh 0.1.10__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 CHANGED
@@ -48,30 +48,44 @@ class File(BaseModel):
48
48
  """Check if the path is a URL."""
49
49
  parsed = urllib.parse.urlparse(path)
50
50
  return parsed.scheme in ('http', 'https')
51
-
52
51
  def _download_url(self) -> None:
53
52
  """Download the URL to a temporary file and update the path."""
54
53
  original_url = self.path
55
- # Create a temporary file with a suffix based on the URL path
56
- suffix = os.path.splitext(urllib.parse.urlparse(original_url).path)[1]
57
- tmp_file = tempfile.NamedTemporaryFile(delete=False, suffix=suffix)
58
- self._tmp_path = tmp_file.name
59
-
60
- # Set up request with user agent
61
- headers = {
62
- 'User-Agent': (
63
- 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) '
64
- 'AppleWebKit/537.36 (KHTML, like Gecko) '
65
- 'Chrome/91.0.4472.124 Safari/537.36'
66
- )
67
- }
68
- req = urllib.request.Request(original_url, headers=headers)
69
-
70
- # Download the file
71
- print(f"Downloading URL: {original_url} to {self._tmp_path}")
72
- with urllib.request.urlopen(req) as response, open(self._tmp_path, 'wb') as out_file:
73
- out_file.write(response.read())
74
- self.path = self._tmp_path
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)}")
75
89
 
76
90
  def __del__(self):
77
91
  """Cleanup temporary file if it exists."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: inferencesh
3
- Version: 0.1.10
3
+ Version: 0.1.11
4
4
  Summary: inference.sh Python SDK
5
5
  Author: Inference Shell Inc.
6
6
  Author-email: "Inference Shell Inc." <hello@inference.sh>
@@ -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=N1GubtBeFkvqnpDisU8DUm7376HEkug1AwgoTV4Irv0,4081
3
- inferencesh-0.1.10.dist-info/LICENSE,sha256=OsgqEWIh2el_QMj0y8O1A5Q5Dl-dxqqYbFE6fszuR4s,1086
4
- inferencesh-0.1.10.dist-info/METADATA,sha256=Xx4mNEwqLMfhZfdZenwPhA-XWMbgvvWEQ-WzMxyD5Tc,2584
5
- inferencesh-0.1.10.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
6
- inferencesh-0.1.10.dist-info/entry_points.txt,sha256=6IC-fyozAqW3ljsMLGCXxJ0_ui2Jb-2fLHtoH1RTnEE,45
7
- inferencesh-0.1.10.dist-info/top_level.txt,sha256=TSMHg3T1ThMl1HGAWmzBClwOYH1ump5neof9BfHIwaA,12
8
- inferencesh-0.1.10.dist-info/RECORD,,