File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change 11#!/usr/bin/env python
2- # -*- coding: utf-8 -*--
2+ import json
33
4- # Copyright (c) 2021, 2024 Oracle and/or its affiliates.
4+ # Copyright (c) 2021, 2025 Oracle and/or its affiliates.
55# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
6-
76import sys
87import traceback
9- from dataclasses import is_dataclass
108
119import fire
10+ from pydantic import BaseModel
1211
1312from ads .common import logger
1413
@@ -84,7 +83,14 @@ def serialize(data):
8483 The string representation of each dataclass object.
8584 """
8685 if isinstance (data , list ):
86+ for item in data :
87+ if isinstance (item , BaseModel ):
88+ print (json .dumps (item .dict (), indent = 4 ))
89+ else :
90+ print (str (item ))
8791 [print (str (item )) for item in data ]
92+ elif isinstance (data , BaseModel ):
93+ print (json .dumps (data .dict (), indent = 4 ))
8894 else :
8995 print (str (data ))
9096
You can’t perform that action at this time.
0 commit comments