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

Update wagi.rs #3025

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Update wagi.rs #3025

wants to merge 1 commit into from

Conversation

guyoung
Copy link

@guyoung guyoung commented Feb 25, 2025

modify parse WagiHttp request params to command-line arguments

modify parse WagiHttp request params to  command-line arguments
Copy link
Collaborator

@itowlson itowlson left a comment

Choose a reason for hiding this comment

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

This change seems to alter the behaviour to ignore wagi_config. Can you say more about what you intend with this change?

@guyoung
Copy link
Author

guyoung commented Mar 1, 2025

In my project AIMatrices(https://github.com/guyoung/AIMatrices), a large amount of code from the Spin project is referenced. There is a requirement to run Python code using wagi, and the http requests are as follows:

Currently, the parameter parsing method of WagiHttpExecutor cannot meet the above http requests.

@guyoung guyoung mentioned this pull request Mar 1, 2025
@itowlson
Copy link
Collaborator

itowlson commented Mar 2, 2025

Thanks for the clarification. The WAGI executor an argv template from configuration, and we can't just throw that away. For example, a Spin app could set:

executor = { type = "wagi", argv = "my-first-value ${SCRIPT_NAME} my-middle-value ${ARGS} my-last-value"

and your proposed change would break that.

I'm guessing the big problem is the way that the implementation splits the post-substitution argv on spaces, so your query string of http://127.0.0.1:21500/python?-c&import sys; print(sys.version) gets turned into an args of ["-c", "import", "sys;", "print(sys.version)"] or something like that?

If so, maybe the fix is to change how we use the template. Currently we sub into the template string, then split the post-substitution argv on spaces to get an args iterator. Maybe the better strategy is to split the template string on spaces first, then splice in the array of query-string pairs at the position of the ${ARGS} element. That seems like it might meet your needs while retaining backward compatibility with argv templates. Thoughts?

@guyoung
Copy link
Author

guyoung commented Mar 3, 2025

I agree with you

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.

2 participants