Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 128 additions & 0 deletions framework/dev/cmp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# #!/bin/bash
# # Compare conf.py across different versions of Flower
# # Usage:
# # ./cmp.sh v1.8.0 v1.9.0 # Compare two specific versions
# # ./cmp.sh # Compare all consecutive versions

# set -e

# # Move to the repository root
# cd "$(git rev-parse --show-toplevel)"

# # Function to determine the correct path for conf.py based on version
# get_conf_path() {
# local version=$1

# # Extract version number for comparison (remove 'v' prefix and convert to number)
# # v1.14.0 and later use framework/docs/source/conf.py
# # Earlier versions use doc/source/conf.py

# # Simple version comparison: if >= v1.14.0, use new path
# if [[ "$version" == "main" ]]; then
# echo "framework/docs/source/conf.py"
# else
# # Extract major and minor version (e.g., v1.14.0 -> 1.14)
# local ver_num=$(echo "$version" | sed 's/^v//' | cut -d. -f1,2)
# local major=$(echo "$ver_num" | cut -d. -f1)
# local minor=$(echo "$ver_num" | cut -d. -f2)

# # Check if version >= 1.14
# if (( major > 1 )) || (( major == 1 && minor >= 14 )); then
# echo "framework/docs/source/conf.py"
# else
# echo "doc/source/conf.py"
# fi
# fi
# }

# # Function to compare two versions
# compare_versions() {
# local v1=$1
# local v2=$2

# local path1=$(get_conf_path "$v1")
# local path2=$(get_conf_path "$v2")

# echo "========================================"
# echo "Comparing: $v1 → $v2"
# echo " $v1: $path1"
# echo " $v2: $path2"
# echo "========================================"

# # Check if files exist
# if ! git cat-file -e "$v1:$path1" 2>/dev/null; then
# echo "ERROR: File not found at $v1:$path1"
# return 1
# fi

# if ! git cat-file -e "$v2:$path2" 2>/dev/null; then
# echo "ERROR: File not found at $v2:$path2"
# return 1
# fi

# # Show the diff
# git diff --color "$v1:$path1" "$v2:$path2"
# echo ""
# }

# # Main logic
# if [ $# -eq 2 ]; then
# # Two versions provided - compare them directly
# compare_versions "$1" "$2"
# elif [ $# -eq 0 ]; then
# # No versions provided - compare all consecutive versions
# echo "Fetching all version tags (v1.8.0 and later)..."

# # Get sorted list of version tags >= v1.8.0
# versions=$(git for-each-ref '--format=%(refname:lstrip=-1)' refs/tags/ | \
# grep -iE '^v((([1-9]|[0-9]{2,}).*\.([8-9]|[0-9]{2,}).*)|([2-9]|[0-9]{2,}).*)$' | \
# sort -V)

# # Convert to array
# version_array=($versions)

# # Add main as the last version
# version_array+=("main")

# echo "Found ${#version_array[@]} versions to compare"
# echo ""

# # Compare consecutive versions
# for ((i=0; i<${#version_array[@]}-1; i++)); do
# v1="${version_array[$i]}"
# v2="${version_array[$((i+1))]}"

# compare_versions "$v1" "$v2"

# # Pause after each comparison (optional)
# # read -p "Press Enter to continue to next comparison..."
# done

# echo "========================================"
# echo "Comparison complete!"
# echo "========================================"
# else
# echo "Usage:"
# echo " $0 <version1> <version2> # Compare two specific versions"
# echo " $0 # Compare all consecutive versions"
# echo ""
# echo "Examples:"
# echo " $0 v1.8.0 v1.9.0"
# echo " $0 v1.13.0 main"
# echo " $0"
# exit 1
# fi
set -e

# Get all version tags >= v1.8.0, sorted
versions=$(git for-each-ref '--format=%(refname:lstrip=-1)' refs/tags/ | \
grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | \
sort -V | \
awk -F'[v.]' '{ if ($2 > 1 || ($2 == 1 && $3 >= 8)) print $0 }')
# versions="`git for-each-ref '--format=%(refname:lstrip=-1)' refs/tags/ | grep -iE '^v((([1-9]|[0-9]{2,}).*\.([8-9]|[0-9]{2,}).*)|([2-9]|[0-9]{2,}).*)$'`"

for current_version in ${versions}; do

echo "Processing version: ${current_version}"

done
73 changes: 6 additions & 67 deletions framework/docs/build-versioned-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ cp -r framework/docs/source/_templates ${tmp_dir}/_templates

