You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

178 lines
5.5KB

  1. .PHONY: clean data lint requirements sync_data_to_s3 sync_data_from_s3
  2. #################################################################################
  3. # GLOBALS #
  4. #################################################################################
  5. PROJECT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
  6. PROFILE = default
  7. PROJECT_NAME = smartissposts
  8. PYTHON_INTERPRETER = python
  9. SH_INTERPRETER = /bin/sh
  10. ifeq (,$(shell which conda))
  11. HAS_CONDA=False
  12. else
  13. HAS_CONDA=True
  14. endif
  15. #################################################################################
  16. # COMMANDS #
  17. #################################################################################
  18. ## Delete all compiled Python files
  19. clean:
  20. find . -path ./mysql -prune -o -type f -name "*.py[co]" -exec rm {} +
  21. find . -path ./mysql -prune -o -type d -name "__pycache__" -exec rm {} +
  22. ## Test python environment is setup correctly
  23. test_environment:
  24. $(PYTHON_INTERPRETER) test_environment.py
  25. ## Write requirements.txt
  26. pipreqs:
  27. pipreqs --force $(PROJECT_DIR)
  28. ## Install Python Dependencies
  29. requirements: test_environment
  30. pip install -U pip setuptools wheel
  31. pip install -r requirements.txt
  32. python -m pip install --upgrade ptvsd
  33. ## debug
  34. debug:
  35. python -m ptvsd --host 0.0.0.0 --port 3000 --wait -m ${m}
  36. ## Write config template
  37. config_template:
  38. $(PYTHON_INTERPRETER) -m iss.tools.config_template
  39. ## start docker
  40. docker_start:
  41. docker-compose up -d
  42. ## stop docker
  43. docker_stop:
  44. docker-compose stop
  45. ## docker exec bash
  46. docker_bash:
  47. docker exec --user=jovyan -it jupyter-iss /bin/bash
  48. #################################################################################
  49. # PROJECT RULES #
  50. #################################################################################
  51. ## Sync photos with my refs
  52. sync_collections: iss/data/sync_collections.sh
  53. /bin/sh iss/data/sync_collections.sh
  54. populate_db:
  55. $(PYTHON_INTERPRETER) -m iss.exec.bdd
  56. sampling:
  57. $(PYTHON_INTERPRETER) -m iss.exec.sampling
  58. training:
  59. $(PYTHON_INTERPRETER) -m iss.exec.training
  60. exec_clustering:
  61. $(PYTHON_INTERPRETER) -m iss.exec.clustering
  62. facets:
  63. $(PYTHON_INTERPRETER) -m iss.exec.facets
  64. posters:
  65. $(PYTHON_INTERPRETER) -m iss.exec.posters --config-id=1 --generate=1 --poster-id='test'
  66. #################################################################################
  67. # OUTSIDE CONTAINER #
  68. #################################################################################
  69. maximize_test:
  70. cp $(PROJECT_DIR)/data/raw/collections/20180211-130001.jpg $(PROJECT_DIR)/data/isr/input/sample/
  71. docker run -v "$(PROJECT_DIR)/data/isr:/home/isr/data" -v "$(PROJECT_DIR)/../image-super-resolution/weights:/home/isr/weights" -v "$(PROJECT_DIR)/config/config_isr.yml:/home/isr/config.yml" -it isr -d -p -c config.yml
  72. maximize_version_3:
  73. cp $(PROJECT_DIR)/data/raw/collections/20170815-130001.jpg $(PROJECT_DIR)/data/isr/input/version_3/
  74. cp $(PROJECT_DIR)/data/raw/collections/20180902-100001.jpg $(PROJECT_DIR)/data/isr/input/version_3/
  75. docker run -v "$(PROJECT_DIR)/data/isr:/home/isr/data" -v "$(PROJECT_DIR)/../image-super-resolution/weights:/home/isr/weights" -v "$(PROJECT_DIR)/config/config_isr.yml:/home/isr/config.yml" -it isr -d -p -c config.yml
  76. #################################################################################
  77. # FLOYDHUB #
  78. #################################################################################
  79. floyd_training:
  80. floyd run --task training
  81. floyd_training_prod:
  82. floyd run --task training_prod
  83. floyd_retraining:
  84. floyd run --task retraining
  85. #################################################################################
  86. # Self Documenting Commands #
  87. #################################################################################
  88. .DEFAULT_GOAL := help
  89. # Inspired by <http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html>
  90. # sed script explained:
  91. # /^##/:
  92. # * save line in hold space
  93. # * purge line
  94. # * Loop:
  95. # * append newline + line to hold space
  96. # * go to next line
  97. # * if line starts with doc comment, strip comment character off and loop
  98. # * remove target prerequisites
  99. # * append hold space (+ newline) to line
  100. # * replace newline plus comments by `---`
  101. # * print line
  102. # Separate expressions are necessary because labels cannot be delimited by
  103. # semicolon; see <http://stackoverflow.com/a/11799865/1968>
  104. .PHONY: help
  105. help:
  106. @echo "$$(tput bold)Available rules:$$(tput sgr0)"
  107. @echo
  108. @sed -n -e "/^## / { \
  109. h; \
  110. s/.*//; \
  111. :doc" \
  112. -e "H; \
  113. n; \
  114. s/^## //; \
  115. t doc" \
  116. -e "s/:.*//; \
  117. G; \
  118. s/\\n## /---/; \
  119. s/\\n/ /g; \
  120. p; \
  121. }" ${MAKEFILE_LIST} \
  122. | LC_ALL='C' sort --ignore-case \
  123. | awk -F '---' \
  124. -v ncol=$$(tput cols) \
  125. -v indent=19 \
  126. -v col_on="$$(tput setaf 6)" \
  127. -v col_off="$$(tput sgr0)" \
  128. '{ \
  129. printf "%s%*s%s ", col_on, -indent, $$1, col_off; \
  130. n = split($$2, words, " "); \
  131. line_length = ncol - indent; \
  132. for (i = 1; i <= n; i++) { \
  133. line_length -= length(words[i]) + 1; \
  134. if (line_length <= 0) { \
  135. line_length = ncol - indent - length(words[i]) - 1; \
  136. printf "\n%*s ", -indent, " "; \
  137. } \
  138. printf "%s ", words[i]; \
  139. } \
  140. printf "\n"; \
  141. }' \
  142. | more $(shell test $(shell uname) = Darwin && echo '--no-init --raw-control-chars')