Support generating Python SDK with Pyodide#4784
Conversation
|
No changes needing a change description found. |
|
You can try these changes here
|
iscai-msft
left a comment
There was a problem hiding this comment.
looking really good, thanks @YalinLi0312 !
| if (sdkContext.arm === true) { | ||
| commandArgs.push("--azure-arm=true"); | ||
| } | ||
| if (resolvedOptions.flavor === "azure") { |
There was a problem hiding this comment.
The logic about options (e.g. "azure-arm"/"flavor") between python mode and pyodide mode is same so it is better to handle them in one central place.
| Write-Host "Building project ..." | ||
| & npm run build | ||
|
|
||
| Write-Host "Regenerating project with Pyodide ..." |
There was a problem hiding this comment.
I think there is no need to add new step in eng to run test twice with python and pyodide mode to make the CI time double than now. We can run azure test with python mode and unbranded test with pyodide mode. Then you just need to add use-pyodide: true here
There was a problem hiding this comment.
we just want to make sure that generating with pyodide and with python result in the same output, so I think it is necessary to run twice
| resolvedOptions["package-pprint-name"] = `"${resolvedOptions["package-pprint-name"]}"`; | ||
| } | ||
| if (resolvedOptions["use-pyodide"]) { | ||
| const commandArgs: Record<string, string> = {}; |
There was a problem hiding this comment.
the command args should be same whatever use pyodide or not, it's better to consolidate the logic.
| async def main(): | ||
| import warnings | ||
| with warnings.catch_warnings(): | ||
| warnings.simplefilter("ignore", SyntaxWarning) | ||
| from pygen import m2r, preprocess, codegen, black | ||
|
|
||
| m2r.M2R(output_folder=outputFolder, cadl_file=yamlRelativePath, **commandArgs).process() | ||
| preprocess.PreProcessPlugin(output_folder=outputFolder, cadl_file=yamlRelativePath, **commandArgs).process() | ||
| codegen.CodeGenerator(output_folder=outputFolder, cadl_file=yamlRelativePath, **commandArgs).process() | ||
| black.BlackScriptPlugin(output_folder=outputFolder, **commandArgs).process() | ||
|
|
||
| await main() |
There was a problem hiding this comment.
is pyodide able to run a py file? i just wondering if two paths could be consolidated. previously, we used py file. here, we use inline code.
|
|
||
| await main() | ||
| `; | ||
| await pyodide.runPythonAsync(python, { globals }); |
There was a problem hiding this comment.
how will pyodide deal with exception?
| await runPython3("./eng/scripts/setup/install.py"); | ||
| await runPython3("./eng/scripts/setup/prepare.py"); |
There was a problem hiding this comment.
i'm wondering how the exception be caught here?
|
closing in favor of #5289 |
Mostly copied from #4784, thank you @YalinLi0312 --------- Co-authored-by: iscai-msft <isabellavcai@gmail.com> Co-authored-by: tadelesh <tadelesh.shi@live.cn>
No description provided.