Skip to content

Commit

Permalink
change subnet, add yagna install check
Browse files Browse the repository at this point in the history
  • Loading branch information
norbibi committed Jul 29, 2023
1 parent 0059b70 commit fd565cf
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 20 deletions.
35 changes: 22 additions & 13 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ def create_output_directory(main_output_directory):

@persistent
def init(scene):
bpy.context.scene.golem_settings.start_frame = bpy.context.scene.frame_start
bpy.context.scene.golem_settings.end_frame = bpy.context.scene.frame_end
bpy.context.scene.golem_settings.step_frame = bpy.context.scene.render.fps
bpy.context.scene.golem_settings.start_frame = bpy.context.scene.frame_start
bpy.context.scene.golem_settings.end_frame = bpy.context.scene.frame_end
bpy.context.scene.golem_settings.step_frame = bpy.context.scene.render.fps

class Golem_Render(bpy.types.Operator):
bl_idname = "golem_render.render"
Expand Down Expand Up @@ -156,6 +156,15 @@ def update_progress():
progress_btn = False
providers_btn = False
cancel_btn = False
elif msg == "yagna_not_installed":
ShowMessageBox("Please install yagna and add to PATH", "Yagna error", 'ERROR')
running = False
render_process.terminate()
bpy.app.timers.unregister(update_progress)
render_btn = True
progress_btn = False
providers_btn = False
cancel_btn = False
elif msg == "insufficient_funds":
ShowMessageBox("Please get funds with command: yagna payment fund", "Insufficient funds", 'ERROR')
running = False
Expand Down Expand Up @@ -196,23 +205,23 @@ def execute(self, context):
##########################################################################################################

def set_start_frame(self, value):
if value <= self["end_frame"]:
if value >= bpy.context.scene.frame_start:
self["start_frame"] = value
else:
self["start_frame"] = bpy.context.scene.frame_start
if value <= self["end_frame"]:
if value >= bpy.context.scene.frame_start:
self["start_frame"] = value
else:
self["start_frame"] = bpy.context.scene.frame_start

def get_start_frame(self):
if "start_frame" not in self.keys():
self["start_frame"] = bpy.context.scene.frame_start
return self["start_frame"]

def set_end_frame(self, value):
if value >= self["start_frame"]:
if value <= bpy.context.scene.frame_end:
self["end_frame"] = value
else:
self["end_frame"] = bpy.context.scene.frame_end
if value >= self["start_frame"]:
if value <= bpy.context.scene.frame_end:
self["end_frame"] = value
else:
self["end_frame"] = bpy.context.scene.frame_end

def get_end_frame(self):
if "end_frame" not in self.keys():
Expand Down
18 changes: 11 additions & 7 deletions addon_golem.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@
from multiprocessing import Process, Value, Queue
from decimal import Decimal

def init_payment(network):
def init_payment(queue, network):
cmd = ["yagna", "payment", "init", "--sender", "--network=" + network, "--driver=erc20"]
with subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) as proc:
for line in proc.stderr:
if "Error: Called service `/local/identity/Get` is unavailable" in line:
queue.put('yagna_not_started')
try:
with subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) as proc:
for line in proc.stderr:
if "Error: Called service `/local/identity/Get` is unavailable" in line:
queue.put('yagna_not_started')
except:
queue.put('yagna_not_installed')
return

def get_appkey():
cmd = ["yagna", "app-key", "list", "--json"]
Expand Down Expand Up @@ -164,7 +168,7 @@ def render(main_blend_file, project_directory, output_directory, frames, queue,
importlib.reload(site)
from yapapi.log import enable_default_logger

init_payment(network)
init_payment(queue, network)
app_key = get_appkey()
os.environ['YAGNA_APPKEY'] = app_key

Expand All @@ -181,7 +185,7 @@ def render(main_blend_file, project_directory, output_directory, frames, queue,
queue = queue,
payment_driver = "erc20",
payment_network = network,
subnet_tag = "public",
subnet_tag = "norbert",
budget = budget,
interval_payment = 0,
start_price = start_price,
Expand Down

0 comments on commit fd565cf

Please sign in to comment.