|
27 | 27 | ) |
28 | 28 | from snowfakery.plugins import PluginContext, SnowfakeryPlugin, ScalarTypes |
29 | 29 | from snowfakery.utils.collections import OrderedSet |
| 30 | +from snowfakery.utils.yaml_utils import register_for_continuation |
30 | 31 |
|
31 | 32 | OutputStream = "snowfakery.output_streams.OutputStream" |
32 | 33 | VariableDefinition = "snowfakery.data_generator_runtime_object_model.VariableDefinition" |
@@ -60,6 +61,7 @@ def generate_id(self, table_name: str) -> int: |
60 | 61 | def __getitem__(self, table_name: str) -> int: |
61 | 62 | return self.last_used_ids[table_name] |
62 | 63 |
|
| 64 | + # TODO: Fix this to use the new convention of get_continuation_data |
63 | 65 | def __getstate__(self): |
64 | 66 | return {"last_used_ids": dict(self.last_used_ids)} |
65 | 67 |
|
@@ -195,21 +197,14 @@ def check_slots_filled(self): |
195 | 197 | def first_new_id(self, tablename): |
196 | 198 | return self.transients.first_new_id(tablename) |
197 | 199 |
|
198 | | - def __getstate__(self): |
199 | | - def serialize_dict_of_object_rows(dct): |
200 | | - return {k: v.__getstate__() for k, v in dct.items()} |
201 | | - |
202 | | - persistent_nicknames = serialize_dict_of_object_rows(self.persistent_nicknames) |
203 | | - persistent_objects_by_table = serialize_dict_of_object_rows( |
204 | | - self.persistent_objects_by_table |
205 | | - ) |
| 200 | + def get_continuation_state(self): |
206 | 201 | intertable_dependencies = [ |
207 | 202 | dict(v._asdict()) for v in self.intertable_dependencies |
208 | 203 | ] # converts ordered-dict to dict for Python 3.6 and 3.7 |
209 | 204 |
|
210 | 205 | state = { |
211 | | - "persistent_nicknames": persistent_nicknames, |
212 | | - "persistent_objects_by_table": persistent_objects_by_table, |
| 206 | + "persistent_nicknames": self.persistent_nicknames, |
| 207 | + "persistent_objects_by_table": self.persistent_objects_by_table, |
213 | 208 | "id_manager": self.id_manager.__getstate__(), |
214 | 209 | "today": self.today, |
215 | 210 | "nicknames_and_tables": self.nicknames_and_tables, |
@@ -244,6 +239,9 @@ def deserialize_dict_of_object_rows(dct): |
244 | 239 | self.reset_slots() |
245 | 240 |
|
246 | 241 |
|
| 242 | +register_for_continuation(Globals, Globals.get_continuation_state) |
| 243 | + |
| 244 | + |
247 | 245 | class JinjaTemplateEvaluatorFactory: |
248 | 246 | def __init__(self, native_types: bool): |
249 | 247 | if native_types: |
|
0 commit comments