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

[Experiment] Runtime AST modifier for Transformers #1185

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions packages/kernel/py/stlite-lib/stlite_lib_tests/codemod_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1001,3 +1001,33 @@ def test_convert_asyncio_run(test_input, expected):
assert ast.dump(tree, indent=4) == ast.dump(
ast.parse(expected, "test.py", "exec"), indent=4
)



@pytest.mark.parametrize(
"test_input,expected",
[
pytest.param(
"""
from transformers import pipeline

classifier = pipeline("sentiment-analysis")

result = classifier("We are very happy to show you the 🤗 Transformers library.")
""",
"""
from transformers_js_py import pipeline

classifier = await pipeline("sentiment-analysis")

result = await classifier("We are very happy to show you the 🤗 Transformers library.")
""",
id="transformers_pipeline",
),
],
)
def test_convert_transformers_js(test_input, expected):
tree = patch(test_input, "test.py")
assert ast.dump(tree, indent=4) == ast.dump(
ast.parse(expected, "test.py", "exec"), indent=4
)
Loading