我正在尝试编写一个函数,该函数以
然而,使用
我可以想出一种方法来实现,但我找不到一种简洁的方法。
pydantic BaseModel
作为输入来运行另一个函数。我需要将BaseModel解包为kwargs。我尝试了以下方法:def run_routing_from_job(job):
return run_routing(
job.inputs.input_file,
**job.inputs.config.dict()
)
job
的格式为:
class Job(BaseModel):
client_info: ClientInfo # Another BaseModel
inputs: RoutingJobInputs # Another BaseModel
uid: UUID = Field(default_factory=uuid4)
status: str = "job_queued"
result: int = None
然而,使用
.dict()
会将所有项目递归解析为字典格式。我希望保留client_info
和inputs
作为BaseModel类,而不是将其转换为字典。我可以想出一种方法来实现,但我找不到一种简洁的方法。
job: Job
参数,而要使用**kwargs
呢? - Hernán Alarcónjob
,但现在我只想解压基本模型。 - Tom McLean