inferencesh 0.1.12__py3-none-any.whl → 0.1.15__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,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
- path: str # Absolute path to the file or URL
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
- def __init__(self, **data):
111
- super().__init__(**data)
112
- if self._is_url(self.path):
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.path):
115
- self.path = os.path.abspath(self.path)
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.path
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(path=str(path))
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()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: inferencesh
3
- Version: 0.1.12
3
+ Version: 0.1.15
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=pR0MXSJe41LgJkjGK-jhZR7LjqCFdRZtNTV6qcjYSTI,123
2
+ inferencesh/sdk.py,sha256=6Q-mXB4MAuqjY5sFZcp-RVrkbV9EZvDD38HSl4RQx2o,7839
3
+ inferencesh-0.1.15.dist-info/LICENSE,sha256=OsgqEWIh2el_QMj0y8O1A5Q5Dl-dxqqYbFE6fszuR4s,1086
4
+ inferencesh-0.1.15.dist-info/METADATA,sha256=YuMQ9yYKL0g9riTLwhpaQejD6eBLg7KEL7MBmTxZt3U,2584
5
+ inferencesh-0.1.15.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
6
+ inferencesh-0.1.15.dist-info/entry_points.txt,sha256=6IC-fyozAqW3ljsMLGCXxJ0_ui2Jb-2fLHtoH1RTnEE,45
7
+ inferencesh-0.1.15.dist-info/top_level.txt,sha256=TSMHg3T1ThMl1HGAWmzBClwOYH1ump5neof9BfHIwaA,12
8
+ inferencesh-0.1.15.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.0)
2
+ Generator: setuptools (76.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,8 +0,0 @@
1
- inferencesh/__init__.py,sha256=pR0MXSJe41LgJkjGK-jhZR7LjqCFdRZtNTV6qcjYSTI,123
2
- inferencesh/sdk.py,sha256=OJsbJlaQFewO6ncikfgGMnxs7TBLhxw_icNoHsqeIqw,7717
3
- inferencesh-0.1.12.dist-info/LICENSE,sha256=OsgqEWIh2el_QMj0y8O1A5Q5Dl-dxqqYbFE6fszuR4s,1086
4
- inferencesh-0.1.12.dist-info/METADATA,sha256=J39n1MJJ6ZlQr5uokw_1rhryoeofKaiVIyvTxsEUaF8,2584
5
- inferencesh-0.1.12.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
6
- inferencesh-0.1.12.dist-info/entry_points.txt,sha256=6IC-fyozAqW3ljsMLGCXxJ0_ui2Jb-2fLHtoH1RTnEE,45
7
- inferencesh-0.1.12.dist-info/top_level.txt,sha256=TSMHg3T1ThMl1HGAWmzBClwOYH1ump5neof9BfHIwaA,12
8
- inferencesh-0.1.12.dist-info/RECORD,,