Skip to content
Snippets Groups Projects
Commit 3a40e9a2 authored by florian's avatar florian
Browse files

MAINT: Use new error and reorganize imports

parent d13fc55d
No related branches found
No related tags found
2 merge requests!91Release 0.3,!62Fix merge conflict in split_into_inserts_and_updates
Pipeline #30660 failed
...@@ -29,35 +29,40 @@ the acuired data with CaosDB. ...@@ -29,35 +29,40 @@ the acuired data with CaosDB.
""" """
from __future__ import annotations from __future__ import annotations
import argparse
import importlib import importlib
from caosadvancedtools.cache import UpdateCache, Cache import logging
import uuid
import sys
import os import os
import sys
import uuid
import warnings
import yaml import yaml
from argparse import RawTextHelpFormatter
from collections import defaultdict
from copy import deepcopy
from enum import Enum from enum import Enum
import logging
from importlib_resources import files from importlib_resources import files
import argparse from jsonschema import validate
from argparse import RawTextHelpFormatter from typing import Any, Optional, Type, Union
import caosdb as db import caosdb as db
from caosadvancedtools.cache import UpdateCache, Cache
from caosadvancedtools.crawler import Crawler as OldCrawler from caosadvancedtools.crawler import Crawler as OldCrawler
import warnings from caosdb.apiutils import (compare_entities, EntityMergeConflictError,
merge_entities)
from caosdb.common.datatype import is_reference from caosdb.common.datatype import is_reference
from .stores import GeneralStore, RecordStore
from .identified_cache import IdentifiedCache
from .structure_elements import StructureElement, Directory
from .converters import Converter, DirectoryConverter from .converters import Converter, DirectoryConverter
from .identifiable_adapters import (IdentifiableAdapter, from .identifiable_adapters import (IdentifiableAdapter,
LocalStorageIdentifiableAdapter, LocalStorageIdentifiableAdapter,
CaosDBIdentifiableAdapter) CaosDBIdentifiableAdapter)
from collections import defaultdict from .identified_cache import IdentifiedCache
from typing import Any, Optional, Type, Union
from caosdb.apiutils import compare_entities, merge_entities
from copy import deepcopy
from jsonschema import validate
from .macros import defmacro_constructor, macro_constructor from .macros import defmacro_constructor, macro_constructor
from .stores import GeneralStore, RecordStore
from .structure_elements import StructureElement, Directory
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
...@@ -744,11 +749,8 @@ class Crawler(object): ...@@ -744,11 +749,8 @@ class Crawler(object):
newrecord = self.get_from_any_cache(record) newrecord = self.get_from_any_cache(record)
try: try:
merge_entities(newrecord, record) merge_entities(newrecord, record)
except RuntimeError as re: except EntityMergeConflictError:
if "Merge conflict" in str(re):
continue continue
else:
raise re
Crawler.bend_references_to_new_object( Crawler.bend_references_to_new_object(
old=record, new=newrecord, entities=flat + to_be_updated + to_be_inserted) old=record, new=newrecord, entities=flat + to_be_updated + to_be_inserted)
...@@ -986,7 +988,8 @@ class Crawler(object): ...@@ -986,7 +988,8 @@ class Crawler(object):
if self.identifiableAdapter is None: if self.identifiableAdapter is None:
raise RuntimeError("Should not happen.") raise RuntimeError("Should not happen.")
to_be_inserted, to_be_updated = self.split_into_inserts_and_updates(crawled_data) to_be_inserted, to_be_updated = self.split_into_inserts_and_updates(
crawled_data)
# TODO: refactoring of typo # TODO: refactoring of typo
for el in to_be_updated: for el in to_be_updated:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment