mirror of
https://github.com/hwchase17/langchain
synced 2024-11-13 19:10:52 +00:00
docs: experimental case, use yq action (#27798)
This commit is contained in:
parent
f94125a325
commit
54cb80c778
16
.github/scripts/prep_api_docs_build.py
vendored
16
.github/scripts/prep_api_docs_build.py
vendored
@ -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)
|
||||
@ -36,9 +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}"
|
||||
target_dir = get_target_dir(package["name"])
|
||||
|
||||
# Handle root path case
|
||||
if source_path == ".":
|
||||
|
16
.github/workflows/api_doc_build.yml
vendored
16
.github/workflows/api_doc_build.yml
vendored
@ -23,15 +23,19 @@ jobs:
|
||||
path: langchain-api-docs-html
|
||||
token: ${{ secrets.TOKEN_GITHUB_API_DOCS_HTML }}
|
||||
|
||||
- name: Install yq
|
||||
run: |
|
||||
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
|
||||
sudo chmod a+x /usr/local/bin/yq
|
||||
- name: Get repos with yq
|
||||
id: get-unsorted-repos
|
||||
uses: mikefarah/yq@master
|
||||
with:
|
||||
cmd: yq '.packages[].repo' langchain/libs/packages.yml
|
||||
|
||||
- name: Parse YAML and checkout repos
|
||||
env:
|
||||
REPOS_UNSORTED: ${{ steps.get-unsorted-repos.outputs.result }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
# Get unique repositories
|
||||
REPOS=$(yq '.packages[].repo' langchain/libs/packages.yml | sort -u)
|
||||
REPOS=$(echo "$REPOS_UNSORTED" | sort -u)
|
||||
|
||||
# Checkout each unique repository
|
||||
for repo in $REPOS; do
|
||||
@ -41,8 +45,6 @@ jobs:
|
||||
git clone --depth 1 https://github.com/$repo.git $REPO_NAME
|
||||
fi
|
||||
done
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Set up Python ${{ env.PYTHON_VERSION }} + Poetry ${{ env.POETRY_VERSION }}
|
||||
uses: "./langchain/.github/actions/poetry_setup"
|
||||
|
@ -601,9 +601,11 @@ For the legacy API reference hosted on ReadTheDocs see [https://api.python.langc
|
||||
]
|
||||
for header_name, dir_ in sorted(
|
||||
zip(integration_headers, integrations),
|
||||
key=lambda h_d: integrations_to_show.index(h_d[1])
|
||||
if h_d[1] in integrations_to_show
|
||||
else len(integrations_to_show),
|
||||
key=lambda h_d: (
|
||||
integrations_to_show.index(h_d[1])
|
||||
if h_d[1] in integrations_to_show
|
||||
else len(integrations_to_show)
|
||||
),
|
||||
)[: len(integrations_to_show)]:
|
||||
integration_grid += f'\n- header: "**{header_name}**"\n content: {_package_namespace(dir_).replace("_", "-")} {_get_package_version(_package_dir(dir_))}\n link: {dir_.replace("-", "_")}/index.html'
|
||||
doc += f"""## Integrations
|
||||
@ -648,7 +650,7 @@ def main(dirs: Optional[list] = None) -> None:
|
||||
dirs = [
|
||||
dir_
|
||||
for dir_ in os.listdir(ROOT_DIR / "libs")
|
||||
if dir_ not in ("cli", "partners", "standard-tests")
|
||||
if dir_ not in ("cli", "partners", "standard-tests", "packages.yml")
|
||||
]
|
||||
dirs += [
|
||||
dir_
|
||||
|
Loading…
Reference in New Issue
Block a user