Skip to content

Conversation

@ramaro
Copy link
Member

@ramaro ramaro commented Jun 3, 2025

Fixes #1318

Proposed Changes

Docs and Tests

  • Tests added
  • Updated documentation

@ramaro ramaro changed the title Ramaro/compile cache Implement kadet input type cache Jun 6, 2025
"-c",
help="enable compilation caching to .kapitan_cache\
and dependency caching to .dependency_cache, default is False",
help="enable compilation caching to $XDG_CACHE_HOME/kapitan, default is False",
Copy link

Choose a reason for hiding this comment

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

Maybe it is should state:

caching preferably to $XDG_CACHE_HOME/kapitan or $HOME/kapitan, default is False"

or

caching preferably to $XDG_CACHE_HOME/kapitan (if XDG-compliant) or $HOME/kapitan, default is False"

or

caching either to $XDG_CACHE_HOME/kapitan or $HOME/kapitan, default is False"

default=from_dot_kapitan("compile", "cache", False),
)
compile_parser.add_argument(
"--cache-paths",
Copy link

Choose a reason for hiding this comment

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

Should the removal of the --cache-paths be announced on CHANGELOG.md file under the NEXT RELEASE - Breaking section?

@rjmco
Copy link

rjmco commented Jun 9, 2025

I think it would be good to have docstrings for the new functions

Copy link

@rjmco rjmco left a comment

Choose a reason for hiding this comment

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

Announcement of the new feature on the NEXT RELEASE section of the CHANGELOG.md might be missing.

default.nix Outdated
# from https://nixos.wiki/wiki/Python#Emulating_virtualenv_with_nix-shell
let
pkgs = import <nixpkgs> {};
in pkgs.mkShell {
Copy link

Choose a reason for hiding this comment

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

nit: in pkgs.mkShell with pkgs; {

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks, fixed

"""

input_params = config.input_params
target_name = self.target_name
Copy link

Choose a reason for hiding this comment

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

I would suggest changing slightly the initial line of this function's docstring from:

Compile a kadet input file.

to

Compile a kadet input file, if resulting compilation is not already cached

with open(cached_path_lock, "wb") as fp:
logger.debug("Writing cache file: %s", cached_path_lock)
self.dump_output(output_obj, fp)
cached_path_lock.rename(Path(str(cached_path_lock).removesuffix(".lock")))
Copy link

Choose a reason for hiding this comment

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

What if for some reason, someone aborts execution and this step is never executed? Should there be a recommendation to remove the .lock? Would it be to:

  1. Delete the whole cache?
  2. Delete just the .lock file?
  3. Remove the .locl suffix?

@ramaro ramaro force-pushed the ramaro/compile-cache branch from 97da85b to 8dbb04b Compare July 4, 2025 20:52
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.

[feat]: Cache unchanged compiled items to disk

3 participants