From beffd173ea6587dd61241a94cb20ce1711ff65df Mon Sep 17 00:00:00 2001 From: hlts2 Date: Mon, 22 Apr 2024 12:04:16 +0900 Subject: [PATCH 1/3] feat: add make command to support two version deploy Signed-off-by: hlts2 --- Makefile | 52 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index 28e2069..9f9f64c 100755 --- a/Makefile +++ b/Makefile @@ -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 @@ -112,7 +113,21 @@ $(PB2DIR_ROOT): $(PB2PYS): proto/deps $(PB2DIR_ROOT) $(SHADOWS) $(VALD_DIR): - git clone --depth 1 https://$(VALDREPO) $(VALD_DIR) + git clone https://$(VALDREPO) $(VALD_DIR) + +.PHONY: vald/clone +## clone vald repository +vald/clone: $(VALD_DIR) + +.PHONY: vald/checkout +## 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 @@ -121,8 +136,8 @@ 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 ## print VALD_CLIENT_PYTHON_VERSION value @@ -131,25 +146,10 @@ vald/client/python/version/print: .PHONY: vald/client/python/version/update ## update VALD_CLIENT_PYTHON_VERSION value -vald/client/python/version/update: vald +vald/client/python/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 @@ -166,3 +166,13 @@ $(BINDIR)/buf: "https://github.com/bufbuild/buf/releases/download/$$version/buf-$(shell uname -s)-$(shell uname -m)" \ -o "${BINDIR}/buf" && \ chmod +x "${BINDIR}/buf" + +.PHONY: ci/deps +## install deps for CI environment +ci/deps: + sudo apt-get update -y && sudo apt-get install -y \ + python3-setuptools \ + libprotobuf-dev \ + libprotoc-dev \ + protobuf-compiler + pip3 install grpcio-tools From 517879c38ca75ea38a1ff9956be0ddf248b55dca Mon Sep 17 00:00:00 2001 From: hlts2 Date: Thu, 25 Apr 2024 11:42:01 +0900 Subject: [PATCH 2/3] feat: add make command and python version file Signed-off-by: hlts2 --- Makefile | 36 ++++++++++++++++++++++++++++-------- PYTHON_VERSION | 1 + 2 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 PYTHON_VERSION diff --git a/Makefile b/Makefile index 9f9f64c..0688f49 100755 --- a/Makefile +++ b/Makefile @@ -21,8 +21,6 @@ LANGUAGE = python PKGNAME = $(NAME)-client-$(LANGUAGE) PKGREPO = github.com/$(REPO)/$(PKGNAME) -PYTHON = python - VALD_DIR = vald-origin VALD_SHA = VALD_SHA VALD_CLIENT_PYTHON_VERSION = VALD_CLIENT_PYTHON_VERSION @@ -59,6 +57,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" @@ -139,14 +140,14 @@ vald/sha/print: 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_DIR) +vald/client/version/update: $(VALD_DIR) (vald_version=`cat $(VALD_DIR)/versions/VALD_VERSION | sed -e 's/^v//'`; \ echo "VALD_VERSION: $${vald_version}"; \ echo "$${vald_version}" > VALD_CLIENT_PYTHON_VERSION) @@ -167,12 +168,31 @@ $(BINDIR)/buf: -o "${BINDIR}/buf" && \ chmod +x "${BINDIR}/buf" -.PHONY: ci/deps +.PHONY: ci/deps/install ## install deps for CI environment -ci/deps: +ci/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/test +## Execute test for CI environment +ci/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/package/prepare +## prepare package to publish +ci/package/prepare: + python3 setup.py sdist + python3 setup.py bdist_wheel + +.PHONY: version/python +## Print Python version +version/python: + @echo $(PYTHON_VERSION) diff --git a/PYTHON_VERSION b/PYTHON_VERSION new file mode 100644 index 0000000..c8cfe39 --- /dev/null +++ b/PYTHON_VERSION @@ -0,0 +1 @@ +3.10 From d7e25f201b95fc2e1f0b427e8e2e12f087f5b124 Mon Sep 17 00:00:00 2001 From: hlts2 Date: Thu, 25 Apr 2024 16:33:23 +0900 Subject: [PATCH 3/3] fix: deleted unnecessary make command Signed-off-by: hlts2 --- .gitignore | 1 + Makefile | 4 ---- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index f78ec3d..7e2386d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /vald-origin /vald +wordvecs1000.json # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/Makefile b/Makefile index 0688f49..aea417e 100755 --- a/Makefile +++ b/Makefile @@ -116,10 +116,6 @@ $(PB2PYS): proto/deps $(PB2DIR_ROOT) $(SHADOWS) $(VALD_DIR): git clone https://$(VALDREPO) $(VALD_DIR) -.PHONY: vald/clone -## clone vald repository -vald/clone: $(VALD_DIR) - .PHONY: vald/checkout ## checkout vald repository vald/checkout: $(VALD_DIR)