Skip to content

Commit

Permalink
Fix ucxx versioning (#503)
Browse files Browse the repository at this point in the history
  • Loading branch information
AyodeAwe authored Mar 26, 2024
1 parent 8a06ef8 commit b6af951
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 27 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ lib_map.json
.jekyll-cache
.jekyll-metadata
.netlify
__pycache__/
16 changes: 10 additions & 6 deletions ci/customization/customize_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
import json
import os
from bs4 import BeautifulSoup
from util import r_versions

FILEPATH = sys.argv[1]
IS_UCXX_FILE = len(sys.argv) > 2 and sys.argv[2] == "--is-ucxx"

LIB_MAP_PATH = os.path.join(os.path.dirname(__file__), "lib_map.json")
RELEASES_PATH = os.path.join(
Expand All @@ -22,9 +24,11 @@
with open(RELEASES_PATH) as fp:
release_data = json.load(fp)
VERSIONS_DICT = {
"nightly": release_data["nightly"]["version"],
"stable": release_data["stable"]["version"],
"legacy": release_data["legacy"]["version"],
"nightly": release_data["nightly"][
"ucxx_version" if IS_UCXX_FILE else "version"
],
"stable": release_data["stable"]["ucxx_version" if IS_UCXX_FILE else "version"],
"legacy": release_data["legacy"]["ucxx_version" if IS_UCXX_FILE else "version"],
}

SCRIPT_TAG_ID = "rapids-selector-js"
Expand All @@ -40,11 +44,11 @@ def get_version_from_fp():
based on the file path
"""
match = re.search(r"/(\d?\d\.\d\d)/", FILEPATH)
version_number_str = match.group(1)
version_number_str = r_versions(match.group(1))
version_name = "stable"
if version_number_str > VERSIONS_DICT["stable"]:
if version_number_str.is_greater_than(VERSIONS_DICT["stable"]):
version_name = "nightly"
if version_number_str < VERSIONS_DICT["stable"]:
if version_number_str.is_less_than(VERSIONS_DICT["stable"]):
version_name = "legacy"
return {"name": version_name, "number": version_number_str}

Expand Down
6 changes: 5 additions & 1 deletion ci/customization/customize_docs_in_folder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ for FILE in $(grep "${JTD_SEARCH_TERM}\|${DOXYGEN_SEARCH_TERM}\|${PYDATA_SEARCH_
--exclude-dir=legacy \
--exclude-dir=cudf-java \
${FOLDER_TO_CUSTOMIZE} ); do
python ${SCRIPT_SRC_FOLDER}/customize_doc.py $(realpath ${FILE})
if [[ ${FILE} == *"ucxx"* ]]; then
python ${SCRIPT_SRC_FOLDER}/customize_doc.py $(realpath ${FILE}) --is-ucxx
else
python ${SCRIPT_SRC_FOLDER}/customize_doc.py $(realpath ${FILE})
fi
echo "" # line break for readability
done
IFS="$OIFS"
17 changes: 17 additions & 0 deletions ci/customization/util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class r_versions(str):
def compare(self, other: str) -> int:
yearA, monthA = map(int, self.split("."))
yearB, monthB = map(int, other.split("."))

if yearA < yearB or (yearA == yearB and monthA < monthB):
return -1
elif yearA == yearB and monthA == monthB:
return 0
else:
return 1

def is_less_than(self, other: str) -> bool:
return self.compare(other) == -1

def is_greater_than(self, other: str) -> bool:
return self.compare(other) == 1
34 changes: 17 additions & 17 deletions ci/download_from_s3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,26 @@ download_lib_docs() {
SRC VERSION_MAP VERSION_NAME \
VERSION_NUMBER

VERSION_MAP=$(
jq '{
"legacy": .legacy.version,
"stable": .stable.version,
"nightly": .nightly.version
}' _data/releases.json
)
export VERSION_MAP
VERSION_MAP=$(jq '{
"legacy": { "version": .legacy.version, "ucxx_version": .legacy.ucxx_version },
"stable": { "version": .stable.version, "ucxx_version": .stable.ucxx_version },
"nightly": { "version": .nightly.version, "ucxx_version": .nightly.ucxx_version }
}' _data/releases.json)

PROJECT_MAP=$(yq '.apis + .libs' _data/docs.yml)
export PROJECT_MAP


for VERSION_NAME in $(jq -nr 'env.VERSION_MAP | fromjson | keys | .[]'); do
for PROJECT in $(yq -n 'env(PROJECT_MAP) | keys | .[]'); do
export VERSION_NAME PROJECT
VERSION_NUMBER=$(jq -nr 'env.VERSION_MAP | fromjson | .[env.VERSION_NAME]')

if yq -en 'env(PROJECT_MAP) | .[strenv(PROJECT)].versions.[strenv(VERSION_NAME)] == 0' > /dev/null 2>&1; then
echo "skipping: $PROJECT | $VERSION_NAME | $VERSION_NUMBER"
for VERSION_NAME in $(jq -r 'keys | .[]' <<< "$VERSION_MAP"); do
for PROJECT in $(yq -r 'keys | .[]' <<< "$PROJECT_MAP"); do
VERSION_NUMBER=$(jq -r --arg vn "$VERSION_NAME" --arg pr "$PROJECT" '
if ($pr | contains("ucxx")) then
.[$vn].ucxx_version
else
.[$vn].version
end' <<< "$VERSION_MAP")

PROJECT_MAP_JSON=$(yq -r -o json '.' <<< "$PROJECT_MAP")
if [ "$(jq -r --arg pr "$PROJECT" --arg vn "$VERSION_NAME" '.[$pr].versions[$vn]' <<< "$PROJECT_MAP_JSON")" == "0" ]; then
echo "Skipping: $PROJECT | $VERSION_NAME | $VERSION_NUMBER"
continue
fi

Expand Down
20 changes: 17 additions & 3 deletions ci/update_symlinks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,28 @@
set -euEo pipefail

PROJ_ROOT=$(realpath "$(dirname $(realpath $0))/../")
RELEASES="${PROJ_ROOT}/_data/releases.json"

STABLE_FOLDER=$( cat "${PROJ_ROOT}/_data/releases.json" | jq -r '.stable.version')
LEGACY_FOLDER=$( cat "${PROJ_ROOT}/_data/releases.json" | jq -r '.legacy.version')
NIGHTLY_FOLDER=$( cat "${PROJ_ROOT}/_data/releases.json" | jq -r '.nightly.version')
STABLE_VERSION=$(jq -r '.stable.version' < "${RELEASES}")
LEGACY_VERSION=$(jq -r '.legacy.version' < "${RELEASES}")
NIGHTLY_VERSION=$(jq -r '.nightly.version' < "${RELEASES}")

STABLE_UCXX_VERSION=$(jq -r '.stable.ucxx_version' < "${RELEASES}")
LEGACY_UCXX_VERSION=$(jq -r '.legacy.ucxx_version' < "${RELEASES}")
NIGHTLY_UCXX_VERSION=$(jq -r '.nightly.ucxx_version' < "${RELEASES}")

echo "Updating symlinks..."
echo ""
for FOLDER in _site/api/*/ ; do
if [[ "${FOLDER}" == *"ucxx"* ]]; then
STABLE_FOLDER=$STABLE_UCXX_VERSION
LEGACY_FOLDER=$LEGACY_UCXX_VERSION
NIGHTLY_FOLDER=$NIGHTLY_UCXX_VERSION
else
STABLE_FOLDER=$STABLE_VERSION
LEGACY_FOLDER=$LEGACY_VERSION
NIGHTLY_FOLDER=$NIGHTLY_VERSION
fi

cd ${FOLDER}
echo ""
Expand Down

0 comments on commit b6af951

Please sign in to comment.