Skip to content

Commit

Permalink
[vald-client-python]: Use vald-client-ci workflows for release and e2e (
Browse files Browse the repository at this point in the history
#284)

* feat: introduce two version support feature

Signed-off-by: hlts2 <[email protected]>

* fix: refactor and add debug job for build and test

Signed-off-by: hlts2 <[email protected]>

* fix: deleted debug job for e2e and build proto

Signed-off-by: hlts2 <[email protected]>

---------

Signed-off-by: hlts2 <[email protected]>
  • Loading branch information
hlts2 authored May 7, 2024
1 parent d8fa4dd commit 9836844
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ jobs:
# - uses: vdaas/vald-client-ci/.github/actions/e2e@main
- uses: vdaas/vald-client-ci/.github/actions/e2e@feat/add-common-workflows
with:
client_type: node
client_type: python
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ jobs:
# uses: vdaas/vald-client-ci/.github/workflows/_release.yaml@main
uses: vdaas/vald-client-ci/.github/workflows/_release.yaml@feat/add-common-workflows
with:
client_type: node
client_type: python
secrets: inherit
2 changes: 1 addition & 1 deletion .github/workflows/sync.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
# uses: vdaas/vald-client-ci/.github/workflows/sync.yaml@main
uses: vdaas/vald-client-ci/.github/workflows/sync.yaml@feat/add-common-workflows
with:
client_type: node
client_type: python
secrets:
CI_USER: ${{ secrets.DISPATCH_USER }}
CI_TOKEN: ${{ secrets.DISPATCH_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/vald-origin
/vald
wordvecs1000.json

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
95 changes: 64 additions & 31 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ PYTHON = python
VALD_DIR = vald-origin
VALD_SHA = VALD_SHA
VALD_CLIENT_PYTHON_VERSION = VALD_CLIENT_PYTHON_VERSION
VALD_CHECKOUT_REF ?= main

BINDIR ?= /usr/local/bin

Expand Down Expand Up @@ -58,6 +59,9 @@ PB2PYS = $(PROTOS:$(PROTO_ROOT)/%.proto=$(PB2DIR_ROOT)/$(SHADOW_ROOT)/%_pb2.py)

MAKELISTS = Makefile

PYTHON_VERSION := $(eval PYTHON_VERSION := $(shell cat PYTHON_VERSION))$(PYTHON_VERSION)
TEST_DATASET_PATH = wordvecs1000.json

red = /bin/echo -e "\x1b[31m\#\# $1\x1b[0m"
green = /bin/echo -e "\x1b[32m\#\# $1\x1b[0m"
yellow = /bin/echo -e "\x1b[33m\#\# $1\x1b[0m"
Expand Down Expand Up @@ -109,10 +113,19 @@ $(SHADOW_PROTO_ROOT)/%.proto: $(PROTO_ROOT)/%.proto
$(PB2DIR_ROOT):
mkdir -p $@

$(PB2PYS): proto/deps $(PB2DIR_ROOT) $(SHADOWS)
$(PB2PYS): proto/deps/install $(PB2DIR_ROOT) $(SHADOWS)

$(VALD_DIR):
git clone --depth 1 https://$(VALDREPO) $(VALD_DIR)
git clone https://$(VALDREPO) $(VALD_DIR)

## checkout vald repository
vald/checkout: $(VALD_DIR)
cd $(VALD_DIR) && git checkout $(VALD_CHECKOUT_REF)

.PHONY: vald/origin/sha/print
## print origin VALD_SHA value
vald/origin/sha/print: $(VALD_DIR)
@cd $(VALD_DIR) && git rev-parse HEAD | tr -d '\n'

.PHONY: vald/sha/print
## print VALD_SHA value
Expand All @@ -121,48 +134,68 @@ vald/sha/print:

.PHONY: vald/sha/update
## update VALD_SHA value
vald/sha/update: vald
(cd vald; git rev-parse HEAD | tr -d '\n' > ../$(VALD_SHA))
vald/sha/update: $(VALD_DIR)
(cd $(VALD_DIR); git rev-parse HEAD | tr -d '\n' > ../$(VALD_SHA))

.PHONY: vald/client/python/version/print
.PHONY: vald/client/version/print
## print VALD_CLIENT_PYTHON_VERSION value
vald/client/python/version/print:
vald/client/version/print:
@cat $(VALD_CLIENT_PYTHON_VERSION)

.PHONY: vald/client/python/version/update
.PHONY: vald/client/version/update
## update VALD_CLIENT_PYTHON_VERSION value
vald/client/python/version/update: vald
vald/client/version/update: $(VALD_DIR)
(vald_version=`cat $(VALD_DIR)/versions/VALD_VERSION | sed -e 's/^v//'`; \
client_version=`cat $(VALD_CLIENT_PYTHON_VERSION)`; \
major=$${client_version%%.*}; client_version="$${client_version#*.}"; \
minor=$${client_version%%.*}; client_version="$${client_version#*.}"; \
patch=$${client_version%%.*}; client_version="$${client_version#*.}"; \
if [ "$${vald_version}" = "$${major}.$${minor}.$${patch}" ]; then \
if [ "$${patch}" = "$${client_version}" ]; then \
new_version="$${major}.$${minor}.$${patch}.post1"; \
else \
rev="$${client_version#post}"; \
rev=$$((rev+1)); \
new_version="$${major}.$${minor}.$${patch}.post$${rev}"; \
fi; \
else \
new_version="$${vald_version}"; \
fi; \
echo "VALD_VERSION: $${vald_version}, NEW_CLIENT_VERSION: $${new_version}"; \
echo "$${new_version}" > VALD_CLIENT_PYTHON_VERSION)
echo "VALD_VERSION: $${vald_version}"; \
echo "$${vald_version}" > VALD_CLIENT_PYTHON_VERSION)
sed -i -e "s/^version = .*\$$/version = `cat VALD_CLIENT_PYTHON_VERSION`/" setup.cfg

.PHONY: proto/deps
.PHONY: test
## Execute test
test: $(TEST_DATASET_PATH)
python src/test.py

$(TEST_DATASET_PATH):
curl -L https://raw.githubusercontent.com/rinx/word2vecjson/master/data/wordvecs1000.json -o $(TEST_DATASET_PATH)

.PHONY: ci/deps/install
## install deps for CI environment
ci/deps/install: proto/deps/install
sudo apt-get update -y && sudo apt-get install -y \
python3-setuptools \
libprotobuf-dev \
libprotoc-dev \
protobuf-compiler
pip3 install grpcio-tools

.PHONY: ci/deps/update
## update deps for CI environment
ci/deps/update:
@echo "Nothing do be done"

.PHONY: ci/package/prepare
## prepare package to publish
ci/package/prepare:
python3 setup.py sdist
python3 setup.py bdist_wheel

.PHONY: ci/package/publish
## publich packages
ci/package/publish:
@echo "Nothing do be done"

.PHONY: proto/deps/install
## install proto deps
proto/deps: buf/install

.PHONY: buf/install
## install buf command.
buf/install: $(BINDIR)/buf
proto/deps/install: $(BINDIR)/buf

$(BINDIR)/buf:
@version=$$(curl -sSL $(BUF_VERSION_URL)); \
curl -sSL \
"https://github.com/bufbuild/buf/releases/download/$$version/buf-$(shell uname -s)-$(shell uname -m)" \
-o "${BINDIR}/buf" && \
chmod +x "${BINDIR}/buf"

.PHONY: version/python
## Print Python version
version/python:
@echo $(PYTHON_VERSION)
1 change: 1 addition & 0 deletions PYTHON_VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.10

0 comments on commit 9836844

Please sign in to comment.