-
Notifications
You must be signed in to change notification settings - Fork 17
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
Driver export format and location definitions #92
Comments
Some background and thoughts: Driver export format: Driver export location:
So then Some history bits: |
Basically, all drivers are loaded "by convention". There is the possibility to prevent drivers from being loaded using the env variable: NEEO_DEVICES_EXCLUDED_DIRECTORIES=["file1", "file2"]. It's also possible to configure the devices folder using NEEO_DEVICES_DIRECTORY="directory". But I agree with @pfiaux, we should move towards a more defined way of loading devices, but also keep the configuration centralised in the package.json to make it less confusing. |
Not only by convention but also implicitly, (a driver called my-awesome-driver would not match the neeo- filter and be excluded even if it was a valid driver). we could move to explicit naming using the package.json (similar to say cordova plugins):
But this adds some duplicate data since they will also be listed in dependencies. Also regarding the Driver export location, i'm still wondering how or if we need to handle the local use case. Here's some options I thought of:
It's mainly relevant to the CLI and not necessarily to the driver export standard. Perhaps this is a discussion more specific to the CLI and it's use of neeoSdkOptions, other tools don't necessarily need to use this and should be able to do it differently. I've updated the description driver export format at the top of the issue. |
I'll need to read it a couple of times and test some stuff to give a definitive feedback. I can however already comment on the struggles i had in adopting the CLI until now, Although i can code I'm not a developer that needs half the word to understand the bigger picture, the lack of experience will be the same or more so with users that like to fiddle around but have no clue about node, NPS etc.. For then a linear always the same approach is recommended. My struggles can help in finding an easy way for the user. Now concrete, here are my struggles.
To a user, the most simple solution is:
The SDK would scan reclusively either package.json or more future proof neeodriver.json Sorry for not yet answering the question directly. |
Thanks for the feedback @nklerk, good points!
Since we didn't do the split yet I'll just call it neeo-cli and outline how it might work for the advanced user who only wants to run drivers:
Then the CLI will also have some tools for developers like
|
This would be the perfect solution! |
I didn't plan on getting involved in the discussions that are taking place here, but seeing the way drivers are currently "forced" to be structured in a certain way (although there are workarounds) I wanted to hop in and give a nudge towards configuration as @bdauria already mentioned earlier. I think there are two to go forward if we want to expose drivers through config:
Sadly we don't have default/unnamed exports yet, so for now we're forced to name our export. I'm not quite opposed to
I'm completely in favour of @pfiaux suggestion of how the CLI would be used to add new drivers, as I'm not quite fond of having to clone drivers into a certain directory. I would like to suggest that individual drivers are spawned in separate processes to avoid a bad driver from bringing everything down. Im that case I think it would be wise to look at existing process managers to avoid reinventing the wheel. |
I would like to join this discussion, beside i currently have no time for playing with the new SDK. I definitly like the Point, that @nklerk mentioned. From side of a User it must be as simple as possible to load a driver to NEEO. Currently it is hard enough to do so because needed to Setup an external Device to run the Code. But due to this will not be changed within the next Releases, i like the Following way: I know, that Github is not very good when merging Code to one repository, but i also don't like the way to search for each driver and implement it every time. There should not be to much related to the enduser, thereofr a simple as possible concept should be approched. Later on when a HTTP control of the Brain is officialli supported, this can also lead to loading a Zip file into the Brain which is then extracted and stored under a single folder. |
Apologies @pfiaux @bdauria @nklerk I have been AFK for this week - life and stuff 😄 I think the convention of a package exporting a single driver makes the most sense to me as multi-export comes with big challenges in terms of process management and also installation/maintenance. I'm not sure I'm fully understanding the discussion around location though? To me, this shouldn't be a problem. If you However, if we're talking about a use case where you have local and npm packages in the same project, then to me that doesn't make sense. As a developer, if I'm creating a new driver - that driver should be self-contained and not need to depend on another driver. If we want to "combine" drivers to run from a single server - we're moving out of the responsibilities of the SDK to build a driver and into the next "architectural" level - e.g. Driver Manager/CLI Server Start. I hope that makes sense. In short what I am saying is - I can't see a valid reason for a driver package to need a dependency on another driver package. If we treat that as the norm and best practise then the location discussion is redundant as it just leverages standard |
Let's split off the single vs multiple driver discussion to a separate issue #100 because there's other concerns with that change architecture wise. For now we'll keep the devices array which we recommend to only be used with 1 device (plus arrays make for easier functional programming). After looking over the pros and cons for local vs npm packages here I think we're going to go with the npm setup and stop supporting local drivers directly. We lose the convention of drivers in SummaryLet's say we're in
This treats local and npm packages the same way so only 1 setup to support for driver managers and developers and avoids any drivers accidentally depending on another. Also it leaves it up to the driver managers (CLI, driver manager, ...) which drivers to load. In some cases automatically loading all compatible drivers makes sense, in others we might want an explicit whitelist or blacklist but that should be up to the manager code to handle as it wants. It will also be easier for the advanced user running SDK devices:
No manual managing of folders, downloading/extracting and installing dependencies. As @Shepless mentioned the best practice would be to leverage npm. It leaves 1 lose end, as a developer writing a driver how do easily I run the driver I'm currently working on for development. I don't think it needs a special kind of standard defined here, there's currently multiple options and we can add more via the CLI to handle this case. |
@pfiaux I'm fully with you on this. one way of installing and running drivers is the way to go. For development i would like to keep the option to use MS visual code in debugging mode. I'm not sure how that is called but the feature where the dev can halt code and look inside variables etc. but I guess this is what you meant. |
We've published updated examples including a a skeleton/minimal driver in the next branch: We'll update the readme in the SDK as part of #82 and we have a work in progress CLI which will be in a separate repository with the install documentation. |
As highlighted in #82 and #74 as of the last release we've added new ways to export devices, and to transition we still have some of the old ones.
Goal: a clear definition driver export format and location that covers development and production needs (writing/debugging drivers and running driver via cli, driver manager and ...) for future SDK versions.
Driver export standard
Driver export format
The format from 0.50.x should be flexible enough:
Recommendation: 1 device per export/module, unless the devices are variations or similar (v1 & v2 or lite & premium).
Driver export location
This makes the devices easily accessible via
require('neeo-driver-example').devices
and more flexible as that location could also be"index.js"
or"dist/index.min.js"
and so on.0.50.x export:
Driver export format
Currently as of 0.50.5 with the neeo-sdk cli the expected format of a device driver is:
Regardless of if that driver has one or more devices in it. The CLI then combines all the drivers it finds and loads them in a server.
Driver export location
As of 0.50.5 will be loaded from different locations based on use case. If we consider the neeo-sdk cli as the emerging standard, it will look for devices in the driver export format at these locations:
devices/${driverName}/index.js
devices/index.js
node_modues/${moduleName}/devices/index.js
0.50.5 export location example:
Let's say we're in a work space using:
The local setup looks like this:
This will load all drivers from 3 different paths in different ways and only partially leveraging the NPM package loading sytem.
0.49.x and before export:
Drivers didn't export themselves but started their servers.
Driver export format
None.
Driver export location
None.
The text was updated successfully, but these errors were encountered: