inferencesh 0.1.16__py3-none-any.whl → 0.1.18__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
@@ -101,9 +101,9 @@ class BaseApp(BaseModel):
101
101
 
102
102
  class File(BaseModel):
103
103
  """A class representing a file in the inference.sh ecosystem."""
104
- uri: str # Original location (URL or file path)
104
+ uri: Optional[str] = None # Original location (URL or file path)
105
105
  path: Optional[str] = None # Resolved local file path
106
- mime_type: Optional[str] = None # MIME type of the file
106
+ content_type: Optional[str] = None # MIME type of the file
107
107
  size: Optional[int] = None # File size in bytes
108
108
  filename: Optional[str] = None # Original filename if available
109
109
  _tmp_path: Optional[str] = PrivateAttr(default=None) # Internal storage for temporary file path
@@ -113,12 +113,19 @@ class File(BaseModel):
113
113
  populate_by_name=True
114
114
  )
115
115
 
116
+ @model_validator(mode='after')
117
+ def check_uri_or_path(self) -> 'File':
118
+ """Validate that either uri or path is provided."""
119
+ if not self.uri and not self.path:
120
+ raise ValueError("Either 'uri' or 'path' must be provided")
121
+ return self
122
+
116
123
  def model_post_init(self, _: Any) -> None:
117
- if self._is_url(self.uri):
124
+ if self.uri and self._is_url(self.uri):
118
125
  self._download_url()
119
- elif not os.path.isabs(self.uri):
126
+ elif self.uri and not os.path.isabs(self.uri):
120
127
  self.path = os.path.abspath(self.uri)
121
- else:
128
+ elif self.uri:
122
129
  self.path = self.uri
123
130
  self._populate_metadata()
124
131
 
@@ -177,8 +184,8 @@ class File(BaseModel):
177
184
  def _populate_metadata(self) -> None:
178
185
  """Populate file metadata from the path if it exists."""
179
186
  if os.path.exists(self.path):
180
- if not self.mime_type:
181
- self.mime_type = self._guess_mime_type()
187
+ if not self.content_type:
188
+ self.content_type = self._guess_content_type()
182
189
  if not self.size:
183
190
  self.size = self._get_file_size()
184
191
  if not self.filename:
@@ -189,7 +196,7 @@ class File(BaseModel):
189
196
  """Create a File instance from a file path."""
190
197
  return cls(uri=str(path))
191
198
 
192
- def _guess_mime_type(self) -> Optional[str]:
199
+ def _guess_content_type(self) -> Optional[str]:
193
200
  """Guess the MIME type of the file."""
194
201
  return mimetypes.guess_type(self.path)[0]
195
202
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: inferencesh
3
- Version: 0.1.16
3
+ Version: 0.1.18
4
4
  Summary: inference.sh Python SDK
5
5
  Author: Inference Shell Inc.
6
6
  Author-email: "Inference Shell Inc." <hello@inference.sh>
@@ -39,7 +39,7 @@ file = File(path="/path/to/file.png")
39
39
  # File with explicit metadata
40
40
  file = File(
41
41
  path="/path/to/file.png",
42
- mime_type="image/png",
42
+ content_type="image/png",
43
43
  filename="custom_name.png",
44
44
  size=1024 # in bytes
45
45
  )
@@ -51,7 +51,7 @@ file = File.from_path("/path/to/file.png")
51
51
  exists = file.exists()
52
52
 
53
53
  # Access file metadata
54
- print(file.mime_type) # automatically detected if not specified
54
+ print(file.content_type) # automatically detected if not specified
55
55
  print(file.size) # file size in bytes
56
56
  print(file.filename) # basename of the file
57
57
 
@@ -0,0 +1,8 @@
1
+ inferencesh/__init__.py,sha256=pR0MXSJe41LgJkjGK-jhZR7LjqCFdRZtNTV6qcjYSTI,123
2
+ inferencesh/sdk.py,sha256=NM8_zSBW8gdIPbCK5d1iUdsgncAtbsBdG2e0MLX2hdw,8193
3
+ inferencesh-0.1.18.dist-info/LICENSE,sha256=OsgqEWIh2el_QMj0y8O1A5Q5Dl-dxqqYbFE6fszuR4s,1086
4
+ inferencesh-0.1.18.dist-info/METADATA,sha256=9lc1GISASMJmUWGahJCyZuGDupuXZBE9SbazBA1U2Ak,2590
5
+ inferencesh-0.1.18.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
6
+ inferencesh-0.1.18.dist-info/entry_points.txt,sha256=6IC-fyozAqW3ljsMLGCXxJ0_ui2Jb-2fLHtoH1RTnEE,45
7
+ inferencesh-0.1.18.dist-info/top_level.txt,sha256=TSMHg3T1ThMl1HGAWmzBClwOYH1ump5neof9BfHIwaA,12
8
+ inferencesh-0.1.18.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- inferencesh/__init__.py,sha256=pR0MXSJe41LgJkjGK-jhZR7LjqCFdRZtNTV6qcjYSTI,123
2
- inferencesh/sdk.py,sha256=UJ4qSOWjqH44rVLlu3lk3MVyw6pnj8DxwspsBTWm4Bw,7852
3
- inferencesh-0.1.16.dist-info/LICENSE,sha256=OsgqEWIh2el_QMj0y8O1A5Q5Dl-dxqqYbFE6fszuR4s,1086
4
- inferencesh-0.1.16.dist-info/METADATA,sha256=yEJt7lzzQQHR4eogFD2LsdeFmOVWrLYWJ6it9qUUvXA,2584
5
- inferencesh-0.1.16.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
6
- inferencesh-0.1.16.dist-info/entry_points.txt,sha256=6IC-fyozAqW3ljsMLGCXxJ0_ui2Jb-2fLHtoH1RTnEE,45
7
- inferencesh-0.1.16.dist-info/top_level.txt,sha256=TSMHg3T1ThMl1HGAWmzBClwOYH1ump5neof9BfHIwaA,12
8
- inferencesh-0.1.16.dist-info/RECORD,,