Skip to content

Commit ba7ce14

Browse files
committed
improve file class
1 parent 1a662c7 commit ba7ce14

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

src/inferencesh/models/file.py

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
from pathlib import Path
1010
from tqdm import tqdm
1111

12-
from pydantic import GetCoreSchemaHandler, GetJsonSchemaHandler
13-
from pydantic_core import CoreSchema, core_schema
14-
1512
class File(BaseModel):
1613
"""A class representing a file in the inference.sh ecosystem."""
1714

@@ -239,22 +236,29 @@ def refresh_metadata(self) -> None:
239236
self.size = self._get_file_size() # Always update size
240237
self.filename = self._get_filename()
241238

242-
@classmethod
243-
def __get_pydantic_core_schema__(
244-
cls, source: Type[Any], handler: GetCoreSchemaHandler
245-
) -> CoreSchema:
246-
"""Generates a Pydantic Core schema for validation of this File class"""
247-
# Get the default schema for our class
248-
schema = handler(source)
239+
# @classmethod
240+
# def __get_pydantic_core_schema__(
241+
# cls, source: Type[Any], handler: GetCoreSchemaHandler
242+
# ) -> CoreSchema:
243+
# """Generates a Pydantic Core schema for validation of this File class"""
244+
# # Get the default schema for our class
245+
# schema = handler(source)
246+
247+
# # Create a proper serialization schema that includes the type
248+
# serialization = core_schema.plain_serializer_function_ser_schema(
249+
# lambda x: x.uri if x.uri else x.path,
250+
# return_schema=core_schema.str_schema(),
251+
# when_used="json",
252+
# )
249253

250-
return core_schema.json_or_python_schema(
251-
json_schema=core_schema.union_schema([
252-
core_schema.str_schema(), # Accept string input
253-
schema, # Accept full object input
254-
]),
255-
python_schema=schema,
256-
serialization=schema.get("serialization", {}),
257-
)
254+
# return core_schema.json_or_python_schema(
255+
# json_schema=core_schema.union_schema([
256+
# core_schema.str_schema(), # Accept string input
257+
# schema, # Accept full object input
258+
# ]),
259+
# python_schema=schema,
260+
# serialization=serialization,
261+
# )
258262

259263
@classmethod
260264
def __get_pydantic_json_schema__(

0 commit comments

Comments
 (0)