Add progress callback#74
Open
869570967 wants to merge 6 commits into
Open
Conversation
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Purpose: When calling functions like await Installer.TryInstallPip(); and await Installer.PipInstallModule("torch", progress: progress); sometimes, due to network issues or very large packages, the program has to wait a long time without any progress feedback. Simply showing a loading spinner isn’t ideal, so here we add a progress callback parameter to make it easier to display the current progress in real time.
PS: The code was implemented using AI, and self-testing shows no issues so far. Here's my test code—you can also try it out to see if it works. If there are no problems, it can be merged and published to NuGet (pre-release is fine too). I'm a bit pressed to use it. Thanks a lot!
`using Python.Included;
namespace PythonDemo
{
internal class Program
{
static async Task Main(string[] args)
{
Installer.LogMessage += Installer_LogMessage;
//Console.WriteLine("Hello, World!");
await Installer.SetupPython();
await Installer.TryInstallPip();
Action progress = p =>
{
Console.WriteLine(p);
};
await Installer.PipInstallModule("torch", progress: progress);
}
}
`