cli[patch]: Update migrations file manually (#21021)

We need to replace occurrences in the code of RunnableMap not just the
import,
so for now, we don't replace RunnableMap.
This commit is contained in:
Eugene Yurtsev 2024-04-29 10:53:31 -04:00 committed by GitHub
parent 67428c4052
commit 4f4ee8e2cf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 32 additions and 3 deletions

View File

@ -1569,7 +1569,7 @@
],
[
"langchain.schema.runnable.RunnableMap",
"langchain_core.runnables.RunnableParallel"
"langchain_core.runnables.RunnableMap"
],
[
"langchain.schema.runnable.RunnableParallel",
@ -1629,7 +1629,7 @@
],
[
"langchain.schema.runnable.base.RunnableMap",
"langchain_core.runnables.RunnableParallel"
"langchain_core.runnables.RunnableMap"
],
[
"langchain.schema.runnable.base.coerce_to_runnable",

View File

@ -106,7 +106,7 @@ def generate_top_level_imports(pkg: str) -> List[Tuple[str, str]]:
# Only iterate through top-level modules/packages
for finder, modname, ispkg in pkgutil.iter_modules(
package.__path__, package.__name__ + "."
package.__path__, package.__name__ + "."
):
if ispkg:
try:

View File

@ -0,0 +1,29 @@
"""Handle a test case where the import is updated and may involve an alias change."""
from tests.unit_tests.migrate.cli_runner.case import Case
from tests.unit_tests.migrate.cli_runner.file import File
# The test case right now make sure that if we update the import
# of RunnableMap to RunnableParallel then the code that's using RunnableMap
# should be updated as well (or else we keep importing RunnableMap.)
cases = [
Case(
name="Imports",
source=File(
"app.py",
content=[
"from langchain.runnables import RunnableMap",
"",
"chain = RunnableMap({})",
],
),
expected=File(
"app.py",
content=[
"from langchain_core.runnables import RunnableMap",
"",
"chain = RunnableMap({})",
],
),
),
]
""