Skip to content

Commit

Permalink
update the base dep in uv deps
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanrfrazier committed Oct 1, 2024
1 parent a46eb5d commit ce3d9b2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/nightly_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ jobs:
git config --global user.email "[email protected]"
git config --global user.name "Langflow Bot"
# WARNING: These scripts must be run in this order.
# Poetry will use a different cached virtual environment once the main pyproject.toml
# project-name is updated, which does not have dependencies installed.
BASE_TAG="${{ steps.generate_base_tag.outputs.base_tag }}"
echo "Updating base project version to $BASE_TAG"
uv run ./scripts/ci/update_pyproject_name.py langflow-base-nightly base
Expand Down
29 changes: 24 additions & 5 deletions scripts/ci/update_pyproject_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,40 @@ def update_pyproject_name(pyproject_path: str, new_project_name: str) -> None:
with open(filepath, "w") as file:
file.write(content)

def update_base_dep(pyproject_path: str, new_version: str) -> None:
def update_uv_dep(pyproject_path: str, new_project_name: str) -> None:
"""Update the langflow-base dependency in pyproject.toml."""
filepath = os.path.join(BASE_DIR, pyproject_path)
with open(filepath, "r") as file:
content = file.read()

replacement = "langflow-base-nightly = { workspace = true }"
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:
raise ValueError(f"Invalid project name: {new_project_name}")

# Updates the dependency name for uv
pattern = re.compile(r'langflow-base = \{ workspace = true \}')
if not pattern.search(content):
raise Exception(f'langflow-base uv dependency not found in "{filepath}"')
raise Exception(f"{replacement} uv dependency not found in {filepath}")
content = pattern.sub(replacement, content)
with open(filepath, "w") as file:
file.write(content)

# For the main project, update the langflow-base dependency in uv section
if new_project_name == "langflow-nightly":
# pattern = re.compile(r'langflow-base')
pattern = re.compile(r'(dependencies\s*=\s*\[\s*\n\s*)("langflow-base")')
replacement = r'\1"langflow-base-nightly"'

if not pattern.search(content):
raise Exception(f"{replacement} uv dependency not found in {filepath}")
content = pattern.sub(replacement, content)
with open(filepath, "w") as file:
file.write(content)


def main() -> None:
if len(sys.argv) != 3:
Expand All @@ -48,9 +66,10 @@ def main() -> None:

if build_type == "base":
update_pyproject_name("src/backend/base/pyproject.toml", new_project_name)
update_base_dep("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:
raise ValueError(f"Invalid build type: {build_type}")

Expand Down

0 comments on commit ce3d9b2

Please sign in to comment.