mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-25 00:12:08 +08:00
Replace Pydantic .dict() with .model_dump()
The .dict() method is deprecated in Pydantic V2 (PydanticDeprecatedSince20) and slated for removal in V3. The identically-behaving replacement is .model_dump() — all existing keyword arguments (exclude_unset, exclude, by_alias) are supported unchanged. Galaxy has already completed the bulk of the Pydantic v2 migration; these are the straggling call sites still emitting deprecation warnings in CI.
This commit is contained in:
@@ -10230,7 +10230,7 @@ class WorkflowInvocation(Base, UsesCreateAndUpdateTime, Dictifiable, Serializabl
|
||||
|
||||
def add_message(self, message: "InvocationMessageUnion"):
|
||||
|
||||
message_dict = message.dict(
|
||||
message_dict = message.model_dump(
|
||||
exclude_unset=True,
|
||||
exclude={"history_id"}, # history_id comes in through workflow_invocation and isn't persisted in database
|
||||
)
|
||||
|
||||
@@ -472,7 +472,7 @@ class ToolOutputCollectionStructure:
|
||||
return collection_prototype
|
||||
|
||||
def to_dict(self):
|
||||
return self.to_model().dict()
|
||||
return self.to_model().model_dump()
|
||||
|
||||
def to_model(self) -> ToolOutputCollectionStructureModel:
|
||||
discover_datasets = []
|
||||
|
||||
@@ -145,7 +145,7 @@ def _description_from_tool_source(
|
||||
request_schema: Optional[Dict[str, Any]] = None
|
||||
if request_and_schema:
|
||||
request = request_and_schema.request.input_state
|
||||
request_schema = request_and_schema.request_schema.dict()
|
||||
request_schema = request_and_schema.request_schema.model_dump()
|
||||
|
||||
value_state_representation = raw_test_dict.get("value_state_representation", "test_case_xml")
|
||||
tool_id, tool_version = _tool_id_and_version(tool_source, tool_guid)
|
||||
|
||||
@@ -2052,12 +2052,12 @@ def src_id_to_item(
|
||||
for item in adapting:
|
||||
element = TransientCollectionAdapterDatasetInstanceElement(
|
||||
item.name,
|
||||
cast(HistoryDatasetAssociation, src_id_to_item(sa_session, item.dict(), security)),
|
||||
cast(HistoryDatasetAssociation, src_id_to_item(sa_session, item.model_dump(), security)),
|
||||
)
|
||||
elements.append(element)
|
||||
return recover_adapter(elements, adapter_model)
|
||||
else:
|
||||
value = adapting.dict()
|
||||
value = adapting.model_dump()
|
||||
src_to_class = {
|
||||
"hda": HistoryDatasetAssociation,
|
||||
"ldda": LibraryDatasetDatasetAssociation,
|
||||
@@ -2994,7 +2994,7 @@ def history_item_to_json(value, app, use_security):
|
||||
collection_adapter: Optional[CollectionAdapter] = None
|
||||
if isinstance(value, CollectionAdapter):
|
||||
collection_adapter = value
|
||||
return collection_adapter.to_adapter_model().dict()
|
||||
return collection_adapter.to_adapter_model().model_dump()
|
||||
if isinstance(value, MutableMapping) and "src" in value and "id" in value:
|
||||
return value
|
||||
elif isinstance(value, DatasetCollectionElement):
|
||||
|
||||
@@ -182,7 +182,7 @@ class DatasetCollectionsService(ServiceBase, UsesLibraryMixinItems):
|
||||
:returns: element view of new dataset collection
|
||||
"""
|
||||
# TODO: Error handling...
|
||||
create_params = api_payload_to_create_params(payload.dict(exclude_unset=True, by_alias=True))
|
||||
create_params = api_payload_to_create_params(payload.model_dump(exclude_unset=True, by_alias=True))
|
||||
if payload.instance_type == "history":
|
||||
if payload.history_id is None:
|
||||
raise exceptions.RequestParameterInvalidException("Parameter history_id is required.")
|
||||
|
||||
@@ -395,7 +395,7 @@ class HistoriesService(ServiceBase, ConsumesModelStores, ServesExportStores):
|
||||
duration=short_term_storage_target.duration,
|
||||
user=trans.async_request_user,
|
||||
export_association_id=export_association.id,
|
||||
**payload.dict(),
|
||||
**payload.model_dump(),
|
||||
)
|
||||
result = prepare_history_download.delay(request=request, task_user_id=getattr(trans.user, "id", None))
|
||||
task_summary = async_task_summary(result)
|
||||
@@ -412,7 +412,7 @@ class HistoriesService(ServiceBase, ConsumesModelStores, ServesExportStores):
|
||||
user=trans.async_request_user,
|
||||
history_id=history.id,
|
||||
export_association_id=export_association.id,
|
||||
**payload.dict(),
|
||||
**payload.model_dump(),
|
||||
)
|
||||
result = write_history_to.delay(request=request, task_user_id=getattr(trans.user, "id", None))
|
||||
task_summary = async_task_summary(result)
|
||||
|
||||
@@ -59,4 +59,4 @@ class ModelCache:
|
||||
if not os.path.exists(parent_directory):
|
||||
os.makedirs(parent_directory)
|
||||
with open(cache_target, "w") as f:
|
||||
json.dump(model_object.dict(), f)
|
||||
json.dump(model_object.model_dump(), f)
|
||||
|
||||
Reference in New Issue
Block a user