mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-11-18 12:27:16 +01:00
added dependencies (and dependencies per task)
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
from threading import Thread
|
||||
|
||||
from nostr_sdk import Keys
|
||||
|
||||
from nostr_dvm.dvm import DVM
|
||||
from nostr_dvm.utils.admin_utils import AdminConfig
|
||||
from nostr_dvm.utils.dvmconfig import DVMConfig
|
||||
from nostr_dvm.utils.nip89_utils import NIP89Config
|
||||
from nostr_dvm.dvm import DVM
|
||||
from nostr_dvm.utils.output_utils import post_process_result
|
||||
|
||||
|
||||
@@ -23,11 +25,13 @@ class DVMTaskInterface:
|
||||
ACCEPTS_CASHU = True # DVMs build with this framework support encryption, but others might not.
|
||||
dvm_config: DVMConfig
|
||||
admin_config: AdminConfig
|
||||
dependencies = []
|
||||
|
||||
def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config, admin_config: AdminConfig = None,
|
||||
options=None, task=None):
|
||||
self.init(name, dvm_config, admin_config, nip89config, task)
|
||||
self.options = options
|
||||
self.install_dependencies(self.dependencies)
|
||||
|
||||
def init(self, name, dvm_config, admin_config=None, nip89config=None, task=None):
|
||||
self.NAME = name
|
||||
@@ -80,6 +84,13 @@ class DVMTaskInterface:
|
||||
"""Post-process the data and return the result Use default function, if not overwritten"""
|
||||
return post_process_result(result, event)
|
||||
|
||||
def install_dependencies(self, packages):
|
||||
import pip
|
||||
for package in packages:
|
||||
try:
|
||||
__import__(package.split("=")[0])
|
||||
except ImportError:
|
||||
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
|
||||
|
||||
@staticmethod
|
||||
def set_options(request_form):
|
||||
|
||||
Reference in New Issue
Block a user