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

Custom user plugin [fix #574] #683

Merged
merged 29 commits into from
May 27, 2024

Conversation

Edouard2laire
Copy link
Contributor

@Edouard2laire Edouard2laire commented Feb 14, 2024

Hello,

As discussed here: #574 , this allows the usage of custom plugins that are not officially supported in Brainstorm. This can be used to share processes within a lab by having a common GitHub repository and having that repo as a custom plugin in Brainstorm.

This is done by defining the customs plugin in specific JSON files under the .brainstorm folder. Each json can contain one or multiple plugins (although one plugin per json might be better as recommended by Francois)

Here is an example of plugins.json file with 2 plugin definition:
plugins.json

Splitted into two files:

plugin_bids_matlab.json
plugin_bst_users.json

The creation of the JSON file can be a bit tedious and prone to error but this is just the first PR to get feedback and we might improve the addition of a plugin in that json file later :) As you suggested, made json file could easily be shared in the bst_plugin repo.

Edouard

[Hs: i cant believe i posted that issue in 2022]

TODOs

  • Update plugin menu without restarting Brainstorm
  • Add user-defined plugins with URL
  • Add user-defined plugins with file
  • Add user-defined plugins manually (user input)
  • Remove user-defined plugins
  • Tests with archiving
  • Tests with deploy
  • Documentation

@Edouard2laire Edouard2laire changed the title Custom user plugin Custom user plugin [fix #574] Feb 15, 2024
@rcassani
Copy link
Member

Can we save the user from creating the json file?

If the scripts to be shared are a public repo, and they are thought to be used as Brainstorm processes. This can work as:

  1. An option in the GUI. Plugin > Add from URL
  2. User provides the URL to the repo (may branch as well)
  3. The repo is downloaded
  4. Brainstorm checks for the json file in it
  5. If the json file exists the plugin gets added following those instructions

@Edouard2laire
Copy link
Contributor Author

Edouard2laire commented Feb 15, 2024

Can we save the user from creating the json file?

yes, I just wanted to make sure you were still ok with the idea since it is from 2022 before working on the user-friendly part :)

If the scripts to be shared are a public repo, and they are thought to be used as Brainstorm processes. This can work as:

  1. An option in the GUI. Plugin > Add from URL
  2. User provides the URL to the repo (may branch as well)
  3. The repo is downloaded
  4. Brainstorm checks for the json file in it
  5. If the json file exists the plugin gets added following those instructions

Seems like a good plan, and if the json file doesn't exist then we ask the user to fill it being extra cautious. I would also add the option to Add directly from json in addition to the URL from step 1. I will add that to the current PR and ping you when ready. (hopefully before 2026 :D)

Edit: the only thing I don't necessarily like with the add from URL is that we might end up downloading each plugin twice : one to get the .json and then to actually download the plugin.

@rcassani
Copy link
Member

We can retrieve only the .json file, something like this:

text = bst_webread('https://raw.githubusercontent.com/brainstorm-tools/brainstorm3/master/README.md');

@Edouard2laire
Copy link
Contributor Author

Here is a first implementation. The following code is adding the plugin in the .brainstorm folder.

bst_plugin('AddCustom','https://github.com/Edouard2laire/bst-users/blob/custom_plugin/plugins/plugin_bids_matlab.json')

Is there a way to update the plugin menu without starting brainstorm again ?

@Edouard2laire
Copy link
Contributor Author

ok . This is ready to be reviewed. The only issue is that when adding a new plugin, brainstorm needs to be restarted to update the menu.

@Edouard2laire
Copy link
Contributor Author

is there any news for that PR by any chance ? :)

@rcassani
Copy link
Member

Just started with it

@rcassani
Copy link
Member

@Edouard2laire, I'm still working on this PR. Meanwhile, what do you think on deleting the json file (in the plugin dir) when uninstall a 'User defined' plugin? I think it makes sense, as if they are not needed for the moment, they can be unloaded. Otherwise, a method to delete the json files would be needed.

@Edouard2laire
Copy link
Contributor Author

@Edouard2laire, I'm still working on this PR. Meanwhile, what do you think on deleting the json file (in the plugin dir) when uninstall a 'User defined' plugin? I think it makes sense, as if they are not needed for the moment, they can be unloaded. Otherwise, a method to delete the json files would be needed.

yes, I think that make sense too. Users can easily add back the plugin if they want.

@rcassani
Copy link
Member

yes, I think that make sense too. Users can easily add back the plugin if they want.

It looked as a good idea, but now it is quite asymmetric.
"Add", just adds, Install is needed
'Uninstall', uninstalls and deletes the json file

I'll add the option of remove the custom plugin:

  • Add > Install
  • Uninstall > Remove (with remove uninstalling if needed)

@Edouard2laire
Copy link
Contributor Author

Wow it looks great! thanks a lot. (sorry I didn't realize there was so much code left to write)

For the addition of new plugin, do we need to have 3 options ( file, URL, and manual)? I have the feeling that the file and URL would already cover most of the options.

@rcassani
Copy link
Member

Wanted to add the manual, as a way to start create a basic .json without having to type it.

In addition, documentation is needed for this new feature. I'll start with draft and share it with you.
Do you have access to edit pages in the Brainstorm wiki?

@Edouard2laire
Copy link
Contributor Author

Wanted to add the manual, as a way to start create a basic .json without having to type it.

In addition, documentation is needed for this new feature. I'll start with draft and share it with you. Do you have access to edit pages in the Brainstorm wiki?

Yes, I have access (username: EdouardDelaire). Let me know if there is anything else you want me to do.

@rcassani
Copy link
Member

@Edouard2laire, documentation is in the link below, please check it out and edit it if needed.
https://neuroimage.usc.edu/brainstorm/Tutorials/Plugins

This PR seems to be read to be merged!

@Edouard2laire
Copy link
Contributor Author

Edouard2laire commented May 24, 2024

Looks good to me. Thx :)

For the documentation; maybe we want to add a sentence saying the procedure if a user wants their plugin to be officially integrated in Brainstorm ?

@rcassani rcassani merged commit 998a993 into brainstorm-tools:master May 27, 2024
@rcassani
Copy link
Member

@Edouard2laire 🎉
(and before 2026 🤣)

@Edouard2laire
Copy link
Contributor Author

🎉🎉
Thanks for your help in this PR :)
(hopefully, I'll have graduated by 2026 lol)

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

Successfully merging this pull request may close these issues.

None yet

2 participants