Skip to content

Commit

Permalink
infra: allow non-langchainai packages (#28199)
Browse files Browse the repository at this point in the history
  • Loading branch information
efriis authored Nov 19, 2024
1 parent d9d6895 commit 24eea2e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
36 changes: 20 additions & 16 deletions .github/scripts/prep_api_docs_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
def load_packages_yaml() -> Dict[str, Any]:
"""Load and parse the packages.yml file."""
with open("langchain/libs/packages.yml", "r") as f:
return yaml.safe_load(f)
all_packages = yaml.safe_load(f)

return {k: v for k, v in all_packages.items() if k["repo"]}


def get_target_dir(package_name: str) -> Path:
Expand All @@ -23,24 +25,19 @@ def get_target_dir(package_name: str) -> Path:
return base_path / "partners" / package_name_short


def clean_target_directories(packages: Dict[str, Any]) -> None:
def clean_target_directories(packages: list) -> None:
"""Remove old directories that will be replaced."""
for package in packages["packages"]:
if package["repo"] != "langchain-ai/langchain":
target_dir = get_target_dir(package["name"])
if target_dir.exists():
print(f"Removing {target_dir}")
shutil.rmtree(target_dir)
for package in packages:

target_dir = get_target_dir(package["name"])
if target_dir.exists():
print(f"Removing {target_dir}")
shutil.rmtree(target_dir)


def move_libraries(packages: Dict[str, Any]) -> None:
def move_libraries(packages: list) -> None:
"""Move libraries from their source locations to the target directories."""
for package in packages["packages"]:
# Skip if it's the main langchain repo or disabled
if package["repo"] == "langchain-ai/langchain" or package.get(
"disabled", False
):
continue
for package in packages:

repo_name = package["repo"].split("/")[1]
source_path = package["path"]
Expand Down Expand Up @@ -68,7 +65,14 @@ def main():
"""Main function to orchestrate the library sync process."""
try:
# Load packages configuration
packages = load_packages_yaml()
package_yaml = load_packages_yaml()
packages = [
p
for p in package_yaml["packages"]
if not p.get("disabled", False)
and p["repo"].startswith("langchain-ai/")
and p["repo"] != "langchain-ai/langchain"
]

# Clean target directories
clean_target_directories(packages)
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/api_doc_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ jobs:
# Get unique repositories
REPOS=$(echo "$REPOS_UNSORTED" | sort -u)
# Checkout each unique repository
# Checkout each unique repository that is in langchain-ai org
for repo in $REPOS; do
if [ "$repo" != "langchain-ai/langchain" ]; then
if [[ "$repo" != "langchain-ai/langchain" && "$repo" == langchain-ai/* ]]; then
REPO_NAME=$(echo $repo | cut -d'/' -f2)
echo "Checking out $repo to $REPO_NAME"
git clone --depth 1 https://github.com/$repo.git $REPO_NAME
Expand Down

0 comments on commit 24eea2e

Please sign in to comment.