inferencesh 0.1.23__py3-none-any.whl → 0.1.24__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
@@ -1,4 +1,4 @@
1
- from typing import Optional, Union, ClassVar
1
+ from typing import Optional, Union
2
2
  from pydantic import BaseModel, ConfigDict, PrivateAttr, model_validator
3
3
  import mimetypes
4
4
  import os
@@ -114,6 +114,25 @@ class File(BaseModel):
114
114
  populate_by_name=True
115
115
  )
116
116
 
117
+ @classmethod
118
+ def __get_validators__(cls):
119
+ # First yield the default validators
120
+ yield cls.validate
121
+
122
+ @classmethod
123
+ def validate(cls, value):
124
+ """Convert string values to File objects."""
125
+ if isinstance(value, str):
126
+ # If it's a string, treat it as a uri
127
+ return cls(uri=value)
128
+ elif isinstance(value, cls):
129
+ # If it's already a File instance, return it as is
130
+ return value
131
+ elif isinstance(value, dict):
132
+ # If it's a dict, use normal validation
133
+ return cls(**value)
134
+ raise ValueError(f'Invalid input for File: {value}')
135
+
117
136
  @model_validator(mode='after')
118
137
  def check_uri_or_path(self) -> 'File':
119
138
  """Validate that either uri or path is provided."""
@@ -170,7 +189,7 @@ class File(BaseModel):
170
189
  if tmp_file is not None and hasattr(self, '_tmp_path'):
171
190
  try:
172
191
  os.unlink(self._tmp_path)
173
- except:
192
+ except (OSError, IOError):
174
193
  pass
175
194
  raise RuntimeError(f"Error downloading URL {original_url}: {str(e)}")
176
195
 
@@ -179,7 +198,7 @@ class File(BaseModel):
179
198
  if hasattr(self, '_tmp_path') and self._tmp_path:
180
199
  try:
181
200
  os.unlink(self._tmp_path)
182
- except:
201
+ except (OSError, IOError):
183
202
  pass
184
203
 
185
204
  def _populate_metadata(self) -> None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: inferencesh
3
- Version: 0.1.23
3
+ Version: 0.1.24
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=hbKkgHCh0lCdhWyHs3FHHRd8JfLeHkTd1bT4v79Fi8M,192
2
+ inferencesh/sdk.py,sha256=u8GbIAn5clg_9zHUy99zu2AidgBION4f1KcMJnmjChg,12417
3
+ inferencesh-0.1.24.dist-info/licenses/LICENSE,sha256=OsgqEWIh2el_QMj0y8O1A5Q5Dl-dxqqYbFE6fszuR4s,1086
4
+ inferencesh-0.1.24.dist-info/METADATA,sha256=FM54ThOJtpP14Z1-DN2ZV0Mv0g73md2u8kW15mJfSE4,2612
5
+ inferencesh-0.1.24.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
6
+ inferencesh-0.1.24.dist-info/entry_points.txt,sha256=6IC-fyozAqW3ljsMLGCXxJ0_ui2Jb-2fLHtoH1RTnEE,45
7
+ inferencesh-0.1.24.dist-info/top_level.txt,sha256=TSMHg3T1ThMl1HGAWmzBClwOYH1ump5neof9BfHIwaA,12
8
+ inferencesh-0.1.24.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.0.0)
2
+ Generator: setuptools (80.3.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,8 +0,0 @@
1
- inferencesh/__init__.py,sha256=hbKkgHCh0lCdhWyHs3FHHRd8JfLeHkTd1bT4v79Fi8M,192
2
- inferencesh/sdk.py,sha256=MdGlTaZITc9nuE94jLU01L1LWsC5RKj-OpFre-x6CeI,11738
3
- inferencesh-0.1.23.dist-info/licenses/LICENSE,sha256=OsgqEWIh2el_QMj0y8O1A5Q5Dl-dxqqYbFE6fszuR4s,1086
4
- inferencesh-0.1.23.dist-info/METADATA,sha256=_S9CelUY7dd_6ECy-n3Dj-K562rN3cvQ5f1WLvXP5HQ,2612
5
- inferencesh-0.1.23.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
6
- inferencesh-0.1.23.dist-info/entry_points.txt,sha256=6IC-fyozAqW3ljsMLGCXxJ0_ui2Jb-2fLHtoH1RTnEE,45
7
- inferencesh-0.1.23.dist-info/top_level.txt,sha256=TSMHg3T1ThMl1HGAWmzBClwOYH1ump5neof9BfHIwaA,12
8
- inferencesh-0.1.23.dist-info/RECORD,,