* Add nightly hash history script to nightly workflow * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * Add lfx-nightly to script * Handle first run * Try fixing version on nightly hash history * remove lfx lockfile since it does not exist * Get full version in build, handle the [extras] in pyprojects * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * language update * Handle extras in langflow-base dependency in all workflows * [autofix.ci] apply automated fixes * Fix import in lfx status response * [autofix.ci] apply automated fixes * Use built artifact for jobs, remove wait period * use [complete] when building test cli job * skip slack message added to success * Update merge hash histry job to only run when ref is main * Updates pyproject naming to add nightly suffix * [autofix.ci] apply automated fixes * Fix ordering of lfx imports' * [autofix.ci] apply automated fixes * Ah, ignore auto-import fixes by ruff * [autofix.ci] apply automated fixes * update test to look at _all_ exported instead * [autofix.ci] apply automated fixes * perf: Limit enum options in tool schemas to reduce token usage (#11370) * fix current date tokens usage * Update src/lfx/src/lfx/io/schema.py * remove comment --------- Co-authored-by: Himavarsha <40851462+HimavarshaVS@users.noreply.github.com> * update date test to reflect changes to lfx * ruff * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Cristhian Zanforlin Lousa <cristhian.lousa@gmail.com> Co-authored-by: Himavarsha <40851462+HimavarshaVS@users.noreply.github.com>
89 lines
3.0 KiB
Python
Executable File
89 lines
3.0 KiB
Python
Executable File
#!/usr/bin/env python
|
|
|
|
import re
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import packaging.version
|
|
|
|
BASE_DIR = Path(__file__).parent.parent.parent
|
|
ARGUMENT_NUMBER = 3
|
|
|
|
|
|
def update_base_dep(pyproject_path: str, new_version: str) -> None:
|
|
"""Update the langflow-base dependency in pyproject.toml."""
|
|
filepath = BASE_DIR / pyproject_path
|
|
content = filepath.read_text(encoding="utf-8")
|
|
|
|
# Updated pattern to handle PEP 440 version suffixes, extras (e.g., [complete]),
|
|
# both ~= and == version specifiers, and both langflow-base and langflow-base-nightly names
|
|
# Captures extras in group 2 to preserve them in the replacement
|
|
pattern = re.compile(r'("langflow-base(?:-nightly)?((?:\[[^\]]+\])?)(?:~=|==)[\d.]+(?:\.(?:post|dev|a|b|rc)\d+)*")')
|
|
|
|
# Check if the pattern is found
|
|
match = pattern.search(content)
|
|
if not match:
|
|
msg = f'langflow-base dependency not found in "{filepath}"'
|
|
raise ValueError(msg)
|
|
|
|
# Extract extras if present (e.g., "[complete]")
|
|
extras = match.group(2) if match.group(2) else ""
|
|
replacement = f'"langflow-base-nightly{extras}=={new_version}"'
|
|
|
|
# Replace the matched pattern with the new one
|
|
content = pattern.sub(replacement, content)
|
|
filepath.write_text(content, encoding="utf-8")
|
|
|
|
|
|
def update_lfx_dep_in_base(pyproject_path: str, lfx_version: str) -> None:
|
|
"""Update the LFX dependency in langflow-base pyproject.toml to use nightly version."""
|
|
filepath = BASE_DIR / pyproject_path
|
|
content = filepath.read_text(encoding="utf-8")
|
|
|
|
# Updated pattern to handle PEP 440 version suffixes, both ~= and == version specifiers,
|
|
# and both lfx and lfx-nightly names
|
|
pattern = re.compile(r'("lfx(?:-nightly)?(?:~=|==)[\d.]+(?:\.(?:post|dev|a|b|rc)\d+)*")')
|
|
replacement = f'"lfx-nightly=={lfx_version}"'
|
|
|
|
# Check if the pattern is found
|
|
if not pattern.search(content):
|
|
msg = f'LFX dependency not found in "{filepath}"'
|
|
raise ValueError(msg)
|
|
|
|
# Replace the matched pattern with the new one
|
|
content = pattern.sub(replacement, content)
|
|
filepath.write_text(content, encoding="utf-8")
|
|
|
|
|
|
def verify_pep440(version):
|
|
"""Verify if version is PEP440 compliant.
|
|
|
|
https://github.com/pypa/packaging/blob/16.7/packaging/version.py#L191
|
|
"""
|
|
return packaging.version.Version(version)
|
|
|
|
|
|
def main() -> None:
|
|
if len(sys.argv) != ARGUMENT_NUMBER:
|
|
msg = "Usage: update_lf_base_dependency.py <base_version> <lfx_version>"
|
|
raise ValueError(msg)
|
|
base_version = sys.argv[1]
|
|
lfx_version = sys.argv[2]
|
|
|
|
# Strip "v" prefix from versions if present
|
|
base_version = base_version.removeprefix("v")
|
|
lfx_version = lfx_version.removeprefix("v")
|
|
|
|
verify_pep440(base_version)
|
|
verify_pep440(lfx_version)
|
|
|
|
# Update langflow-base dependency in main project
|
|
update_base_dep("pyproject.toml", base_version)
|
|
|
|
# Update LFX dependency in langflow-base
|
|
update_lfx_dep_in_base("src/backend/base/pyproject.toml", lfx_version)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|