Skip to content
This repository was archived by the owner on Oct 19, 2024. It is now read-only.

Commit 5afa57b

Browse files
authored
[CI/CD] Store version number in alpa._version__ (#626)
1 parent 504e770 commit 5afa57b

File tree

9 files changed

+238
-170
lines changed

9 files changed

+238
-170
lines changed

.github/workflows/release_alpa.yml

-31
Original file line numberDiff line numberDiff line change
@@ -61,34 +61,3 @@ jobs:
6161
echo "Publish to PyPI"
6262
ls -ltr dist/
6363
python -m twine upload --verbose dist/*
64-
65-
update-version:
66-
runs-on: [ubuntu-latest]
67-
needs: [release-alpa]
68-
steps:
69-
- uses: actions/checkout@v3
70-
71-
- name: Bump VERSION and commit
72-
run: |
73-
git config --local user.email "[email protected]"
74-
git config --local user.name "GitHub Action"
75-
git checkout -b actions/version-bump
76-
cat VERSION | awk -F. -v OFS=. 'NF==1{print ++$NF}; NF>1{$NF=sprintf("%0*d", length($NF), ($NF+1)); print}' > VERSION.tmp && mv VERSION.tmp VERSION
77-
git add VERSION
78-
git commit -m "Bump candidate version [skip ci]"
79-
80-
- name: Push branch
81-
uses: ad-m/github-push-action@master
82-
with:
83-
github_token: ${{ secrets.PAT_TOKEN }}
84-
branch: actions/version-bump
85-
force: true
86-
87-
- name: Create version-bump PR
88-
uses: repo-sync/pull-request@v2
89-
with:
90-
github_token: ${{ secrets.PAT_TOKEN }}
91-
source_branch: "actions/version-bump"
92-
destination_branch: "main"
93-
pr_title: "Bumping VERSION file due to recent release"
94-
pr_body: "*Automated PR*: This should update the candidate version. Please delete source branch upon merge"

GENVER

-130
This file was deleted.

VERSION

-1
This file was deleted.

alpa/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from alpa.shard_parallel.auto_sharding import AutoShardingOption
2727
from alpa.serialization import save_checkpoint, restore_checkpoint
2828
from alpa.timer import timers
29+
from alpa.version import __version__
2930

3031
from . import api
3132
from . import collective

alpa/version.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""Version information."""
2+
3+
__version__ = "1.0.0.dev0"

docker/scripts/build_alpa.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ git fetch origin +${ALPA_BRANCH}
5050
git checkout -qf FETCH_HEAD
5151

5252
# install jaxlib and jax
53-
export VERSION=$(bash GENVER --pep440)
53+
python3 update_version.py --git-describe
5454
python3 setup.py bdist_wheel
5555

5656
if ! python3 -m auditwheel show dist/alpa-*.whl | egrep 'platform tag: "(manylinux2014_x86_64|manylinux_2_17_x86_64)"' > /dev/null; then

docs/conf.py

+15-4
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,22 @@
1616
# -- Project information -----------------------------------------------------
1717

1818
project = 'Alpa'
19-
#copyright = '2022, <Author>'
20-
#author = '<Author>'
19+
author = 'Alpa Developers'
20+
copyright = f'2022, {author}'
2121

22-
# The full version, including alpha/beta/rc tags
23-
release = '0.1.4'
22+
23+
def git_describe_version():
24+
"""Get git describe version."""
25+
ver_py = os.path.join("..", "update_version.py")
26+
libver = {"__file__": ver_py}
27+
exec(compile(open(ver_py, "rb").read(), ver_py, "exec"), libver, libver)
28+
gd_version, _ = libver["git_describe_version"]()
29+
return gd_version
30+
31+
32+
import alpa
33+
version = git_describe_version()
34+
release = version
2435

2536

2637
# -- General configuration ---------------------------------------------------

setup.py

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import glob
22
import os
3+
import re
34
import shutil
45
import subprocess
56
import sys
67

78
from setuptools import setup, find_packages
89

910
IS_WINDOWS = sys.platform == "win32"
11+
ROOT_DIR = os.path.dirname(__file__)
1012

1113

1214
def get_cuda_version(cuda_home):
@@ -98,6 +100,16 @@ def get_cuda_version_str(no_dot=False):
98100
]
99101

100102

103+
def get_alpa_version():
104+
with open(os.path.join(ROOT_DIR, "alpa", "version.py")) as fp:
105+
version_match = re.search(
106+
r"^__version__ = ['\"]([^'\"]*)['\"]", fp.read(), re.M
107+
)
108+
if version_match:
109+
return version_match.group(1)
110+
raise RuntimeError("Unable to find version string.")
111+
112+
101113
def build():
102114
"""Build the custom pipeline marker API."""
103115
# Check cuda version
@@ -169,13 +181,13 @@ def finalize_options(self):
169181
if self.distribution.has_ext_modules():
170182
self.install_lib = self.install_platlib
171183

172-
with open(os.path.join("README.md"), encoding="utf-8") as f:
184+
with open("README.md", encoding="utf-8") as f:
173185
long_description = f.read()
174186

175187
setup(
176188
name="alpa",
177-
version=os.environ.get("VERSION"),
178-
author="Alpa team",
189+
version=get_alpa_version(),
190+
author="Alpa Developers",
179191
author_email="",
180192
description=
181193
"Alpa automatically parallelizes large tensor computation graphs and "

0 commit comments

Comments
 (0)