mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-09-18 07:50:57 +02:00
handle exception, adapt more tests to framework
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -198,3 +198,4 @@ tests/cat4.png
|
|||||||
*.png
|
*.png
|
||||||
tests/gifs/data.mdb
|
tests/gifs/data.mdb
|
||||||
tests/gifs/lock.mdb
|
tests/gifs/lock.mdb
|
||||||
|
tests/gif_library.py
|
||||||
|
@@ -237,7 +237,10 @@ async def send_event_outbox(event: Event, client, dvm_config) -> SendEventOutput
|
|||||||
if len(relays) == 0:
|
if len(relays) == 0:
|
||||||
return None
|
return None
|
||||||
for relay in relays:
|
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:
|
try:
|
||||||
await outboxclient.connect()
|
await outboxclient.connect()
|
||||||
event_response = await outboxclient.send_event(event)
|
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:
|
for relay in relays:
|
||||||
if relay not in dvm_config.RELAY_LIST:
|
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()
|
await client.connect()
|
||||||
|
|
||||||
|
@@ -4,6 +4,7 @@ from pathlib import Path
|
|||||||
import dotenv
|
import dotenv
|
||||||
from nostr_sdk import init_logger, LogLevel
|
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.tasks.content_discovery_currently_popular_mostr import DicoverContentCurrentlyPopularMostr
|
||||||
from nostr_dvm.utils.admin_utils import AdminConfig
|
from nostr_dvm.utils.admin_utils import AdminConfig
|
||||||
from nostr_dvm.utils.dvmconfig import build_default_config
|
from nostr_dvm.utils.dvmconfig import build_default_config
|
||||||
@@ -23,7 +24,7 @@ if use_logger:
|
|||||||
init_logger(LogLevel.ERROR)
|
init_logger(LogLevel.ERROR)
|
||||||
|
|
||||||
|
|
||||||
RELAY_LIST = ["wss://nostr.mom",
|
RELAY_LIST = ["wss://relay.nostrdvm.com",
|
||||||
#"wss://relay.primal.net",
|
#"wss://relay.primal.net",
|
||||||
"wss://nostr.oxtr.dev",
|
"wss://nostr.oxtr.dev",
|
||||||
#"wss://relay.nostr.net"
|
#"wss://relay.nostr.net"
|
||||||
@@ -72,6 +73,8 @@ def build_example_mostr(name, identifier, admin_config, options, image, cost=0,
|
|||||||
|
|
||||||
|
|
||||||
def playground():
|
def playground():
|
||||||
|
|
||||||
|
framework = DVMFramework()
|
||||||
# Popular Global
|
# Popular Global
|
||||||
admin_config_global_wot = AdminConfig()
|
admin_config_global_wot = AdminConfig()
|
||||||
admin_config_global_wot.REBROADCAST_NIP89 = rebroadcast_NIP89
|
admin_config_global_wot.REBROADCAST_NIP89 = rebroadcast_NIP89
|
||||||
@@ -101,7 +104,8 @@ def playground():
|
|||||||
update_rate=global_update_rate,
|
update_rate=global_update_rate,
|
||||||
processing_msg=custom_processing_msg,
|
processing_msg=custom_processing_msg,
|
||||||
update_db=update_db)
|
update_db=update_db)
|
||||||
discovery_mostr.run(True)
|
framework.add(discovery_mostr)
|
||||||
|
framework.run()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -5,6 +5,7 @@ import dotenv
|
|||||||
from duck_chat import ModelType
|
from duck_chat import ModelType
|
||||||
from nostr_sdk import Kind
|
from nostr_sdk import Kind
|
||||||
|
|
||||||
|
from nostr_dvm.framework import DVMFramework
|
||||||
from nostr_dvm.tasks.generic_dvm import GenericDVM
|
from nostr_dvm.tasks.generic_dvm import GenericDVM
|
||||||
from nostr_dvm.utils.admin_utils import AdminConfig
|
from nostr_dvm.utils.admin_utils import AdminConfig
|
||||||
from nostr_dvm.utils.dvmconfig import build_default_config
|
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):
|
def playground(announce=False):
|
||||||
|
|
||||||
|
framework = DVMFramework()
|
||||||
kind = 5050
|
kind = 5050
|
||||||
admin_config = AdminConfig()
|
admin_config = AdminConfig()
|
||||||
admin_config.REBROADCAST_NIP89 = announce
|
admin_config.REBROADCAST_NIP89 = announce
|
||||||
@@ -77,7 +79,8 @@ def playground(announce=False):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
dvm.process = process # overwrite the process function with the above one
|
dvm.process = process # overwrite the process function with the above one
|
||||||
dvm.run(True)
|
framework.add(dvm)
|
||||||
|
framework.run()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@@ -5,6 +5,7 @@ from pathlib import Path
|
|||||||
import dotenv
|
import dotenv
|
||||||
from nostr_sdk import Kind
|
from nostr_sdk import Kind
|
||||||
|
|
||||||
|
from nostr_dvm.framework import DVMFramework
|
||||||
from nostr_dvm.tasks.generic_dvm import GenericDVM
|
from nostr_dvm.tasks.generic_dvm import GenericDVM
|
||||||
from nostr_dvm.utils.admin_utils import AdminConfig
|
from nostr_dvm.utils.admin_utils import AdminConfig
|
||||||
from nostr_dvm.utils.dvmconfig import build_default_config
|
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):
|
def playground(announce=False):
|
||||||
|
|
||||||
|
framework = DVMFramework()
|
||||||
kind = Kind(5100)
|
kind = Kind(5100)
|
||||||
model = "dev" #schnell
|
model = "dev" #schnell
|
||||||
|
|
||||||
@@ -103,7 +105,8 @@ def playground(announce=False):
|
|||||||
|
|
||||||
|
|
||||||
dvm.process = process # overwrite the process function with the above one
|
dvm.process = process # overwrite the process function with the above one
|
||||||
dvm.run(True)
|
framework.add(dvm)
|
||||||
|
framework.run()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@@ -34,7 +34,7 @@ SYNC_DB_RELAY_LIST = ["wss://relay.damus.io",
|
|||||||
#"wss://relay.primal.net",
|
#"wss://relay.primal.net",
|
||||||
"wss://nostr.oxtr.dev"]
|
"wss://nostr.oxtr.dev"]
|
||||||
|
|
||||||
RELAY_LIST = ["wss://nostr.mom",
|
RELAY_LIST = ["wss://relay.nostrdvm.com",
|
||||||
#"wss://relay.primal.net",
|
#"wss://relay.primal.net",
|
||||||
"wss://nostr.oxtr.dev",
|
"wss://nostr.oxtr.dev",
|
||||||
#"wss://relay.nostr.net"
|
#"wss://relay.nostr.net"
|
||||||
|
Reference in New Issue
Block a user