Skip to content

Commit 3485fb4

Browse files
committed
feat: allow projects to be pickled and unpickled safely for serde and multiprocessing
1 parent 5d2f218 commit 3485fb4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/dbt_core_interface/project.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import uuid
2020
import weakref
2121
from concurrent.futures import ThreadPoolExecutor
22-
from dataclasses import asdict, dataclass, field
22+
from dataclasses import dataclass, field
2323
from dataclasses import replace as dc_replace
2424
from datetime import datetime
2525
from multiprocessing import get_context as get_mp_context
@@ -1030,3 +1030,10 @@ def clear_deferred_state(self) -> None:
10301030
for node in self.manifest.nodes.values():
10311031
if hasattr(node, "defer_relation"):
10321032
node.defer_relation = None # pyright: ignore[reportAttributeAccessIssue]
1033+
1034+
def __reduce__( # pyright: ignore[reportImplicitOverride]
1035+
self,
1036+
) -> tuple[t.Callable[[DbtConfiguration], DbtProject], tuple[DbtConfiguration]]:
1037+
"""Use for pickling the DbtProject instance."""
1038+
config = self.to_config()
1039+
return (self.__class__.from_config, (config,))

0 commit comments

Comments
 (0)