Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(nodes): return copies of objects in invocation ctx #7195

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions invokeai/app/services/shared/invocation_context.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from copy import deepcopy
from dataclasses import dataclass
from pathlib import Path
from typing import TYPE_CHECKING, Callable, Optional, Union
Expand Down Expand Up @@ -294,15 +295,15 @@ def save(self, tensor: Tensor) -> str:
return name

def load(self, name: str) -> Tensor:
"""Loads a tensor by name.
"""Loads a tensor by name. This method returns a copy of the tensor.

Args:
name: The name of the tensor to load.

Returns:
The loaded tensor.
The tensor.
"""
return self._services.tensors.load(name)
return self._services.tensors.load(name).clone()


class ConditioningInterface(InvocationContextInterface):
Expand All @@ -320,16 +321,16 @@ def save(self, conditioning_data: ConditioningFieldData) -> str:
return name

def load(self, name: str) -> ConditioningFieldData:
"""Loads conditioning data by name.
"""Loads conditioning data by name. This method returns a copy of the conditioning data.

Args:
name: The name of the conditioning data to load.

Returns:
The loaded conditioning data.
The conditioning data.
"""

return self._services.conditioning.load(name)
return deepcopy(self._services.conditioning.load(name))


class ModelsInterface(InvocationContextInterface):
Expand Down
Loading