Download Makefile from Akcom/test: direct link, hf CLI and curl.
- Browser
- Download file 9.53 kB
-
https://huggingface.co/spaces/Akcom/test/resolve/main/Makefile
- Command line
-
hf download hf://spaces/Akcom/test/Makefile
-
curl -L -o Makefile https://huggingface.co/spaces/Akcom/test/resolve/main/Makefile
9.53 kB
| IMAGE_NAME := Akcom/test_clip | |
| RELEASE_BRANCH := release | |
| MAINLINE_BRANCH := master | |
| CURRENT_BRANCH := $(shell git branch | grep \* | cut -d ' ' -f2) | |
| VERSION := 0.0.1 | |
| PYTHON_VER := 3.8 | |
| comma := , | |
| eq = $(if $(or $(1),$(2)),$(and $(findstring $(1),$(2)),\ | |
| $(findstring $(2),$(1))),1) | |
| ########### | |
| # Aliases # | |
| ########### | |
| up: docker.up | |
| down: docker.down | |
| # Build all project artifacts from sources. | |
| # | |
| # Usage: | |
| # make build | |
| build: | docker.build | |
| down: docker.down | |
| up: docker.up | |
| # Resolve all project dependencies. | |
| # | |
| # Usage: | |
| # make deps [dev=(yes|no)] | |
| #deps: | deps.python.wheel deps.python.install | |
| deps: | deps.python.install | |
| ifeq ($(wildcard my.env),) | |
| cp my.dist.env my.env | |
| endif | |
| ################### | |
| # Python commands # | |
| ################### | |
| # Resolve Python project dependencies. | |
| # | |
| # Optional 'cmd' parameter may be used for handy usage of docker-wrapped | |
| # pip, for example: make deps.python cmd='install diffusers' | |
| # | |
| # Usage: | |
| # make deps.python [cmd=(install|<pip-cmd>)] | |
| # [dev=(yes|no)] | |
| # [dockerized=(yes|no)] | |
| pip-cmd = $(if $(call eq,$(cmd),),install --upgrade -r /tmp/requirements.txt,$(cmd)) | |
| # Think about freeze requirements | |
| #pip freeze -r /tmp/requirements.txt > /tmp/requirements.txt && | |
| deps.python.install: | |
| ifneq ($(dockerized),no) | |
| docker run --rm --network=host \ | |
| -e PYTHONPATH=/app/volume/ppath \ | |
| -v "$(PWD)"/docker/rootfs/etc/pip.conf:/etc/pip.conf \ | |
| -v "$(PWD)"/requirements.txt:/tmp/requirements.txt \ | |
| -v "$(PWD)"/volume/.cache/:/app/volume/.cache/ \ | |
| -e CI_SERVER='$(CI_SERVER)' \ | |
| python:$(PYTHON_VER)-slim \ | |
| pip $(pip-cmd) | |
| else | |
| pip $(pip-cmd) | |
| endif | |
| ################### | |
| # Docker commands # | |
| ################### | |
| # Authenticate to GitLab Container Registry where project Docker images | |
| # are stored. | |
| # | |
| # Usage: | |
| # make docker.auth [user=<gitlab-username>] | |
| # [pass-stdin=(no|yes)] | |
| # [cluster=runpod] | |
| ifeq ($(cluster),runpod) | |
| docker_hub_provider = registry.hub.docker.com | |
| else | |
| docker_hub_provider = $(word 1,$(subst /, ,$(IMAGE_NAME))) | |
| endif | |
| docker.auth: | |
| docker login $(docker_hub_provider) \ | |
| $(if $(call eq,$(user),),,--username=$(user)) \ | |
| $(if $(call eq,$(pass-stdin),yes),--password-stdin,) | |
| # Stop project in Dockerized development environment | |
| # and remove all related containers. | |
| # | |
| # Usage: | |
| # make docker.down | |
| docker.down: | |
| docker-compose down --rmi=local -v | |
| # Build project Docker image. | |
| # | |
| # Usage: | |
| # make docker.build [IMAGE=(<empty>|artifacts|<docker-image-postfix>)] | |
| # [TAG=(dev|<tag>)] | |
| # [target=(debug|runtime)] [no-cache=(no|yes)] | |
| # [cluster=runpod] | |
| build-docker-dir = . | |
| build-dockerfile-dir = ./docker/Dockerfile_tensor_gpu | |
| ifeq ($(cluster),runpod) | |
| build-docker-image-name = andreyklumchyk/trdbt$(if $(call eq,$(IMAGE),),,/$(IMAGE)) | |
| else | |
| build-docker-image-name = $(IMAGE_NAME)$(if $(call eq,$(IMAGE),),,/$(IMAGE)) | |
| endif | |
| ifeq ($(IMAGE),artifacts) | |
| build-docker-dir = build/artifacts | |
| endif | |
| docker.build: | |
| docker build --network=host --force-rm \ | |
| -f $(build-dockerfile-dir) \ | |
| $(if $(call eq,$(no-cache),yes),--no-cache,) \ | |
| $(if $(call eq,$(target),),,--target=$(target)) \ | |
| --build-arg VERSION=$(VERSION) \ | |
| -t $(build-docker-image-name):$(if $(call eq,$(TAG),),dev,$(TAG)) \ | |
| $(build-docker-dir)/ | |
| # Push project Docker images to GitLab Container Registry. | |
| # | |
| # Usage: | |
| # make docker.push [IMAGE=(<empty>|artifacts|<docker-image-postfix>)] | |
| # [TAGS=(dev|<t1>[,<t2>...])] | |
| # [cluster=runpod] | |
| docker-push-tags = $(if $(call eq,$(TAGS),),dev,$(TAGS)) | |
| ifeq ($(cluster),runpod) | |
| docker-push-image-name = andreyklumchyk/trdbt$(if $(call eq,$(IMAGE),),,/$(IMAGE)) | |
| else | |
| docker-push-image-name = $(IMAGE_NAME)$(if $(call eq,$(IMAGE),),,/$(IMAGE)) | |
| endif | |
| docker.push: | |
| $(foreach tag,$(subst $(comma), ,$(docker-push-tags)),\ | |
| $(call docker.push.do,$(tag))) | |
| define docker.push.do | |
| $(eval tag := $(strip $(1))) | |
| docker push $(docker-push-image-name):$(tag) | |
| endef | |
| # Pull project Docker images from GitLab Container Registry. | |
| # | |
| # Usage: | |
| # make docker.pull [IMAGE=(<empty>|artifacts|<docker-images-postfix>)] | |
| # [TAGS=(dev|@all|<t1>[,<t2>...])] | |
| docker-pull-image-name = $(IMAGE_NAME)$(if $(call eq,$(IMAGE),),,/$(IMAGE)) | |
| docker-pull-tags = $(if $(call eq,$(TAGS),),dev,$(TAGS)) | |
| docker.pull: | |
| ifeq ($(docker-pull-tags),@all) | |
| docker pull $(docker-pull-image-name) --all-tags | |
| else | |
| $(foreach tag,$(subst $(comma), ,$(docker-pull-tags)),\ | |
| $(call docker.pull.do,$(tag))) | |
| endif | |
| define docker.pull.do | |
| $(eval tag := $(strip $(1))) | |
| docker pull $(docker-pull-image-name):$(tag) | |
| endef | |
| # Tag project Docker image with given tags. | |
| # | |
| # Usage: | |
| # make docker.tag [IMAGE=(<empty>|artifacts|<docker-image-postfix>)] | |
| # [of=(dev|<of-tag>)] [TAGS=(dev|<with-t1>[,<with-t2>...])] | |
| docker-tag-image-name = $(IMAGE_NAME)$(if $(call eq,$(IMAGE),),,/$(IMAGE)) | |
| docker-tag-of = $(if $(call eq,$(of),),dev,$(of)) | |
| docker-tag-with = $(if $(call eq,$(TAGS),),dev,$(TAGS)) | |
| docker.tag: | |
| $(foreach tag,$(subst $(comma), ,$(docker-tag-with)),\ | |
| $(call docker.tag.do,$(docker-tag-of),$(tag))) | |
| define docker.tag.do | |
| $(eval from := $(strip $(1))) | |
| $(eval to := $(strip $(2))) | |
| docker tag $(docker-tag-image-name):$(from) $(docker-tag-image-name):$(to) | |
| endef | |
| # Save project Docker images in a tarball file. | |
| # | |
| # Usage: | |
| # make docker.tar [IMAGE=(<empty>|review|artifacts)] | |
| # [TAGS=(dev|<t1>[,<t2>...])] | |
| docker-tar-image-name = $(IMAGE_NAME)$(if $(call eq,$(IMAGE),),,/$(IMAGE)) | |
| docker-tar-dir = .cache/docker/$(docker-tar-image-name) | |
| docker-tar-tags = $(if $(call eq,$(TAGS),),dev,$(TAGS)) | |
| docker.tar: | |
| @mkdir -p $(docker-tar-dir)/ | |
| $(docker-env) \ | |
| docker save \ | |
| -o $(docker-tar-dir)/$(subst $(comma),_,$(docker-tar-tags)).tar \ | |
| $(foreach tag,$(subst $(comma), ,$(docker-tar-tags)),\ | |
| $(docker-tar-image-name):$(tag)) | |
| # Load project Docker images from a tarball file. | |
| # | |
| # Usage: | |
| # make docker.untar [IMAGE=(<empty>|review|artifacts)] | |
| # [TAGS=(dev|<t1>[,<t2>...])] | |
| docker-untar-image-name = $(IMAGE_NAME)$(if $(call eq,$(IMAGE),),,/$(IMAGE)) | |
| docker-untar-dir = .cache/docker/$(docker-untar-image-name) | |
| docker-untar-tags = $(if $(call eq,$(TAGS),),dev,$(TAGS)) | |
| docker.untar: | |
| $(docker-env) \ | |
| docker load \ | |
| -i $(docker-untar-dir)/$(subst $(comma),_,$(docker-untar-tags)).tar | |
| # Run project in Dockerized development environment. | |
| # | |
| # Usage: | |
| # make docker.up [rebuild=(no|yes)] | |
| docker.up: docker.down | |
| docker-compose up --abort-on-container-exit \ | |
| $(if $(call eq,$(rebuild),yes),--build,) | |
| # Run Bats tests for project Docker image. | |
| # | |
| # Documentation of Bats: | |
| # https://github.com/bats-core/bats-core | |
| # | |
| # Usage: | |
| # make docker.test [IMAGE=(<empty>|review|<docker-image-postfix>)] | |
| # [TAG=(dev|<docker-tag>)] | |
| test-docker-image = $(IMAGE_NAME)$(if $(call eq,$(IMAGE),),,/$(IMAGE)) | |
| test-docker-tag = $(if $(call eq,$(TAG),),dev,$(TAG)) | |
| docker.test: | |
| IMAGE=$(test-docker-image):$(test-docker-tag) \ | |
| node_modules/.bin/bats tests/docker/suite.bats | |
| ################ | |
| # Git commands # | |
| ################ | |
| # Release project version (merge to release branch and apply version tag). | |
| # | |
| # Usage: | |
| # make git.release [VERSION=] | |
| git.release: | |
| ifneq ($(CURRENT_BRANCH),$(MAINLINE_BRANCH)) | |
| @echo "--> Current branch is not '$(MAINLINE_BRANCH)'" && false | |
| endif | |
| git fetch origin --tags $(RELEASE_BRANCH):$(RELEASE_BRANCH) | |
| ifeq ($(shell git rev-parse v$(VERSION) >/dev/null 2>&1 && echo "ok"),ok) | |
| @echo "--> Tag v$(VERSION) already exists" && false | |
| endif | |
| git fetch . $(MAINLINE_BRANCH):$(RELEASE_BRANCH) | |
| git tag v$(VERSION) $(RELEASE_BRANCH) | |
| git push origin $(RELEASE_BRANCH) | |
| git push --tags origin $(RELEASE_BRANCH) | |
| # Squash changes of the current Git branch onto another Git branch. | |
| # | |
| # WARNING: You must merge `onto` branch in the current branch before squash! | |
| # | |
| # Usage: | |
| # make git.squash [onto=] [del=(no|yes)] | |
| onto ?= $(MAINLINE_BRANCH) | |
| del ?= no | |
| upstream ?= origin | |
| git.squash: | |
| ifeq ($(CURRENT_BRANCH),$(onto)) | |
| @echo "--> Current branch is '$(onto)' already" && false | |
| endif | |
| git checkout $(onto) | |
| git branch -m $(CURRENT_BRANCH) orig-$(CURRENT_BRANCH) | |
| git checkout -b $(CURRENT_BRANCH) | |
| git branch --set-upstream-to $(upstream)/$(CURRENT_BRANCH) | |
| git merge --squash orig-$(CURRENT_BRANCH) | |
| ifeq ($(del),yes) | |
| git branch -d orig-$(CURRENT_BRANCH) | |
| endif | |
| ################### | |
| # GitLab commands # | |
| ################### | |
| # Prepare release notes for GitLab release. | |
| # | |
| # Usage: | |
| # make gitlab.release.notes [VERSION=<proj-version>] | |
| # [project-url=(https://gitlab.com/cmn_src/front1|<gitlab-project-url>)] | |
| gitlab-proj-url = $(strip $(if $(call eq,$(project-url),),\ | |
| https://gitlab.com/cmn_src/front1,$(project-url))) | |
| gitlab.release.notes: | |
| @echo "$(strip \ | |
| [Changelog]($(gitlab-proj-url)/-/blob/v$(VERSION)/CHANGELOG.md#$(shell \ | |
| sed -n '/^## \[$(VERSION)\]/{\ | |
| s/^## \[\(.*\)\][^0-9]*\([0-9].*\)/\1-\2/;\ | |
| s/[^0-9a-z-]*//g;\ | |
| p;\ | |
| }' CHANGELOG.md)) | \ | |
| [Milestone]($(gitlab-proj-url)/-/milestones/$(shell \ | |
| sed -n '/^## \[$(VERSION)\]/,/Milestone/{\ | |
| s/.*milestones.\([0-9]*\).*/\1/p;\ | |
| }' CHANGELOG.md)) | \ | |
| [Repository]($(gitlab-proj-url)/-/tree/v$(VERSION)))" | |
| .PHONY: build deps down git.release squash up \ | |
| deps.python.install \ | |
| docker.auth docker.build docker.down docker.pull docker.push \ | |
| docker.tag docker.test docker.up docker.tar docker.untar \ | |
| git.release git.squash gitlab.release.notes | |