Skip to content

Commit

Permalink
Merge pull request #20 from leon-thomm/ryven-console
Browse files Browse the repository at this point in the history
A prototype for a GUIless Ryven version (currently called Ryven Console) is now included. Ryven Console is used to run Ryven flows without Qt (f.ex. on the server) much faster than in Ryven itself. Very useful for time-intensive processing. Testing and showcasing can be done in Ryven while the actual computation can be done without visual interface in the cloud.
There are rules for using Ryven Console, one **cannot** just run a Ryven flow in the console application. But it is possible and not difficult to create nodes that work with Ryven Console. I will add an explanation to the docs once it is part of an official release.
  • Loading branch information
leon-thomm authored Aug 31, 2020
2 parents 435b6d4 + 8a9674f commit 53bf7e5
Show file tree
Hide file tree
Showing 50 changed files with 1,365 additions and 124 deletions.
2 changes: 1 addition & 1 deletion Ryven/custom_src/MainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def parse_nodes(self, j_str, package_path, package_name):
j_obj = json.loads(j_str, strict=False)

Debugger.debug(j_obj['type'])
if j_obj['type'] != 'vyScriptFP nodes package':
if j_obj['type'] != 'Ryven nodes package' and j_obj['type'] != 'vyScriptFP nodes package': # old syntax
return

# package_title = j_obj['title']
Expand Down
13 changes: 9 additions & 4 deletions Ryven/custom_src/NodeInstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ def initialized(self):
if self.main_widget:
try:
self.main_widget.set_data(self.init_config['main widget data'])
except KeyError:
pass
except Exception as e:
print('Exception while setting data in', self.parent_node.title, 'NodeInstance\'s main widget:', e,
' (was this intended?)')

self.special_actions = self.set_special_actions_data(self.init_config['special actions'])
self.temp_state_data = self.init_config['state data']
Expand All @@ -104,7 +105,11 @@ def initialized(self):

# LOADING DATA
if self.temp_state_data is not None:
self.set_data(self.temp_state_data)
try:
self.set_data(self.temp_state_data)
except Exception as e:
print('Exception while setting data in', self.parent_node.title, 'NodeInstance:', e,
' (was this intended?)')


self.initializing = False
Expand Down Expand Up @@ -243,7 +248,7 @@ def set_output_val(self, index, val):
self.outputs[index].set_val(val)

def data_outputs_updated(self):
"""Sends update signals to all data outputs causing connected NIs to update."""
"""(outdated!) Sends update signals to all data outputs causing connected NIs to update."""

Debugger.debug('updating data outputs in', self.parent_node.title)
for o in self.outputs:
Expand Down
11 changes: 6 additions & 5 deletions Ryven/custom_src/PortInstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@


class PortInstance(QGraphicsGridLayout):
"""The PortInstance class represents input-as well as output-instances of a NI. It wasn't really necessary yet, but
I will probably subclass it later into InputPortInstance and OutputPortInstance - so far both are just
PortInstances."""

def __init__(self, parent_node_instance, direction, type_='', label_str='',
widget_name=None, widget_pos=''):
Expand Down Expand Up @@ -58,7 +55,7 @@ def update(self):


def set_val(self, val):
"""applies on INPUT; called NI internally"""
"""applies on OUTPUT; called NI internally"""
Debugger.debug('setting value of', self.direction, 'port of', self.parent_node_instance.parent_node.title,
'NodeInstance to', val)

Expand Down Expand Up @@ -129,7 +126,11 @@ def __init__(self, parent_node_instance, type_='', label_str='',

if config_data is not None:
self.create_widget()
self.widget.set_data(config_data)
try:
self.widget.set_data(config_data)
except Exception as e:
print('Exception while setting data in', self.parent_node_instance.parent_node.title,
'NodeInstance\'s input widget:', e, ' (was this intended?)')
else:
self.create_widget()

Expand Down
98 changes: 73 additions & 25 deletions Ryven/custom_src/tests.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,85 @@
import sys
import types
import inspect
from optparse import OptionParser
import random
import math
import pickle
import os
from pyowm import OWM
import librosa
# import sys
# import types
# import inspect
# from optparse import OptionParser
# import random
# import math
# import pickle
# import os
# from pyowm import OWM
# import librosa

from PySide2.QtWidgets import QMainWindow, QApplication, QWidget, QVBoxLayout, QPlainTextEdit, QGraphicsView, QGraphicsScene, QGraphicsProxyWidget, QAction, QMenu
from PySide2.QtGui import QFont, QColor, QImage, QPainter, QPen, QBrush
from PySide2.QtCore import Qt, QRectF

# Beat tracking example
import librosa
# import librosa


if __name__ == '__main__':
print('asdf')
# 1. Get the file path to an included audio example
filename = librosa.example('nutcracker')
print('asdf')
class PlaceholderAttributeException(Exception):
pass


class Nope:
pass


def placeholder_method(*args):
pass

class PlaceholderWidget:
# def __getattr__(self, item):
# print('getting attribute', item)
# if not hasattr(self, item):
# raise PlaceholderAttributeException('nope')
# else:
# return super(PlaceholderWidget, self).__getattr__(item)

# 2. Load the audio as a waveform `y`
# Store the sampling rate as `sr`
y, sr = librosa.load(filename)
print('asdf')
def y(self):
return 'y!'

# 3. Run the default beat tracker
tempo, beat_frames = librosa.beat.beat_track(y=y, sr=sr)
def __getattr__(self, item):
print('getting attribute:', item)

def method(*args):
print('unknown method used:', item)

return method

def __setattr__(self, key, value):
print('setting attr', key, 'to', value)
print(hasattr(self, key))
if not hasattr(self, key):
return
super(PlaceholderWidget, self).__setattr__(key, value)


if __name__ == '__main__':
pw = PlaceholderWidget()
print('1')
pw.x = 10
print(pw.x)
print('2')
print(pw.y())
pw.foo(15)
print('3')

print('Estimated tempo: {:.2f} beats per minute'.format(tempo))

# 4. Convert the frame indices of beat events into timestamps
beat_times = librosa.frames_to_time(beat_frames, sr=sr)
# print('asdf')
# # 1. Get the file path to an included audio example
# filename = librosa.example('nutcracker')
# print('asdf')
#
# # 2. Load the audio as a waveform `y`
# # Store the sampling rate as `sr`
# y, sr = librosa.load(filename)
# print('asdf')
#
# # 3. Run the default beat tracker
# tempo, beat_frames = librosa.beat.beat_track(y=y, sr=sr)
#
# print('Estimated tempo: {:.2f} beats per minute'.format(tempo))
#
# # 4. Convert the frame indices of beat events into timestamps
# beat_times = librosa.frames_to_time(beat_frames, sr=sr)
6 changes: 6 additions & 0 deletions Ryven_Console/NIENV.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""This file automatically imports all requirements for custom NodeInstances, so that they only need to import this
file. This file should lie in the same location as Ryven.py in order to be able to get imported directly."""

from custom_src.NodeInstance import NodeInstance
from custom_src.Node import Node
from custom_src.retain import M
Loading

0 comments on commit 53bf7e5

Please sign in to comment.