Skip to content

Implement kadet input type cache #1319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft

Implement kadet input type cache #1319

wants to merge 8 commits into from

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
@@ -264,19 +268,10 @@ def build_parser():
compile_parser.add_argument(
"--cache",
"-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"

action="store_true",
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.

# 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; {

@@ -102,34 +116,47 @@ def compile_file(self, config: KapitanInputTypeKadetConfig, input_path, compile_
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?

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
2 participants