Skip to content

Feat/in memory/cacheable mixin#440

Draft
utotsubasa wants to merge 16 commits intom3dev:masterfrom
utotsubasa:feat/in_memory/cacheable_mixin
Draft

Feat/in memory/cacheable mixin#440
utotsubasa wants to merge 16 commits intom3dev:masterfrom
utotsubasa:feat/in_memory/cacheable_mixin

Conversation

@utotsubasa
Copy link
Copy Markdown
Contributor

No description provided.

feat: last_modification_time feature in `InMemoryTarget`
style: add some type hints
fix: fix typo in `InMemoryCacheRepository`
test: add some tests for `InMemoryTarget` and `InMemoryCacheRepository`
style: update variable name from `id` to `key`
feat: add the new parameter `cache_in_memory_by_default` to switch default Target
style: update the variable name from `target_key` to `data_key` for code consistency
test: add tests for `TaskOnKart`s with the `cache_in_memory` parameter
feat: add cacheable flag to `make_target`
test: add test fo Cacheable Targets
chore: move `InMemoryTarget` to `gokart.target` to avoid circular dependencies
test: add tests for `CacheableModelTarget`
@utotsubasa utotsubasa marked this pull request as ready for review February 12, 2025 06:38
@utotsubasa utotsubasa marked this pull request as draft February 12, 2025 12:39
Copy link
Copy Markdown

@JiwaniZakir JiwaniZakir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In gokart/in_memory/data.py, create_data is decorated with @classmethod but uses self as the first parameter instead of cls — this is a bug that will work accidentally but is semantically incorrect and will confuse readers. In cacheable.py, load is annotated as returning bool (def load(self) -> bool) when it clearly returns the cached data object (Any), which will mislead type checkers and callers. The class-level _cache: dict[str, InMemoryData] = {} on InMemoryCacheRepository is shared across all instances, and since InMemoryCacheRepository is a singleton, clearing the cache between test runs requires explicit teardown — there should be a clear() method exposed on the repository, and tests should verify isolation. Finally, the InstantScheduler comment # TODO: ambiguous class name acknowledges a real problem: the name implies no-op scheduling, but it actually deletes entries on get_hook, behaving like a "use once" or "consume" cache — OneShotScheduler or ConsumeOnReadScheduler would be much clearer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants