Konstantin Sofeikov
12/23/2024, 10:46 PMpl.DataFrame and metadata, something like this
@dataloader() # type: ignore[misc]
def A(
mongo_client: DocumentMongoClient,
) -> tuple[pl.DataFrame, dict[str, Any]]:
If caching on the driver is enabled with
dr = (
driver.Builder()
.with_modules(temp_module)
.with_modules(one_hot_module)
.with_cache()
.with_config({"stage": "training"})
.build()
)
, is that stage supposed to cached and the database is not to be reached or does it work differently? The reason I’m asking is because I clearly see that the result of this node is depicted as from cache on a dr.cache.view_run() , but what I also see is that there is a massive spike in networking activity from my laptop when the graph is called. So like on the pic, the dataloders are not drawn as cached(they should not be I guess), and the result is cached, yet there is clearly data download happening every time this is called.Stefan Krawczyk
12/23/2024, 11:09 PMview_run().Stefan Krawczyk
12/23/2024, 11:10 PMmongo_client might be the issue?Stefan Krawczyk
12/23/2024, 11:13 PMStefan Krawczyk
12/23/2024, 11:24 PMfrom hamilton.caching import fingerprinting
from mongodb import DocumentMongoClient # I'm guessing this part
@fingerprinting.hash_value.register(DocumentMongoClient)
def hash_db_client_object(obj, *args, depth: int = 0, **kwargs) -> str:
"""Object hash"""
return "constant" # change this obviously if you want to differentiate between clients, etc.
Do that where your driver code lives. Then this should make the db_client have a consistent hash so that then caching should work as expected.Konstantin Sofeikov
12/24/2024, 7:12 AM