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

[Plugin] Move plugin definition to external Json file #574

Closed
Edouard2laire opened this issue Sep 8, 2022 · 5 comments
Closed

[Plugin] Move plugin definition to external Json file #574

Edouard2laire opened this issue Sep 8, 2022 · 5 comments

Comments

@Edouard2laire
Copy link
Contributor

Edouard2laire commented Sep 8, 2022

Hello,

Recently, I was thinking about the possibility for the users to have additional plugin that are not officially integrated to brainstorm (typically code that are in .brainstorm/process). For example, I have a lot of code related to nirs project that I sometime needs to share with colleague and currently it makes it hard to track version of the scripts. With a plugin system, I could make sure all the script are always up-to-date between me and my colleagues and between my different computers :)

For the main plugin, this would allow some user to change the version of the external-software they want to use more easily.

To do that I was thinking to move the definition of the plugin to two files: but_plugin.json in the main brainstorm folder. and allows users to create a user_plugin.json in .brainstorm folder to specify user-specific

https://github.com/brainstorm-tools/brainstorm3/blob/master/toolbox/core/bst_plugin.m#L128-L599 would then be only reading of the json files.

Here is a proof of concept of how the file would looks like

PlugDesc            = struct();
PlugDesc.Name           = 'bci2000';
PlugDesc.Version        = 'latest';
PlugDesc.Category       = 'I/O';
PlugDesc.URLzip         = 'https://bci2000.org/downloads/mex.zip';
PlugDesc.URLinfo        = 'https://www.bci2000.org/mediawiki/index.php/User_Reference:Matlab_MEX_Files';
PlugDesc.TestFile       = 'load_bcidat.m';
PlugDesc.CompiledStatus = 0;

txt = jsonencode(PlugDesc,PrettyPrint=true)


value = jsondecode(txt);
PlugDescDecode = struct_copy_fields(bst_plugin('GetStruct','bci2000'), value, 1); % same as existing struct

Let me know if you think that is a good idea. I can start working on a PR then.

Edouard

@ftadel
Copy link
Member

ftadel commented Sep 9, 2022

Yes, this sounds like a very interesting idea!
You can go ahead with your experiments, I'll help you wrap them up :)

@Edouard2laire
Copy link
Contributor Author

ok. I will work on it this weekend :)

@ftadel
Copy link
Member

ftadel commented Sep 10, 2022

I'm looking a bit deeper into this idea and I'm not sure that the basic Brainstorm plugins currently defined in bst_plugins.m should be moved to a json file:

  1. Some of the elements in the structure depend on the OS, therefore it can't be one single .json file
  2. It's going to slow down a bit the startup
  3. It has no benefit for flexibility, as users would not modify it.
    => I don't think the bst_plugin.json is a good idea.

For user plugins, it makes much more sense. And it could even be more modular than a single user_plugin.json file.
One json file = one plugin would be more modular.

I was thinking about maybe parsing all the .json files in the .brainstorm/plugin folder, for user plugins definition.
Or maybe there is no need to actually parse the .json files there, and you could add a menu "Import plugin" in the plugin menu. This would ask for loading a .json file from the hard drive or from a URL, and then install it.
Once installed, it can be updated without the json I guess?

I realize what I wrote is a bit messy, I haven't thought much about it, but wanted to share quickly these ideas before you spend too much time with the implementation.

@rcassani
Copy link
Member

Few months ago, we revamped the bst-users repo, it may be helpful for these user plugins.

  • The user plugins and their definition (json or plugin struct) can be added there as submodules.
  • Then, the user can install them through the GUI

Does it make some sense?

@ftadel
Copy link
Member

ftadel commented Sep 12, 2022

Few months ago, we revamped the bst-users repo, it may be helpful for these user plugins.

@Edouard2laire Maybe you could push there one of your (future) user plugins, as an example?

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

No branches or pull requests

3 participants