Skip to content

Commit

Permalink
Do not read multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
ademariag committed Aug 17, 2024
1 parent 8dec97b commit 365fa9c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions kapitan/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import kapitan.cached as cached
from kapitan import __file__ as kapitan_install_path
from kapitan.inputs.kadet import Dict
from kapitan.errors import CompileError, InventoryError, KapitanError
from kapitan.inventory import Inventory, ReclassInventory, AVAILABLE_BACKENDS
from kapitan.utils import PrettyDumper, deep_get, flatten_dict, render_jinja2_file, sha256_string
Expand Down Expand Up @@ -334,6 +335,13 @@ def get_inventory(inventory_path, ignore_class_not_found: bool = False) -> Inven

cached.inv = inventory_backend
cached.global_inv = cached.inv.inventory

# if we use forked processes, we need to load the inventory for kadet once
# and pass it to the children, to avoid re-reading the inventory for each child
# TODO(adenaria): Improve to only do it for kadet
if cached.args.mp_method != "spawn":
cached.inventory_global_kadet = Dict(cached.global_inv)

# migrate inventory to selected inventory backend
if hasattr(cached.args, "migrate") and cached.args.migrate:
inventory_backend.migrate()
Expand Down

0 comments on commit 365fa9c

Please sign in to comment.