From 4f3bf7429031406442b39d2b30603e3586112fcb Mon Sep 17 00:00:00 2001
From: Daniel <d.hornung@indiscale.com>
Date: Wed, 21 Feb 2024 17:01:36 +0100
Subject: [PATCH] MAINT: Documentation, formatting, typos, error messages,
 linkahead

---
 src/caoscrawler/converters.py            |  2 +-
 src/caoscrawler/crawl.py                 | 17 ++++++++---------
 src/caoscrawler/hdf5_converter.py        |  2 +-
 src/caoscrawler/identifiable.py          |  2 +-
 src/caoscrawler/identifiable_adapters.py |  6 +++---
 src/caoscrawler/scanner.py               |  2 +-
 src/caoscrawler/utils.py                 |  2 +-
 unittests/test_crawler.py                |  6 +++---
 8 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/src/caoscrawler/converters.py b/src/caoscrawler/converters.py
index dddb83a7..772f690b 100644
--- a/src/caoscrawler/converters.py
+++ b/src/caoscrawler/converters.py
@@ -36,7 +36,7 @@ from inspect import signature
 from string import Template
 from typing import Any, List, Optional, Tuple, Union
 
-import caosdb as db
+import linkahead as db
 import pandas as pd
 import yaml
 import yaml_header_tools
diff --git a/src/caoscrawler/crawl.py b/src/caoscrawler/crawl.py
index e0bddb57..698a154f 100644
--- a/src/caoscrawler/crawl.py
+++ b/src/caoscrawler/crawl.py
@@ -207,14 +207,13 @@ def _treat_merge_error_of(newrecord, record):
                 # TODO can we also compare lists?
                 and not isinstance(this_p.value, list)
                     and not isinstance(that_p.value, list)):
-                logger.error("The Crawler is trying to merge two entities "
-                             "because they should be the same object (same"
-                             " identifiables), but they have  "
-                             "different values for the same Property."
-                             f"Problematic Property: {this_p.name}\n"
-                             f"Values: {this_p.value} and "
-                             f"{that_p.value}\n"
-                             f"{record}\n{newrecord}")
+                logger.error(
+                    "The Crawler is trying to merge two entities because they should be the same "
+                    "object (same identifiables), but they have different values for the same "
+                    "Property.\n"
+                    f"Problematic Property: {this_p.name}\n"
+                    f"Values: {this_p.value} and {that_p.value}\n"
+                    f"{record}\n{newrecord}")
                 raise RuntimeError("Cannot merge Entities")
 
 
@@ -1149,7 +1148,7 @@ class Crawler(object):
         """
         if crawled_data is None:
             warnings.warn(DeprecationWarning(
-                "Calling synchronize without the data to be synchronized is depricated. Please "
+                "Calling synchronize without the data to be synchronized is deprecated. Please "
                 "use for example the Scanner to create this data."))
             crawled_data = self.crawled_data
 
diff --git a/src/caoscrawler/hdf5_converter.py b/src/caoscrawler/hdf5_converter.py
index 506c7b39..5b1ff577 100644
--- a/src/caoscrawler/hdf5_converter.py
+++ b/src/caoscrawler/hdf5_converter.py
@@ -30,7 +30,7 @@ import numpy as np
 
 from typing import Union
 
-import caosdb as db
+import linkahead as db
 
 from .converters import (convert_basic_element, Converter, DictElementConverter,
                          match_name_and_value, SimpleFileConverter)
diff --git a/src/caoscrawler/identifiable.py b/src/caoscrawler/identifiable.py
index 75af5be8..cefdf4a0 100644
--- a/src/caoscrawler/identifiable.py
+++ b/src/caoscrawler/identifiable.py
@@ -20,7 +20,7 @@
 #
 
 from __future__ import annotations
-import caosdb as db
+import linkahead as db
 from datetime import datetime
 import json
 from hashlib import sha256
diff --git a/src/caoscrawler/identifiable_adapters.py b/src/caoscrawler/identifiable_adapters.py
index d661b97a..da31fa39 100644
--- a/src/caoscrawler/identifiable_adapters.py
+++ b/src/caoscrawler/identifiable_adapters.py
@@ -84,13 +84,13 @@ class IdentifiableAdapter(metaclass=ABCMeta):
 
 Some terms:
 
-- Registered identifiable is the definition of an identifiable which is:
+- *Registered identifiable* is defined as an identifiable with:
     - A record type as the parent
     - A list of properties
     - A list of referenced by statements
-- Identifiable is the concrete identifiable, e.g. the Record based on
+- *Identifiable* is the concrete identifiable, e.g. the Record based on
     the registered identifiable with all the values filled in.
-- Identified record is the result of retrieving a record based on the
+- *Identified record* is the result of retrieving a record based on the
     identifiable from the database.
 
 General question to clarify:
diff --git a/src/caoscrawler/scanner.py b/src/caoscrawler/scanner.py
index c4a8063c..5d92401a 100644
--- a/src/caoscrawler/scanner.py
+++ b/src/caoscrawler/scanner.py
@@ -39,7 +39,7 @@ import warnings
 from collections.abc import Callable
 from typing import Any, Optional, Type, Union
 
-import caosdb as db
+import linkahead as db
 import yaml
 from importlib_resources import files
 from jsonschema import validate
diff --git a/src/caoscrawler/utils.py b/src/caoscrawler/utils.py
index 61b36309..c62f44ee 100644
--- a/src/caoscrawler/utils.py
+++ b/src/caoscrawler/utils.py
@@ -25,7 +25,7 @@
 
 # Some utility functions, e.g. for extending pylib.
 
-import caosdb as db
+import linkahead as db
 
 
 def has_parent(entity: db.Entity, name: str):
diff --git a/unittests/test_crawler.py b/unittests/test_crawler.py
index 26aa9e73..14185d45 100644
--- a/unittests/test_crawler.py
+++ b/unittests/test_crawler.py
@@ -51,9 +51,9 @@ from caoscrawler.scanner import (create_converter_registry, scan_directory,
 from caoscrawler.stores import GeneralStore, RecordStore
 from caoscrawler.structure_elements import (DictElement, DictListElement,
                                             DictTextElement, File)
-from caosdb.apiutils import compare_entities
-from caosdb.cached import cache_clear
-from caosdb.exceptions import EmptyUniqueQueryError
+from linkahead.apiutils import compare_entities
+from linkahead.cached import cache_clear
+from linkahead.exceptions import EmptyUniqueQueryError
 from pytest import raises
 
 UNITTESTDIR = Path(__file__).parent
-- 
GitLab