Changeset - d050b8efda9d
[Not reviewed]
default
0 1 0
drewp@bigasterisk.com - 20 months ago 2023-06-02 01:42:36
drewp@bigasterisk.com
fix bug with uninitialized effect ,and prefer a dead effect over a graph reload
1 file changed with 3 insertions and 2 deletions:
0 comments (0 inline, 0 general)
light9/effect/effecteval2.py
Show inline comments
 
import traceback
 
import inspect
 
import logging
 
from dataclasses import dataclass
 
from typing import Callable, List, Optional
 

	
 
from rdfdb.syncedgraph.syncedgraph import SyncedGraph
 
@@ -35,13 +36,13 @@ class EffectEval2:
 
    config: Optional[Config] = None
 

	
 
    def __post_init__(self):
 
        self.graph.addHandler(self._compile)
 

	
 
    def _compile(self):
 
        self.effectFunction = None
 
        self.config = None
 
        if not self.graph.contains((self.uri, RDF.type, L9['Effect'])):
 
            return
 

	
 
        try:
 
            effectFunction = typedValue(EffectFunction, self.graph, self.uri, L9['effectFunction'])
 
            effSets = []
 
@@ -72,13 +73,13 @@ class EffectEval2:
 
            # This should be in EffectFunctionLibrary
 
            funcArgs = list(inspect.signature(func).parameters.values())
 

	
 
            self.config = Config(effectFunction, esettings, devSettings, func, funcArgs)
 
        except Exception:
 
            log.error(f"while compiling {self.uri}")
 
            raise
 
            traceback.print_exc()
 

	
 
    def compute(self, songTime: float, inputs: EffectSettings) -> DeviceSettings:
 
        """
 
        calls our function using inputs (publishedAttr attrs, e.g. :strength)
 
        and effect-level settings including a special attr called :deviceSettings
 
        with DeviceSettings as its value
0 comments (0 inline, 0 general)