inferencesh 0.2.2__py3-none-any.whl → 0.2.4__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
@@ -140,17 +140,29 @@ class File(BaseModel):
140
140
  return self
141
141
 
142
142
  def model_post_init(self, _: Any) -> None:
143
- if self.uri and self._is_url(self.uri):
144
- self._download_url()
145
- elif self.uri and not os.path.isabs(self.uri):
146
- self.path = os.path.abspath(self.uri)
147
- elif self.uri:
148
- self.path = self.uri
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
- else:
152
- raise ValueError("Either 'uri' or 'path' must be provided")
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 DownloadDir(str, Enum):
330
- """Standard download directories used by the SDK."""
331
- DATA = "./data" # Persistent storage/cache directory
332
- TEMP = "./tmp" # Temporary storage directory
333
- CACHE = "./cache" # Cache directory
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, DownloadDir]) -> str:
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 DownloadDir enum value.
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 != DownloadDir.TEMP:
382
+ if output_path.exists() and directory != StorageDir.TEMP:
364
383
  return str(output_path)
365
384
 
366
385
  # Download the file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: inferencesh
3
- Version: 0.2.2
3
+ Version: 0.2.4
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=aIwo6F_1CwFDJ8EPdT5NCp77s4np6m1hyOSh3akpd6A,15832
3
+ inferencesh-0.2.4.dist-info/licenses/LICENSE,sha256=OsgqEWIh2el_QMj0y8O1A5Q5Dl-dxqqYbFE6fszuR4s,1086
4
+ inferencesh-0.2.4.dist-info/METADATA,sha256=2qVKhcIMtBOpjIv2bUjftW7hORXz69r4Lo3PkmDUGDw,2756
5
+ inferencesh-0.2.4.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
6
+ inferencesh-0.2.4.dist-info/entry_points.txt,sha256=6IC-fyozAqW3ljsMLGCXxJ0_ui2Jb-2fLHtoH1RTnEE,45
7
+ inferencesh-0.2.4.dist-info/top_level.txt,sha256=TSMHg3T1ThMl1HGAWmzBClwOYH1ump5neof9BfHIwaA,12
8
+ inferencesh-0.2.4.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- inferencesh/__init__.py,sha256=hbKkgHCh0lCdhWyHs3FHHRd8JfLeHkTd1bT4v79Fi8M,192
2
- inferencesh/sdk.py,sha256=KiD11omxGg0sbCiLSjyJnD1UvfWkUGyk9wB-3wIUcJU,15094
3
- inferencesh-0.2.2.dist-info/licenses/LICENSE,sha256=OsgqEWIh2el_QMj0y8O1A5Q5Dl-dxqqYbFE6fszuR4s,1086
4
- inferencesh-0.2.2.dist-info/METADATA,sha256=S-_OXltQ2PsqHEpOlp3CImD0TITrTydbUVT0SSf94F0,2756
5
- inferencesh-0.2.2.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
6
- inferencesh-0.2.2.dist-info/entry_points.txt,sha256=6IC-fyozAqW3ljsMLGCXxJ0_ui2Jb-2fLHtoH1RTnEE,45
7
- inferencesh-0.2.2.dist-info/top_level.txt,sha256=TSMHg3T1ThMl1HGAWmzBClwOYH1ump5neof9BfHIwaA,12
8
- inferencesh-0.2.2.dist-info/RECORD,,