inferencesh 0.1.12__tar.gz → 0.1.15__tar.gz
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-0.1.12/src/inferencesh.egg-info → inferencesh-0.1.15}/PKG-INFO +1 -1
- {inferencesh-0.1.12 → inferencesh-0.1.15}/pyproject.toml +1 -1
- {inferencesh-0.1.12 → inferencesh-0.1.15}/src/inferencesh/sdk.py +18 -14
- {inferencesh-0.1.12 → inferencesh-0.1.15/src/inferencesh.egg-info}/PKG-INFO +1 -1
- {inferencesh-0.1.12 → inferencesh-0.1.15}/LICENSE +0 -0
- {inferencesh-0.1.12 → inferencesh-0.1.15}/README.md +0 -0
- {inferencesh-0.1.12 → inferencesh-0.1.15}/setup.cfg +0 -0
- {inferencesh-0.1.12 → inferencesh-0.1.15}/setup.py +0 -0
- {inferencesh-0.1.12 → inferencesh-0.1.15}/src/inferencesh/__init__.py +0 -0
- {inferencesh-0.1.12 → inferencesh-0.1.15}/src/inferencesh.egg-info/SOURCES.txt +0 -0
- {inferencesh-0.1.12 → inferencesh-0.1.15}/src/inferencesh.egg-info/dependency_links.txt +0 -0
- {inferencesh-0.1.12 → inferencesh-0.1.15}/src/inferencesh.egg-info/entry_points.txt +0 -0
- {inferencesh-0.1.12 → inferencesh-0.1.15}/src/inferencesh.egg-info/requires.txt +0 -0
- {inferencesh-0.1.12 → inferencesh-0.1.15}/src/inferencesh.egg-info/top_level.txt +0 -0
- {inferencesh-0.1.12 → inferencesh-0.1.15}/tests/test_sdk.py +0 -0
|
@@ -101,27 +101,35 @@ class BaseApp(BaseModel):
|
|
|
101
101
|
|
|
102
102
|
class File(BaseModel):
|
|
103
103
|
"""A class representing a file in the inference.sh ecosystem."""
|
|
104
|
-
|
|
104
|
+
uri: str # Original location (URL or file path)
|
|
105
|
+
path: Optional[str] = None # Resolved local file path
|
|
105
106
|
mime_type: Optional[str] = None # MIME type of the file
|
|
106
107
|
size: Optional[int] = None # File size in bytes
|
|
107
108
|
filename: Optional[str] = None # Original filename if available
|
|
108
|
-
_tmp_path: Optional[str] = None # Internal storage for temporary file path
|
|
109
|
+
_tmp_path: Optional[str] = PrivateAttr(default=None) # Internal storage for temporary file path
|
|
109
110
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
model_config = ConfigDict(
|
|
112
|
+
arbitrary_types_allowed=True,
|
|
113
|
+
populate_by_name=True
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
def model_post_init(self, _: Any) -> None:
|
|
117
|
+
if self._is_url(self.uri):
|
|
113
118
|
self._download_url()
|
|
114
|
-
elif not os.path.isabs(self.
|
|
115
|
-
self.path = os.path.abspath(self.
|
|
119
|
+
elif not os.path.isabs(self.uri):
|
|
120
|
+
self.path = os.path.abspath(self.uri)
|
|
121
|
+
else:
|
|
122
|
+
self.path = self.uri
|
|
116
123
|
self._populate_metadata()
|
|
117
124
|
|
|
118
125
|
def _is_url(self, path: str) -> bool:
|
|
119
126
|
"""Check if the path is a URL."""
|
|
120
127
|
parsed = urllib.parse.urlparse(path)
|
|
121
128
|
return parsed.scheme in ('http', 'https')
|
|
129
|
+
|
|
122
130
|
def _download_url(self) -> None:
|
|
123
131
|
"""Download the URL to a temporary file and update the path."""
|
|
124
|
-
original_url = self.
|
|
132
|
+
original_url = self.uri
|
|
125
133
|
tmp_file = None
|
|
126
134
|
try:
|
|
127
135
|
# Create a temporary file with a suffix based on the URL path
|
|
@@ -179,7 +187,7 @@ class File(BaseModel):
|
|
|
179
187
|
@classmethod
|
|
180
188
|
def from_path(cls, path: Union[str, os.PathLike]) -> 'File':
|
|
181
189
|
"""Create a File instance from a file path."""
|
|
182
|
-
return cls(
|
|
190
|
+
return cls(uri=str(path))
|
|
183
191
|
|
|
184
192
|
def _guess_mime_type(self) -> Optional[str]:
|
|
185
193
|
"""Guess the MIME type of the file."""
|
|
@@ -199,8 +207,4 @@ class File(BaseModel):
|
|
|
199
207
|
|
|
200
208
|
def refresh_metadata(self) -> None:
|
|
201
209
|
"""Refresh all metadata from the file."""
|
|
202
|
-
self._populate_metadata()
|
|
203
|
-
|
|
204
|
-
class Config:
|
|
205
|
-
"""Pydantic config"""
|
|
206
|
-
arbitrary_types_allowed = True
|
|
210
|
+
self._populate_metadata()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|