From 455a8fbaeba13ff49c93dbe3edd818893b666ba2 Mon Sep 17 00:00:00 2001 From: Simon Gerber Date: Thu, 7 Mar 2024 16:43:26 +0100 Subject: [PATCH] Remove Kapitan patch --- README.md | 14 ++----- hack/kapitan_0.32_reclass_rs.patch | 67 ------------------------------ 2 files changed, 3 insertions(+), 78 deletions(-) delete mode 100644 hack/kapitan_0.32_reclass_rs.patch diff --git a/README.md b/README.md index f3a3b52..672a25e 100644 --- a/README.md +++ b/README.md @@ -89,23 +89,15 @@ The benchmarks are implemented with `criterion`. ## Testing reclass-rs in Kapitan -If you're using [Kapitan], you can test reclass-rs by installing `reclass-rs` in your Kapitan virtualenv: - -1. Install `reclass-rs` in your Kapitan virtualenv +If you're using [Kapitan], you can use reclass-rs by installing Kapitan with the optional `reclass-rs` dependency and specifying `--inventory-backend=reclass-rs` when running Kapitan. ``` KAPITAN_VENV=/path/to/your/kapitan/virtualenv source ${KAPITAN_VENV}/bin/activate -pip install reclass-rs -``` - -2. Patch the Kapitan package in the virtualenv with the following command - -``` -patch -p1 -d $KAPITAN_VENV < hack/kapitan_0.32_reclass_rs.patch +pip install kapitan[reclass-rs] ``` -Please note that we've only tested the patch against the Kapitan 0.32 release as published on PyPI. +See the [upstream Kapitan docs](https://kapitan.dev/pages/inventory/reclass-rs/) for more details. ## Automated package version management diff --git a/hack/kapitan_0.32_reclass_rs.patch b/hack/kapitan_0.32_reclass_rs.patch deleted file mode 100644 index e3f5505..0000000 --- a/hack/kapitan_0.32_reclass_rs.patch +++ /dev/null @@ -1,67 +0,0 @@ ---- a/resources.py 2023-09-11 14:17:16.240155393 +0200 -+++ b/resources.py 2023-09-11 14:17:32.876408955 +0200 -@@ -14,6 +14,7 @@ - import logging - import os - import sys -+from datetime import datetime - from functools import partial - - import jsonschema -@@ -27,6 +28,16 @@ - import reclass.core - from reclass.errors import NotFoundError, ReclassException - -+have_reclass_rs = False -+try: -+ from reclass_rs import Reclass -+ -+ # Configure reclass-rs to use as many threads as there are logical cores in the system -+ Reclass.set_thread_count(0) -+ have_reclass_rs = True -+except ImportError: -+ print("Couldn't import reclass_rs, falling back to Python reclass", file=sys.stderr) -+ - logger = logging.getLogger(__name__) - - try: -@@ -348,6 +359,27 @@ - for uri in ("nodes_uri", "classes_uri"): - reclass_config[uri] = os.path.normpath(os.path.join(inventory_path, reclass_config[uri])) - -+ if have_reclass_rs: -+ r = Reclass( -+ nodes_path=reclass_config["nodes_uri"], -+ classes_path=reclass_config["classes_uri"], -+ ignore_class_notfound=ignore_class_notfound, -+ ) -+ -+ print("running reclass_rs", file=sys.stderr) -+ start = datetime.now() -+ try: -+ inv = r.inventory() -+ except ValueError as e: -+ logger.error(f"Inventory reclass_rs error: {e}") -+ raise InventoryError(e) -+ elapsed = datetime.now() - start -+ print(f"Inventory (reclass_rs) took {elapsed}", file=sys.stderr) -+ -+ cached.inv = inv.as_dict() -+ return cached.inv -+ -+ print("Falling back to Python reclass", file=sys.stderr) - try: - storage = reclass.get_storage( - reclass_config["storage_type"], -@@ -358,7 +390,11 @@ - class_mappings = reclass_config.get("class_mappings") # this defaults to None (disabled) - _reclass = reclass.core.Core(storage, class_mappings, reclass.settings.Settings(reclass_config)) - -+ print("running reclass", file=sys.stderr) -+ start = datetime.now() - cached.inv = _reclass.inventory() -+ elapsed = datetime.now() - start -+ print(f"Inventory (reclass) took {elapsed}", file=sys.stderr) - except ReclassException as e: - if isinstance(e, NotFoundError): - logger.error("Inventory reclass error: inventory not found")