Removed entity client dependency

pull/875/head
kompotkot 2023-07-31 12:36:48 +00:00
rodzic a3b0841d10
commit bbe1530eef
5 zmienionych plików z 7 dodań i 27 usunięć

Wyświetl plik

@ -774,12 +774,7 @@ def fix_duplicates_keys_in_entity_subscription():
secondary_fields = secondary_fields["secondary_fields"] secondary_fields = secondary_fields["secondary_fields"]
# get entity id
entity_id = entity.entity_id
# get entity type # get entity type
entity_type = None entity_type = None
# extract required fields # extract required fields
@ -800,7 +795,7 @@ def fix_duplicates_keys_in_entity_subscription():
new_required_fields.append( new_required_fields.append(
{"type": "copy_of_malformed_entity_20230213"} {"type": "copy_of_malformed_entity_20230213"}
) )
new_required_fields.append({"entity_id": str(entity_id)}) new_required_fields.append({"entity_id": str(entity.id)})
new_entity = bc.create_entity( new_entity = bc.create_entity(
token=MOONSTREAM_ADMIN_ACCESS_TOKEN, token=MOONSTREAM_ADMIN_ACCESS_TOKEN,
@ -812,12 +807,12 @@ def fix_duplicates_keys_in_entity_subscription():
secondary_fields=entity.secondary_fields, secondary_fields=entity.secondary_fields,
) )
logger.info( logger.info(
f"Entity {new_entity.entity_id} created successfully for journal (collection) {journal_id}" f"Entity {new_entity.id} created successfully for journal (collection) {journal_id}"
) )
except Exception as e: except Exception as e:
logger.error( logger.error(
f"Failed to create entity {entity_id} for journal (collection) {journal_id}: {str(e)}, user_id: {user_id}" f"Failed to create entity {entity.id} for journal (collection) {journal_id}: {str(e)}, user_id: {user_id}"
) )
continue continue
@ -827,7 +822,7 @@ def fix_duplicates_keys_in_entity_subscription():
bc.update_entity( bc.update_entity(
token=MOONSTREAM_ADMIN_ACCESS_TOKEN, token=MOONSTREAM_ADMIN_ACCESS_TOKEN,
journal_id=journal_id, journal_id=journal_id,
entity_id=entity_id, entity_id=entity.id,
blockchain=entity.blockchain, blockchain=entity.blockchain,
address=entity.address, address=entity.address,
title=entity.title, title=entity.title,
@ -835,10 +830,10 @@ def fix_duplicates_keys_in_entity_subscription():
secondary_fields=secondary_fields, secondary_fields=secondary_fields,
) )
logger.info( logger.info(
f"Entity {entity_id} updated successfully for journal (collection) {journal_id}" f"Entity {entity.id} updated successfully for journal (collection) {journal_id}"
) )
except Exception as e: except Exception as e:
logger.error( logger.error(
f"Failed to update entity {entity_id} for journal (collection) {journal_id}: {str(e)}, user_id: {user_id}" f"Failed to update entity {entity.id} for journal (collection) {journal_id}: {str(e)}, user_id: {user_id}"
) )

Wyświetl plik

@ -24,7 +24,6 @@ from ..settings import (
MOONSTREAM_S3_SMARTCONTRACTS_ABI_PREFIX, MOONSTREAM_S3_SMARTCONTRACTS_ABI_PREFIX,
) )
from ..settings import bugout_client as bc from ..settings import bugout_client as bc
from ..settings import entity_client as ec
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

Wyświetl plik

@ -1,12 +1,9 @@
import os import os
from typing import Optional, Dict from typing import Dict, Optional
from uuid import UUID
from bugout.app import Bugout from bugout.app import Bugout
from entity.client import Entity # type: ignore
from moonstreamdb.blockchain import AvailableBlockchainType from moonstreamdb.blockchain import AvailableBlockchainType
# Bugout # Bugout
BUGOUT_BROOD_URL = os.environ.get("BUGOUT_BROOD_URL", "https://auth.bugout.dev") BUGOUT_BROOD_URL = os.environ.get("BUGOUT_BROOD_URL", "https://auth.bugout.dev")
BUGOUT_SPIRE_URL = os.environ.get("BUGOUT_SPIRE_URL", "https://spire.bugout.dev") BUGOUT_SPIRE_URL = os.environ.get("BUGOUT_SPIRE_URL", "https://spire.bugout.dev")
@ -14,15 +11,6 @@ BUGOUT_SPIRE_URL = os.environ.get("BUGOUT_SPIRE_URL", "https://spire.bugout.dev"
bugout_client = Bugout(brood_api_url=BUGOUT_BROOD_URL, spire_api_url=BUGOUT_SPIRE_URL) bugout_client = Bugout(brood_api_url=BUGOUT_BROOD_URL, spire_api_url=BUGOUT_SPIRE_URL)
# Entity
MOONSTREAM_ENTITY_URL = os.environ.get("MOONSTREAM_ENTITY_URL", "")
if MOONSTREAM_ENTITY_URL == "":
raise ValueError("MOONSTREAM_ENTITY_URL environment variable must be set")
entity_client = Entity(MOONSTREAM_ENTITY_URL)
BUGOUT_REQUEST_TIMEOUT_SECONDS = 5 BUGOUT_REQUEST_TIMEOUT_SECONDS = 5
HUMBUG_REPORTER_BACKEND_TOKEN = os.environ.get("HUMBUG_REPORTER_BACKEND_TOKEN") HUMBUG_REPORTER_BACKEND_TOKEN = os.environ.get("HUMBUG_REPORTER_BACKEND_TOKEN")

Wyświetl plik

@ -36,7 +36,6 @@ jsonschema==4.17.0
lru-dict==1.1.8 lru-dict==1.1.8
Mako==1.2.3 Mako==1.2.3
MarkupSafe==2.1.1 MarkupSafe==2.1.1
moonstream-entity==0.0.5
moonstreamdb==0.3.4 moonstreamdb==0.3.4
multiaddr==0.0.9 multiaddr==0.0.9
multidict==6.0.2 multidict==6.0.2

Wyświetl plik

@ -14,7 +14,6 @@ setup(
"appdirs", "appdirs",
"boto3", "boto3",
"bugout>=0.2.12", "bugout>=0.2.12",
"moonstream-entity>=0.0.5",
"fastapi", "fastapi",
"moonstreamdb>=0.3.4", "moonstreamdb>=0.3.4",
"humbug", "humbug",