mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-05-04 14:20:15 +02:00
better error handling from venvs
This commit is contained in:
parent
d2fbeb7b23
commit
0c2ee4ee6c
12
.idea/dataSources.xml
generated
12
.idea/dataSources.xml
generated
@ -56,5 +56,17 @@
|
|||||||
</library>
|
</library>
|
||||||
</libraries>
|
</libraries>
|
||||||
</data-source>
|
</data-source>
|
||||||
|
<data-source source="LOCAL" name="Bot" uuid="80b7a7dc-a233-4d7b-bd0e-e1d0bc7226e8">
|
||||||
|
<driver-ref>sqlite.xerial</driver-ref>
|
||||||
|
<synchronize>true</synchronize>
|
||||||
|
<jdbc-driver>org.sqlite.JDBC</jdbc-driver>
|
||||||
|
<jdbc-url>jdbc:sqlite:$PROJECT_DIR$/db/Bot.db</jdbc-url>
|
||||||
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
|
<libraries>
|
||||||
|
<library>
|
||||||
|
<url>file://$APPLICATION_CONFIG_DIR$/jdbc-drivers/Xerial SQLiteJDBC/3.43.0/org/xerial/sqlite-jdbc/3.43.0.0/sqlite-jdbc-3.43.0.0.jar</url>
|
||||||
|
</library>
|
||||||
|
</libraries>
|
||||||
|
</data-source>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
@ -239,7 +239,7 @@ class Bot:
|
|||||||
client=self.client, config=self.dvm_config)
|
client=self.client, config=self.dvm_config)
|
||||||
time.sleep(2.0)
|
time.sleep(2.0)
|
||||||
reply_event = EventBuilder.new_encrypted_direct_msg(self.keys,
|
reply_event = EventBuilder.new_encrypted_direct_msg(self.keys,
|
||||||
PublicKey.from_hex(user.npub),
|
PublicKey.from_hex(entry['npub']),
|
||||||
content,
|
content,
|
||||||
None).to_event(self.keys)
|
None).to_event(self.keys)
|
||||||
print(status + ": " + content)
|
print(status + ": " + content)
|
||||||
|
@ -469,6 +469,7 @@ class DVM:
|
|||||||
task = get_task(job_event, client=self.client, dvm_config=self.dvm_config)
|
task = get_task(job_event, client=self.client, dvm_config=self.dvm_config)
|
||||||
|
|
||||||
for dvm in self.dvm_config.SUPPORTED_DVMS:
|
for dvm in self.dvm_config.SUPPORTED_DVMS:
|
||||||
|
result = ""
|
||||||
try:
|
try:
|
||||||
if task == dvm.TASK:
|
if task == dvm.TASK:
|
||||||
|
|
||||||
@ -488,13 +489,13 @@ class DVM:
|
|||||||
|
|
||||||
with open(os.path.abspath('output.txt')) as f:
|
with open(os.path.abspath('output.txt')) as f:
|
||||||
resultall = f.readlines()
|
resultall = f.readlines()
|
||||||
result = ""
|
|
||||||
for line in resultall:
|
for line in resultall:
|
||||||
if line != '\n':
|
if line != '\n':
|
||||||
result += line
|
result += line
|
||||||
os.remove(os.path.abspath('output.txt'))
|
os.remove(os.path.abspath('output.txt'))
|
||||||
if result.startswith("Error:"):
|
assert not result.startswith("Error:")
|
||||||
raise Exception
|
print(result)
|
||||||
|
|
||||||
else: # Some components might have issues with running code in otuside venv.
|
else: # Some components might have issues with running code in otuside venv.
|
||||||
# We install locally in these cases for now
|
# We install locally in these cases for now
|
||||||
result = dvm.process(request_form)
|
result = dvm.process(request_form)
|
||||||
@ -505,9 +506,8 @@ class DVM:
|
|||||||
send_job_status_reaction(job_event, "error", content=str(e),
|
send_job_status_reaction(job_event, "error", content=str(e),
|
||||||
dvm_config=self.dvm_config)
|
dvm_config=self.dvm_config)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
|
||||||
# we could send the exception here to the user, but maybe that's not a good idea after all.
|
# we could send the exception here to the user, but maybe that's not a good idea after all.
|
||||||
send_job_status_reaction(job_event, "error", content="An error occurred",
|
send_job_status_reaction(job_event, "error", content=result,
|
||||||
dvm_config=self.dvm_config)
|
dvm_config=self.dvm_config)
|
||||||
# Zapping back the user on error
|
# Zapping back the user on error
|
||||||
if amount > 0 and self.dvm_config.LNBITS_ADMIN_KEY != "":
|
if amount > 0 and self.dvm_config.LNBITS_ADMIN_KEY != "":
|
||||||
|
@ -146,5 +146,4 @@ def process_venv(identifier):
|
|||||||
DVMTaskInterface.write_output(result, args.output)
|
DVMTaskInterface.write_output(result, args.output)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
DVMTaskInterface.write_output("Error: " + str(e), args.output)
|
DVMTaskInterface.write_output("Error: " + str(e), args.output)
|
||||||
raise Exception
|
|
||||||
|
|
||||||
|
@ -116,9 +116,9 @@ class ImageGenerationDALLE(DVMTaskInterface):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Error in Module")
|
if str(e).startswith("Error code: 400"):
|
||||||
raise Exception(e)
|
raise Exception('Your request was rejected as a result of OpenAI´s safety system. Your prompt may '
|
||||||
|
'contain text that is not allowed by their safety system.')
|
||||||
|
|
||||||
# We build an example here that we can call by either calling this file directly from the main directory,
|
# We build an example here that we can call by either calling this file directly from the main directory,
|
||||||
# or by adding it to our playground. You can call the example and adjust it to your needs or redefine it in the
|
# or by adding it to our playground. You can call the example and adjust it to your needs or redefine it in the
|
||||||
|
2
setup.py
2
setup.py
@ -1,6 +1,6 @@
|
|||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
VERSION = '0.1.4'
|
VERSION = '0.1.5'
|
||||||
DESCRIPTION = 'A framework to build and run Nostr NIP90 Data Vending Machines'
|
DESCRIPTION = 'A framework to build and run Nostr NIP90 Data Vending Machines'
|
||||||
LONG_DESCRIPTION = ('A framework to build and run Nostr NIP90 Data Vending Machines. '
|
LONG_DESCRIPTION = ('A framework to build and run Nostr NIP90 Data Vending Machines. '
|
||||||
'This is an early stage release. Interfaces might change/brick')
|
'This is an early stage release. Interfaces might change/brick')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user