handle exception, adapt more tests to framework

This commit is contained in:
dbth
2025-01-04 19:13:22 +01:00
parent e5ac4ee96c
commit 90e959270f
6 changed files with 25 additions and 7 deletions

1
.gitignore vendored
View File

@@ -198,3 +198,4 @@ tests/cat4.png
*.png
tests/gifs/data.mdb
tests/gifs/lock.mdb
tests/gif_library.py

View File

@@ -237,7 +237,10 @@ async def send_event_outbox(event: Event, client, dvm_config) -> SendEventOutput
if len(relays) == 0:
return None
for relay in relays:
await outboxclient.add_relay(relay)
try:
await outboxclient.add_relay(relay)
except:
print("[" + dvm_config.NIP89.NAME + "] " + relay + " couldn't be added to outbox relays")
try:
await outboxclient.connect()
event_response = await outboxclient.send_event(event)
@@ -276,7 +279,11 @@ async def send_event(event: Event, client: Client, dvm_config, broadcast=False):
for relay in relays:
if relay not in dvm_config.RELAY_LIST:
await client.add_relay(relay)
try:
await client.add_relay(relay)
except:
print("[" + dvm_config.NIP89.NAME + "] " + relay + " couldn't be added to relays")
await client.connect()

View File

@@ -4,6 +4,7 @@ from pathlib import Path
import dotenv
from nostr_sdk import init_logger, LogLevel
from nostr_dvm.framework import DVMFramework
from nostr_dvm.tasks.content_discovery_currently_popular_mostr import DicoverContentCurrentlyPopularMostr
from nostr_dvm.utils.admin_utils import AdminConfig
from nostr_dvm.utils.dvmconfig import build_default_config
@@ -23,7 +24,7 @@ if use_logger:
init_logger(LogLevel.ERROR)
RELAY_LIST = ["wss://nostr.mom",
RELAY_LIST = ["wss://relay.nostrdvm.com",
#"wss://relay.primal.net",
"wss://nostr.oxtr.dev",
#"wss://relay.nostr.net"
@@ -72,6 +73,8 @@ def build_example_mostr(name, identifier, admin_config, options, image, cost=0,
def playground():
framework = DVMFramework()
# Popular Global
admin_config_global_wot = AdminConfig()
admin_config_global_wot.REBROADCAST_NIP89 = rebroadcast_NIP89
@@ -101,7 +104,8 @@ def playground():
update_rate=global_update_rate,
processing_msg=custom_processing_msg,
update_db=update_db)
discovery_mostr.run(True)
framework.add(discovery_mostr)
framework.run()

View File

@@ -5,6 +5,7 @@ import dotenv
from duck_chat import ModelType
from nostr_sdk import Kind
from nostr_dvm.framework import DVMFramework
from nostr_dvm.tasks.generic_dvm import GenericDVM
from nostr_dvm.utils.admin_utils import AdminConfig
from nostr_dvm.utils.dvmconfig import build_default_config
@@ -25,6 +26,7 @@ SYNC_DB_RELAY_LIST = ["wss://relay.damus.io",
def playground(announce=False):
framework = DVMFramework()
kind = 5050
admin_config = AdminConfig()
admin_config.REBROADCAST_NIP89 = announce
@@ -77,7 +79,8 @@ def playground(announce=False):
return result
dvm.process = process # overwrite the process function with the above one
dvm.run(True)
framework.add(dvm)
framework.run()
if __name__ == '__main__':

View File

@@ -5,6 +5,7 @@ from pathlib import Path
import dotenv
from nostr_sdk import Kind
from nostr_dvm.framework import DVMFramework
from nostr_dvm.tasks.generic_dvm import GenericDVM
from nostr_dvm.utils.admin_utils import AdminConfig
from nostr_dvm.utils.dvmconfig import build_default_config
@@ -26,6 +27,7 @@ SYNC_DB_RELAY_LIST = ["wss://relay.damus.io",
def playground(announce=False):
framework = DVMFramework()
kind = Kind(5100)
model = "dev" #schnell
@@ -103,7 +105,8 @@ def playground(announce=False):
dvm.process = process # overwrite the process function with the above one
dvm.run(True)
framework.add(dvm)
framework.run()
if __name__ == '__main__':

View File

@@ -34,7 +34,7 @@ SYNC_DB_RELAY_LIST = ["wss://relay.damus.io",
#"wss://relay.primal.net",
"wss://nostr.oxtr.dev"]
RELAY_LIST = ["wss://nostr.mom",
RELAY_LIST = ["wss://relay.nostrdvm.com",
#"wss://relay.primal.net",
"wss://nostr.oxtr.dev",
#"wss://relay.nostr.net"