From adbb68a7591030c03b75b73afe52dca94500b563 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <h.tomwoerden@indiscale.com> Date: Wed, 3 May 2023 11:38:03 +0200 Subject: [PATCH] MAINT: clear cache when necessary --- src/caoscrawler/crawl.py | 3 ++- unittests/test_tool.py | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/caoscrawler/crawl.py b/src/caoscrawler/crawl.py index 68a0977c..d95af7f0 100644 --- a/src/caoscrawler/crawl.py +++ b/src/caoscrawler/crawl.py @@ -38,7 +38,7 @@ import logging import os import sys import uuid -from caosdb.cached import cached_get_entity_by +from caosdb.cached import cached_get_entity_by, cache_clear import warnings import yaml @@ -847,6 +847,7 @@ class Crawler(object): logger.info(f"Going to insert {len(to_be_inserted)} Entities and update " f"{len(to_be_updated)} Entities.") if commit_changes: + cache_clear() self.execute_parent_updates_in_list(to_be_updated, securityMode=self.securityMode, run_id=self.run_id, unique_names=unique_names) logger.info(f"Added parent RecordTypes where necessary.") diff --git a/unittests/test_tool.py b/unittests/test_tool.py index 0853cb33..c8b11523 100755 --- a/unittests/test_tool.py +++ b/unittests/test_tool.py @@ -46,7 +46,7 @@ from os.path import join, dirname, basename import yaml import caosdb as db from caosdb.apiutils import compare_entities - +from caosdb.cached import cache_clear import pytest from pytest import raises @@ -76,6 +76,11 @@ def dircheckstr(*pathcomponents): "test_directories", "examples_article", *pathcomponents)) +@pytest.fixture +def clear_cache(autouse=True): + cache_clear() + + @pytest.fixture def crawler(): crawler = Crawler() -- GitLab