<commit_before>CONFIG ?=	docker-compose.yml
SERVICES ?=	$(shell cat docker-compose.yml | grep '^[a-z]' | cut -d: -f1)
# By default $(SERVICE) is the first service in docker-compose.yml
SERVICE ?=	$(shell echo $(SERVICES) | tr " " "\n" | head -1)
S3_URL ?= 	s3://pathwar-levels/
PACKAGE_NAME ?=	package-$(shell basename $(shell pwd)).tar
EXCLUDES ?=	$(PACKAGE_NAME) .git
ASSETS ?=	$(filter-out $(EXCLUDES),$(wildcard *))
PKGLVL ?=	/tmp/package_level
DOCKER_COMPOSE ?=	docker-compose -p$(USER)_$(shell basename $(shell pwd) | sed 's/[^a-z]//g')
S3CMD ?=	s3cmd
SECTIONS ?=	$(shell cat $(CONFIG) | grep -E '^[a-z]' | cut -d: -f1)
MAIN_SECTION ?=	$(shell echo $(SECTIONS) | cut -d\  -f1)
MAIN_CID :=	$(shell $(DOCKER_COMPOSE) ps -q $(MAIN_SECTION))
EXEC_MAIN_SECTION :=	docker exec -it $(MAIN_CID)


## Actions
all: up ps logs
.PHONY: all build run shell package publish_on_s3 info


shellmysql:
	docker run -it --rm orchardup/mysql mysql -h$(shell docker inspect -f '{{ .NetworkSettings.IPAddress }}' $(shell $(DOCKER_COMPOSE) ps -q mysql))


info: before
	@echo "ASSETS:        $(ASSETS)"
	@echo "EXLUDES:       $(EXCLUDES)"
	@echo "PACKAGE_NAME:  $(PACKAGE_NAME)"
	@echo "S3_URL:        $(S3_URL)"
	@echo "SERVICE:       $(SERVICE)"
	@echo "SERVICES:      $(SERVICES)"


before::


kill stop rm:: before
	$(DOCKER_COMPOSE) kill $(SECTIONS)
	$(DOCKER_COMPOSE) stop $(SECTIONS)
	$(DOCKER_COMPOSE) rm --force $(SECTIONS)


re:: stop up<commit_msg>Add 'make unix_run'<commit_after>CONFIG ?=	docker-compose.yml
SERVICES ?=	$(shell cat docker-compose.yml | grep '^[a-z]' | cut -d: -f1)
# By default $(SERVICE) is the first service in docker-compose.yml
SERVICE ?=	$(shell echo $(SERVICES) | tr " " "\n" | head -1)
S3_URL ?= 	s3://pathwar-levels/
PACKAGE_NAME ?=	package-$(shell basename $(shell pwd)).tar
EXCLUDES ?=	$(PACKAGE_NAME) .git
ASSETS ?=	$(filter-out $(EXCLUDES),$(wildcard *))
PKGLVL ?=	/tmp/package_level
DOCKER_COMPOSE_NAME ?=	$(USER)$(shell basename $(shell pwd) | sed 's/[^a-z]//g')
DOCKER_COMPOSE ?=	docker-compose -p$(DOCKER_COMPOSE_NAME)
S3CMD ?=	s3cmd
SECTIONS ?=	$(shell cat $(CONFIG) | grep -E '^[a-z]' | cut -d: -f1)
MAIN_SECTION ?=	$(shell echo $(SECTIONS) | cut -d\  -f1)
MAIN_CID :=	$(shell $(DOCKER_COMPOSE) ps -q $(MAIN_SECTION))
EXEC_MAIN_SECTION :=	docker exec -it $(MAIN_CID)
UNIX_USER ?=	bobby


## Actions
all: up ps logs
.PHONY: all build run shell package publish_on_s3 info


shellmysql:
	docker run -it --rm orchardup/mysql mysql -h$(shell docker inspect -f '{{ .NetworkSettings.IPAddress }}' $(shell $(DOCKER_COMPOSE) ps -q mysql))


unix_run: build
	docker run $(DOCKER_COMPOSE_NAME)_$(MAIN_SECTION)
	docker commit `docker ps -lq` tmp
	docker run -it --rm -u $(UNIX_USER) tmp level-enter


info: before
	@echo "ASSETS:        $(ASSETS)"
	@echo "EXLUDES:       $(EXCLUDES)"
	@echo "PACKAGE_NAME:  $(PACKAGE_NAME)"
	@echo "S3_URL:        $(S3_URL)"
	@echo "SERVICE:       $(SERVICE)"
	@echo "SERVICES:      $(SERVICES)"


before::


kill stop rm:: before
	$(DOCKER_COMPOSE) kill $(SECTIONS)
	$(DOCKER_COMPOSE) stop $(SECTIONS)
	$(DOCKER_COMPOSE) rm --force $(SECTIONS)


re:: stop up
{'fraction_non_alphanumeric': 0.17711346833815494, 'fraction_numerical': 0.007071681131468981, 'mean_word_length': 4.178036605657238, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3470832', 'n_tokens_mistral': 1336, 'n_tokens_neox': 1237, 'n_words': 322}