Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider allowing outside module names for light definitions #50

Open
crscheid opened this issue Jul 26, 2023 · 1 comment
Open

Consider allowing outside module names for light definitions #50

crscheid opened this issue Jul 26, 2023 · 1 comment

Comments

@crscheid
Copy link
Contributor

At present, its difficult to add light definitions without contributing directly to the project since the validate_item function assumes the PyDMXControl.profiles. module name being present. Perhaps the code could be modified si that if the module is not found you search the broader namespace for the module before failing.

I plan to hopefully contribute to this projects codebase on a few fronts after I get done with my own testing. 😄

In the meantime, I found a work around. If one defines a light in a file called MyLight with a class of MyAwesomeLight, they can add this to their executing class:

test.py

import sys
from PyDMXControl.controllers import OpenDMXController

import MyLight
sys.modules['PyDMXControl.profiles.MyLight'] = MyLight

dmx.json.load_config('light_config.json')

light_config.json

[
    {
        "type": "MyLight.MyAwesomeLight",
        "args": [],
        "name": "Light 1",
        "start_channel": 1
    },
    {
        "type": "MyLight.MyAwesomeLight",
        "args": [],
        "name": "Light 2",
        "start_channel": 8
    }
]
@MattIPv4
Copy link
Owner

Ah yes, that is a very good point, I hadn't really put in any consideration at all for custom fixtures when I wrote the JSON logic. Open to either scanning the wider namespace if the profile isn't found within the library, or open to allowing a way for profiles to be passed in as a second argument with the JSON load, so that we look at in-library plus the ones passed in, rather than scanning the whole wider namespace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants