Files
langflow/scripts/ci/update_pyproject_name.py
Jordan Frazier a097b685fd ci: add hash history script to nightly workflow (#11409)
* 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>
2026-01-27 16:27:59 +00:00

78 lines
2.9 KiB
Python
Executable File

#!/usr/bin/env python
import re
import sys
from pathlib import Path
BASE_DIR = Path(__file__).parent.parent.parent
ARGUMENT_NUMBER = 3
def update_pyproject_name(pyproject_path: str, new_project_name: str) -> None:
"""Update the project name in pyproject.toml."""
filepath = BASE_DIR / pyproject_path
content = filepath.read_text(encoding="utf-8")
# Regex to match the version line under [tool.poetry]
pattern = re.compile(r'(?<=^name = ")[^"]+(?=")', re.MULTILINE)
if not pattern.search(content):
msg = f'Project name not found in "{filepath}"'
raise ValueError(msg)
content = pattern.sub(new_project_name, content)
# Update extra references in [complete] and [all] extras for nightly builds
if new_project_name == "langflow-base-nightly":
# Replace langflow-base[extra] with langflow-base-nightly[extra] in optional dependencies
content = re.sub(r'"langflow-base\[([^\]]+)\]"', r'"langflow-base-nightly[\1]"', content)
elif new_project_name == "langflow-nightly":
# Replace langflow[extra] with langflow-nightly[extra] in optional dependencies
content = re.sub(r'"langflow\[([^\]]+)\]"', r'"langflow-nightly[\1]"', content)
filepath.write_text(content, encoding="utf-8")
def update_uv_dep(pyproject_path: str, new_project_name: str) -> None:
"""Update the langflow-base dependency in pyproject.toml."""
filepath = BASE_DIR / pyproject_path
content = filepath.read_text(encoding="utf-8")
if new_project_name == "langflow-nightly":
pattern = re.compile(r"langflow = \{ workspace = true \}")
replacement = "langflow-nightly = { workspace = true }"
elif new_project_name == "langflow-base-nightly":
pattern = re.compile(r"langflow-base = \{ workspace = true \}")
replacement = "langflow-base-nightly = { workspace = true }"
else:
msg = f"Invalid project name: {new_project_name}"
raise ValueError(msg)
# Updates the dependency name for uv
if not pattern.search(content):
msg = f"{replacement} uv dependency not found in {filepath}"
raise ValueError(msg)
content = pattern.sub(replacement, content)
filepath.write_text(content, encoding="utf-8")
def main() -> None:
if len(sys.argv) != ARGUMENT_NUMBER:
msg = "Must specify project name and build type, e.g. langflow-nightly base"
raise ValueError(msg)
new_project_name = sys.argv[1]
build_type = sys.argv[2]
if build_type == "base":
update_pyproject_name("src/backend/base/pyproject.toml", new_project_name)
update_uv_dep("pyproject.toml", new_project_name)
elif build_type == "main":
update_pyproject_name("pyproject.toml", new_project_name)
update_uv_dep("pyproject.toml", new_project_name)
else:
msg = f"Invalid build type: {build_type}"
raise ValueError(msg)
if __name__ == "__main__":
main()