From 258ba268959ced02f4e04104d5310e83afb4d777 Mon Sep 17 00:00:00 2001 From: Alexander Schlemmer <a.schlemmer@indiscale.com> Date: Mon, 6 Jan 2025 21:07:32 +0100 Subject: [PATCH] FIX: converter cleanup at wrong position --- src/caoscrawler/crawl.py | 3 ++- src/caoscrawler/scanner.py | 12 +++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/caoscrawler/crawl.py b/src/caoscrawler/crawl.py index e0d24397..f0986367 100644 --- a/src/caoscrawler/crawl.py +++ b/src/caoscrawler/crawl.py @@ -66,7 +66,8 @@ from .identifiable_adapters import (CaosDBIdentifiableAdapter, from .logging import configure_server_side_logging from .macros import defmacro_constructor, macro_constructor from .scanner import (create_converter_registry, initialize_converters, - load_definition, scan_directory, scan_structure_elements) + load_definition, save_debug_tree, scan_directory, + scan_structure_elements) from .stores import GeneralStore from .structure_elements import StructureElement from .sync_graph import SyncGraph diff --git a/src/caoscrawler/scanner.py b/src/caoscrawler/scanner.py index 7f2dd64d..57b540d1 100644 --- a/src/caoscrawler/scanner.py +++ b/src/caoscrawler/scanner.py @@ -37,16 +37,17 @@ from __future__ import annotations import importlib import logging import os +import pathlib import warnings from collections.abc import Callable from typing import Any, Optional, Union import jinja2 - import linkahead as db import yaml from importlib_resources import files from jsonschema import validate +from linkahead.high_level_api import convert_to_python_object from .converters import Converter from .debug_tree import DebugTree @@ -54,9 +55,6 @@ from .stores import GeneralStore, RecordStore from .structure_elements import Directory, StructureElement from .version import check_cfood_version -from linkahead.high_level_api import convert_to_python_object -import pathlib - logger = logging.getLogger(__name__) @@ -459,6 +457,9 @@ def scanner(items: list[StructureElement], converter_dictionary["subtree"] = sub_debug_tree matching_converters.append(converter_dictionary) + # Clean up converter: + converter.cleanup() + if new_debug_tree is not None: element_dictionary = element.get_dict() if not at_least_one_matched: @@ -468,9 +469,6 @@ def scanner(items: list[StructureElement], element_dictionary["matching_converters"] = matching_converters new_debug_tree.append(element_dictionary) - # Clean up converter: - converter.cleanup() - if restricted_path and not path_found: raise RuntimeError("A 'restricted_path' argument was given that is not contained in " "the data tree") -- GitLab