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

Allow RuntimeManager to load scripts stored as assembly resource files #6

Merged
merged 2 commits into from
Feb 16, 2024

Conversation

ncguilbeault
Copy link
Contributor

@ncguilbeault ncguilbeault commented Jan 22, 2024

This PR adds support for loading python scripts in assembly

Loading Python Scripts in Assembly

A nice feature for integrating Python packages into Bonsai is the ability to package python scripts in Bonsai/NuGet packages which can be loaded directly through the RuntimeManager. To do this, the RuntimeManager just needs to detect whether ScriptPaths point to embedded resources and then load the embedded script. With this new feature, it is now possible for the RuntimeManager to parse the path of a script to determine:

  1. if it is an embedded resource; and
  2. load the embedded python script from the specified assembly location.

@ncguilbeault ncguilbeault changed the title Updated to load assembly locations Updated RuntimeManager to load Python scripts embedded in assembly locations Jan 22, 2024
@glopesdev glopesdev changed the title Updated RuntimeManager to load Python scripts embedded in assembly locations Allow RuntimeManager to load scripts stored as assembly resource files Feb 14, 2024
@glopesdev glopesdev added the feature New planned feature label Feb 14, 2024
@glopesdev glopesdev self-requested a review February 14, 2024 16:33
Copy link
Member

@glopesdev glopesdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, I just made the two helper functions private to the class.

In this case I also feel it may be better to centralize all reading logic into a single function to make it easier to understand where all the logic for reading the python code is located.

src/Bonsai.Scripting.Python/RuntimeManager.cs Outdated Show resolved Hide resolved
src/Bonsai.Scripting.Python/RuntimeManager.cs Outdated Show resolved Hide resolved
src/Bonsai.Scripting.Python/RuntimeManager.cs Outdated Show resolved Hide resolved
src/Bonsai.Scripting.Python/RuntimeManager.cs Outdated Show resolved Hide resolved
Co-authored-by: glopesdev <glopesdev@users.noreply.github.com>
@glopesdev glopesdev self-requested a review February 16, 2024 10:27
@glopesdev glopesdev merged commit acb2244 into bonsai-rx:main Feb 16, 2024
1 check passed
Copy link
Member

@glopesdev glopesdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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

Successfully merging this pull request may close these issues.

2 participants