Skip to content

Commit

Permalink
fix(nodes): return copies of objects in invocation ctx
Browse files Browse the repository at this point in the history
Closes #6820
  • Loading branch information
psychedelicious committed Oct 25, 2024
1 parent 3800170 commit fd53f38
Showing 1 changed file with 7 additions and 6 deletions.
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

0 comments on commit fd53f38

Please sign in to comment.