Konstantin Sofeikov
01/08/2025, 1:59 PMnode_name: name of the node
code_version: version of the node's code
dependencies_data_versions: data_version of each dependency of the node
question is: are node input values taken from .with_config() considered part of dependencies_data_versions, or are only results from other nodes included? I've got a problem wherein I pull some data from a db and cache it, but I pull data based on a max_date value supplied through the config. If the cache is clean, then I get different results, for 3 different dates. On a second run though all results are the same, as if only the one of them is returned. Cache logs show cash hit all the time
So I'm trying to figure out is it how caching works and I need to have a node with a date, so it's cached separately, or the problem is elsewhereThierry Jean
01/08/2025, 2:00 PMpip list)Konstantin Sofeikov
01/08/2025, 2:01 PM"sf-hamilton>=1.85.1",Konstantin Sofeikov
01/08/2025, 2:01 PMsf-hamilton 1.85.1
sf-hamilton-sdk 0.8.0
sf-hamilton-ui 0.0.15Konstantin Sofeikov
01/08/2025, 2:02 PMKonstantin Sofeikov
01/08/2025, 2:02 PMThierry Jean
01/08/2025, 2:04 PMdef data_from_db(max_date: datetime.datetime) -> pd.DataFrame: ...
def transform(data_from_db: pd.DataFrame) -> pd.DataFrame: ...
#
dr = driver.Builder().with_config(max_date=datetime.datetime(...)).with_cache()
dr.execute()Konstantin Sofeikov
01/08/2025, 2:05 PMThierry Jean
01/08/2025, 2:06 PMdatetime objects. These classes are oddly defined compared to the rest of the Python standard library. It was a quick fix once we could pin point the issue!Konstantin Sofeikov
01/08/2025, 2:08 PMKonstantin Sofeikov
01/08/2025, 2:08 PMKonstantin Sofeikov
01/08/2025, 2:09 PMThierry Jean
01/08/2025, 2:10 PM1.85.1 If you can open a new issue with a small repro or reproduce yourself the Investigation section I shared here: https://github.com/DAGWorks-Inc/hamilton/issues/1242Konstantin Sofeikov
01/08/2025, 2:32 PMThierry Jean
01/08/2025, 3:16 PMKonstantin Sofeikov
01/08/2025, 3:28 PMKonstantin Sofeikov
01/08/2025, 3:29 PM@fingerprinting.hash_value.register(MongoClient) # type: ignore[misc]
def hash_db_client_object(obj: DocumentMongoClient, *args: Any, **kwargs: Any) -> str:
"""Trick hamilton into caching data loading stage and avoid DB access."""
return "constant"Konstantin Sofeikov
01/08/2025, 3:32 PMThierry Jean
01/08/2025, 3:35 PMmax_date relates to the hash_db_client_object().
With access to code I would do:
1. start with a clean cache and reproduce the bug you described (run with 3 different dates, expecting different result, but getting the same result)
2. access Driver.cache to get .cache_keys. You should get a dictionary of {run_id: {node_name: cache_key}
3. Use hamilton.caching.cache_key.decode_key() on the cache key for max_date. You will get a dictionary of {node_name, code_version, data_version}
4. Given your description, I expect that the data_version for the 3 different values of max_date are the same while you expect them to be different.Konstantin Sofeikov
01/08/2025, 3:36 PMThierry Jean
01/08/2025, 3:37 PMdr.cache.view_run() to display a graph of what was retrieved from cache or not btwThierry Jean
01/08/2025, 3:38 PMrun_id values from dr.cache.run_ids and pass the value to dr.cache.view_run(run_id) to compare the caching behavior between run (Typically, investigating empty cache -> run 1 and run 1 -> run 2 is sufficient for debugging)Konstantin Sofeikov
01/08/2025, 3:39 PMKonstantin Sofeikov
01/08/2025, 3:39 PMKonstantin Sofeikov
01/08/2025, 3:39 PM