-
Notifications
You must be signed in to change notification settings - Fork 217
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
Python sample (scripting ML/AI sample and web Django and Flask) #152
Python sample (scripting ML/AI sample and web Django and Flask) #152
Conversation
seems like CI does not install aspire workload
|
...on.ScriptsAndWebDjangoFlask.AppHost/AspireWithPython.ScriptsAndWebDjangoFlask.AppHost.csproj
Outdated
Show resolved
Hide resolved
I still wonder if this could work "on request". Take a look at this python example: This is a very basic tool which does canny edge detection, and uses gRPC for communication. var cannyEdgeToolContainer = builder
.AddContainer("Canny Edge Detection Tool", "canny-edge-tool")
.WithServiceBinding(hostPort: 50051, containerPort: 50051, name: "canny-edge-tool-endpoint");
var cannyEdgeToolEndpoint = cannyEdgeToolContainer
.GetEndpoint("canny-edge-tool-endpoint"); var cannyEdgeService = builder
.AddProject<Projects.PerceiveAPI_CannyEdgeService_API>("cannyedgeservice-api")
.WithReference(cannyEdgeToolEndpoint); So, could this also work, when it isn't a container, and there isn't gRPC, and it is just an executable? Of course, I can invoke "the normal way" (Process.Start()), but I mean the Aspire way, if there is. |
Well, I am not cloud expert. Just using and learning along the way. I came from Aspire and MAUI (and other clients) integration initiative which sprung to my mind during internal presentation on Aspire and I asked David whether that would work for MAUI and MAUI is several clients in one. Basically "on request" is feature used when orchestrator needs to scale (up/down, in/out), so I think I could make safe bet that Aspire team has that on their plate.
OK. I will. It will take some time.
I think it should. I have few ideas, but again it will take some time. Right now I am trying to solve other, similar issues for clients... See even folder is called Client, because I just changed simple python scripting AI/ML sample to launch Django/Flask.
Aspire is in preview and most likely - not eveything we (You and me) need is implemented. I found out that Aspire SDK can easily be extended and this is what I am exploring and implementing along the way. |
Okay, I worked out a more complete example, also including .NET code, so you have everything. This is how we currently do it. There is a Tool, developed by a research-orientated organization, which needs to be used by the API. So, now this tools runs in a container, hosting a gRPC server to handle requests. In the sample, if you look in For others reading this: the reason for this complexity it because in academia, researchers have no clue whatsoever when it comes to system/cloud/web development. They mainly develop in MATLAB, and python. Therefore, we cannot just ask them to "expose some endpoints", or basically write a whole microservice in Python. They do not understand. Therefore, we have chosen the gRPC approach for now. However, this comes with its limitations and challenges as well, since gRPC isn't supported by MATLAB for example. It also requires quite some guidance from our part. This makes us especially eager to learn to see if it is possible, and feasible, to run the tools as executables/processes. Then it would be possible to have it as an executable omitting gRPC and docker. |
Edit: Seems like on windows nuget restore is being canceled because of NU1506 (item 2 in list above) |
OK. I took a sneak peek into the sample.
Is gRPC server is control manager? To start tool on demand. If yes - this way Aspire.AppHost has no idea that tool (in Aspire lang - Resource, ExecutableResource or ContainerResource) was restarted. I added embbeded HTTP server (watson) to Aspire-Python implementation and am able to hit it with request and
Endpoint is gRPC endpoint of the "control manager". Am I right?
That is the reason I went with HTTP Watson 1st. Almost every data science language has HTTP client, but not server implementation and then Matlab script could request
I went with process ( I will take a deeper look and finish my sample... And then we can talk. Besides I have tons of questions for Aspire team. |
What do you exactly mean with "control manager"?
Well, the tool is just constantly running.
How will this work? And if you are using an HTTP server, how does it differ from using a gRPC server? To me it doesn't solve the issue, or I might be overlooking something / not understanding it fully.
I fail to understand the meaning of control manager in this context, maybe I am missing something though.
Yes, exactly. However, the more I think about this, I can't really see a way for the tool to not be a continuous running process (e,g. gRPC server). Let's go to my sample, this is like the basic sequence:
If the .NET API would just start the process on request ( |
Naming is hard: control/command manager. Receives message/function-call/request and does something. Let's make few steps back. From what I see: gRPC server listens and when it receives something it starts tool (detail: for edge detection). Is that right? Correct me if I am wrong. And then we can go further... |
Aahhh yes.
Yes thats correct. Are you familiar with gRPC? If not, you can read up on it here: https://grpc.io/ |
OK. We are on the same page.
I use it. When I learn I like to do practical things 1st and then dive into theory. So, with gRPC I am junior.
Thanks. Let me finish my daily jobs which piled up because of conference and problems that were not under my control. And then I will finish sample with "Control Manager" I have in my dreams. |
Thanks for this. However we'd like to keep this samples repo limited to demonstrations of Aspire hosting and components owned and shipped from the actual Aspire repo. I think the best place for samples related to community Aspire extensions is in the repos of those extensions. |
Sample integrating Aspire and Python (as Process/ExecutableResource - not Container)
Video
https://www.youtube.com/watch?v=oDSW0t_x9MM
Plans:
Extended sample[s]
https://github.com/Samples-Playgrounds/Samples.Aspire/tree/main/samples/aspire-starter
Motivation - Based on feedback/discussion