# Get a list of languages based on the folders in locales
languages="en `find framework/docs/locales/ -mindepth 1 -maxdepth 1 -type d -exec basename '{}' \;`"
# Get a list of tags, excluding those before v1.0.0
versions="`git for-each-ref '--format=%(refname:lstrip=-1)' refs/tags/ | grep -iE '^v((([1-9]|[0-9]{2,}).*\.([8-9]|[0-9]{2,}).*)|([2-9]|[0-9]{2,}).*)$'`"

# Get all version tags >= v1.8.0, sorted
versions=$(git for-each-ref '--format=%(refname:lstrip=-1)' refs/tags/ | \
grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | \
sort -V | \
awk -F'[v.]' '{ if ($2 > 1 || ($2 == 1 && $3 >= 8)) print $0 }')

# Set the numpy version to use for v1.8.0 to v1.12.0
numpy_version_1="1.26.4"
Expand Down Expand Up @@ -72,71 +76,6 @@ for current_version in ${versions}; do

fi

# Only for v1.5.0, update the versions listed in the switcher
if [ "$current_version" = "v1.5.0" ]; then
corrected_versions=$(cat <<-END
html_context['versions'] = list()
versions = sorted(
[
tag.name
for tag in repo.tags
if not tag.name.startswith("intelligence/")
and tag.name[0] == "v"
and int(tag.name[1]) > 0
and int(tag.name.split(".")[1]) >= 8
],
key=lambda x: [int(part) for part in x[1:].split(".")],
)
versions.append("main")
for version in versions:
html_context["versions"].append({"name": version})
END
)
echo "$corrected_versions" >> source/conf.py
fi

if [ "$current_version" = "v1.6.0" ] || \
[ "$current_version" = "v1.7.0" ] || \
[ "$current_version" = "v1.8.0" ] || \
[ "$current_version" = "v1.9.0" ] || \
[ "$current_version" = "v1.10.0" ] || \
[ "$current_version" = "v1.11.0" ] || \
[ "$current_version" = "v1.11.1" ] || \
[ "$current_version" = "v1.12.0" ] || \
[ "$current_version" = "v1.13.0" ] || \
[ "$current_version" = "v1.13.1" ] || \
[ "$current_version" = "v1.14.0" ] || \
[ "$current_version" = "v1.15.0" ] || \
[ "$current_version" = "v1.15.1" ] || \
[ "$current_version" = "v1.15.2" ]; then
awk '
# when we see the start of the old block, switch mode
/html_context\["versions"\] = list\(\)/ {
print "html_context[\"versions\"] = list()"
print "versions = sorted("
print " ["
print " tag.name"
print " for tag in repo.tags"
print " if not tag.name.startswith(\"intelligence/\")"
print " and tag.name[0] == \"v\""
print " and int(tag.name[1]) > 0"
print " and int(tag.name.split(\".\")[1]) >= 8"
print " ],"
print " key=lambda x: [int(part) for part in x[1:].split(\".\")]"
print ")"
print "versions.append(\"main\")"
print "for version in versions:"
print " html_context[\"versions\"].append({\"name\": version})"
skip=1
next
}
# skip lines until we reach a blank line (or some other heuristic)
skip && /^$/ { skip=0 }
skip { next }
{ print }
' source/conf.py > source/conf_new.py && mv source/conf_new.py source/conf.py
fi

# Copy updated version of html files
cp -r ${tmp_dir}/_templates source

Expand Down
18 changes: 13 additions & 5 deletions framework/docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import datetime
import os
import sys
from packaging import version

from git import Repo

Expand Down Expand Up @@ -92,12 +93,19 @@
author = "The Flower Authors"

# The full version of the next release, including alpha/beta/rc tags
release = "1.23.0"
# The current released version
rst_prolog = """
.. |stable_flwr_version| replace:: 1.23.0
if local or current_version == "main":
release = "1.23.0"
else:
release = current_version.lstrip("v")

ubuntu_version = "24.04"
if version.parse(release) < version.parse("1.11.1"):
ubuntu_version = "22.04"

rst_prolog = f"""
.. |stable_flwr_version| replace:: {release}
.. |stable_flwr_superlink_docker_digest| replace:: 4b317d5b6030710b476f4dbfab2c3a33021ad40a0fcfa54d7edd45e0c51d889c
.. |ubuntu_version| replace:: 24.04
.. |ubuntu_version| replace:: {ubuntu_version}
.. |setuptools_version| replace:: 70.3.0
.. |pip_version| replace:: 24.1.2
.. |python_version| replace:: 3.9
Expand Down
Loading