Slackbot
11/08/2023, 6:43 AMStefan Krawczyk
11/08/2023, 7:23 AMJan Hurst
11/08/2023, 7:23 AMhamilton.io.materialization
before my saver is registered
seems this happens here
i'm just trying to revert to 1.31 to see if that helpsStefan Krawczyk
11/08/2023, 7:26 AMinjectors
were pushed recently, I wonder if that changed some behavior.Jan Hurst
11/08/2023, 7:29 AMJan Hurst
11/08/2023, 7:30 AMJan Hurst
11/08/2023, 7:31 AMStefan Krawczyk
11/08/2023, 7:35 AMJan Hurst
11/08/2023, 7:38 AMJan Hurst
11/08/2023, 7:48 AMElijah Ben Izzy
11/08/2023, 2:35 PMElijah Ben Izzy
11/08/2023, 2:38 PMElijah Ben Izzy
11/09/2023, 4:42 AMrc
version at sf-hamilton==1.37.2rc0
.
Now, before accessing a âdynamicâproperty in the materializer, youâll have to ensure register gets called. That either means calling it inline (uncommon), or importing a module that calls it in the body of the script (likely what youâre doing). I think the unit tests illustrates nicely:
def test_dynamic_properties_can_be_registered_after_import_for_saver():
@dataclasses.dataclass
class CustomDataSaver(DataSaver):
def save_data(self, type_: Type[Type]) -> Tuple[Type, Dict[str, Any]]:
return "value", {}
@classmethod
def applicable_types(cls) -> Collection[Type]:
return [dict]
@classmethod
def name(cls) -> str:
return "testing_unique_key_saver"
registry.register_adapter(CustomDataSaver)
materialize_property = Materialize.testing_unique_key_saver
to_property = to.testing_unique_key_saver
load_from_property = save_to.testing_unique_key_saver
assert materialize_property is not None
assert to_property is not None
assert load_from_property is not None
Jan Hurst
11/09/2023, 6:41 AMto
imported before i register my saver.... is it still a bit of a race? i think that is implied in your test right?Jan Hurst
11/09/2023, 7:06 AMElijah Ben Izzy
11/09/2023, 2:09 PMto
(and Materialize
, an internal construct) is imported out of scope. Registering just has to be done before calling to the property.Jan Hurst
11/10/2023, 7:30 AMElijah Ben Izzy
11/10/2023, 5:12 PM