Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
efriis committed Oct 31, 2024
1 parent fb8d4d3 commit 9427be4
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions .github/scripts/prep_api_docs_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,20 @@ def load_packages_yaml() -> Dict[str, Any]:
return yaml.safe_load(f)


def get_target_dir(package_name: str) -> Path:
"""Get the target directory for a given package."""
package_name_short = package_name.replace("langchain-", "")
base_path = Path("langchain/libs")
if package_name_short == "experimental":
return base_path / "experimental"
return base_path / "partners" / package_name_short


def clean_target_directories(packages: Dict[str, Any]) -> None:
"""Remove old directories that will be replaced."""
base_path = Path("langchain/libs/partners")
for package in packages["packages"]:
if package["repo"] != "langchain-ai/langchain":
package_name = package["name"].replace("langchain-", "")
target_dir = base_path / package_name
target_dir = get_target_dir(package["name"])
if target_dir.exists():
print(f"Removing {target_dir}")
shutil.rmtree(target_dir)
Expand All @@ -36,12 +43,8 @@ def move_libraries(packages: Dict[str, Any]) -> None:
continue

repo_name = package["repo"].split("/")[1]
package_name = package["name"].replace("langchain-", "")
source_path = package["path"]
target_dir = f"langchain/libs/partners/{package_name}"
if package_name == "experimental":
# special case experimental
target_dir = "langchain/libs/experimental"
target_dir = get_target_dir(package["name"])

# Handle root path case
if source_path == ".":
Expand Down

0 comments on commit 9427be4

Please sign in to comment.