inferencesh 0.2.2__tar.gz → 0.2.4__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.2.2/src/inferencesh.egg-info → inferencesh-0.2.4}/PKG-INFO +1 -1
- {inferencesh-0.2.2 → inferencesh-0.2.4}/pyproject.toml +1 -1
- {inferencesh-0.2.2 → inferencesh-0.2.4}/src/inferencesh/sdk.py +36 -17
- {inferencesh-0.2.2 → inferencesh-0.2.4/src/inferencesh.egg-info}/PKG-INFO +1 -1
- {inferencesh-0.2.2 → inferencesh-0.2.4}/LICENSE +0 -0
- {inferencesh-0.2.2 → inferencesh-0.2.4}/README.md +0 -0
- {inferencesh-0.2.2 → inferencesh-0.2.4}/setup.cfg +0 -0
- {inferencesh-0.2.2 → inferencesh-0.2.4}/setup.py +0 -0
- {inferencesh-0.2.2 → inferencesh-0.2.4}/src/inferencesh/__init__.py +0 -0
- {inferencesh-0.2.2 → inferencesh-0.2.4}/src/inferencesh.egg-info/SOURCES.txt +0 -0
- {inferencesh-0.2.2 → inferencesh-0.2.4}/src/inferencesh.egg-info/dependency_links.txt +0 -0
- {inferencesh-0.2.2 → inferencesh-0.2.4}/src/inferencesh.egg-info/entry_points.txt +0 -0
- {inferencesh-0.2.2 → inferencesh-0.2.4}/src/inferencesh.egg-info/requires.txt +0 -0
- {inferencesh-0.2.2 → inferencesh-0.2.4}/src/inferencesh.egg-info/top_level.txt +0 -0
- {inferencesh-0.2.2 → inferencesh-0.2.4}/tests/test_sdk.py +0 -0
|
@@ -140,17 +140,29 @@ class File(BaseModel):
|
|
|
140
140
|
return self
|
|
141
141
|
|
|
142
142
|
def model_post_init(self, _: Any) -> None:
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
143
|
+
"""Initialize file path and metadata after model creation.
|
|
144
|
+
|
|
145
|
+
This method handles:
|
|
146
|
+
1. Downloading URLs to local files if uri is a URL
|
|
147
|
+
2. Converting relative paths to absolute paths
|
|
148
|
+
3. Populating file metadata
|
|
149
|
+
"""
|
|
150
|
+
# Handle uri if provided
|
|
151
|
+
if self.uri:
|
|
152
|
+
if self._is_url(self.uri):
|
|
153
|
+
self._download_url()
|
|
154
|
+
else:
|
|
155
|
+
# Convert relative paths to absolute, leave absolute paths unchanged
|
|
156
|
+
self.path = os.path.abspath(self.uri)
|
|
157
|
+
|
|
158
|
+
# Handle path if provided
|
|
149
159
|
if self.path:
|
|
160
|
+
# Convert relative paths to absolute, leave absolute paths unchanged
|
|
161
|
+
self.path = os.path.abspath(self.path)
|
|
150
162
|
self._populate_metadata()
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
163
|
+
return
|
|
164
|
+
|
|
165
|
+
raise ValueError("Either 'uri' or 'path' must be provided and be valid")
|
|
154
166
|
def _is_url(self, path: str) -> bool:
|
|
155
167
|
"""Check if the path is a URL."""
|
|
156
168
|
parsed = urllib.parse.urlparse(path)
|
|
@@ -326,19 +338,26 @@ class LLMInputWithImage(LLMInput):
|
|
|
326
338
|
default=None
|
|
327
339
|
)
|
|
328
340
|
|
|
329
|
-
class
|
|
330
|
-
"""Standard
|
|
331
|
-
DATA = "
|
|
332
|
-
TEMP = "
|
|
333
|
-
CACHE = "
|
|
341
|
+
class StorageDir(str, Enum):
|
|
342
|
+
"""Standard storage directories used by the SDK."""
|
|
343
|
+
DATA = "/app/data" # Persistent storage/cache directory
|
|
344
|
+
TEMP = "/app/tmp" # Temporary storage directory
|
|
345
|
+
CACHE = "/app/cache" # Cache directory
|
|
346
|
+
|
|
347
|
+
@property
|
|
348
|
+
def path(self) -> Path:
|
|
349
|
+
"""Get the Path object for this storage directory, ensuring it exists."""
|
|
350
|
+
path = Path(self.value)
|
|
351
|
+
path.mkdir(parents=True, exist_ok=True)
|
|
352
|
+
return path
|
|
334
353
|
|
|
335
|
-
def download(url: str, directory: Union[str, Path,
|
|
354
|
+
def download(url: str, directory: Union[str, Path, StorageDir]) -> str:
|
|
336
355
|
"""Download a file to the specified directory and return its path.
|
|
337
356
|
|
|
338
357
|
Args:
|
|
339
358
|
url: The URL to download from
|
|
340
359
|
directory: The directory to save the file to. Can be a string path,
|
|
341
|
-
Path object, or
|
|
360
|
+
Path object, or StorageDir enum value.
|
|
342
361
|
|
|
343
362
|
Returns:
|
|
344
363
|
str: The path to the downloaded file
|
|
@@ -360,7 +379,7 @@ def download(url: str, directory: Union[str, Path, DownloadDir]) -> str:
|
|
|
360
379
|
output_path = hash_dir / filename
|
|
361
380
|
|
|
362
381
|
# If file exists in directory and it's not a temp directory, return it
|
|
363
|
-
if output_path.exists() and directory !=
|
|
382
|
+
if output_path.exists() and directory != StorageDir.TEMP:
|
|
364
383
|
return str(output_path)
|
|
365
384
|
|
|
366
385
|
# Download the file
|
|
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
|