Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

Makefile 4.9 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
  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. BUCKET = [OPTIONAL] your-bucket-for-syncing-data (do not include 's3://')
  7. PROFILE = default
  8. PROJECT_NAME = song_predicition
  9. PYTHON_INTERPRETER = python3
  10. ifeq (,$(shell which conda))
  11. HAS_CONDA=False
  12. else
  13. HAS_CONDA=True
  14. endif
  15. #################################################################################
  16. # COMMANDS #
  17. #################################################################################
  18. ## Install Python Dependencies
  19. requirements: test_environment
  20. $(PYTHON_INTERPRETER) -m pip install -U pip setuptools wheel
  21. $(PYTHON_INTERPRETER) -m pip install -r requirements.txt
  22. ## Make Dataset
  23. data: requirements
  24. $(PYTHON_INTERPRETER) src/data/make_dataset.py data/raw data/processed
  25. ## Delete all compiled Python files
  26. clean:
  27. find . -type f -name "*.py[co]" -delete
  28. find . -type d -name "__pycache__" -delete
  29. ## Lint using flake8
  30. lint:
  31. flake8 src
  32. setup:
  33. python3 -m venv ~/.song_predicition
  34. source ~/.song_predicition/bin/activate
  35. # loaddata:
  36. # unzip ./data/external/SpotifyFeatures.csv.zip -d ./data/raw
  37. install:
  38. pip3 install --upgrade pip &&\
  39. pip3 install -r requirements.txt
  40. test:
  41. python3 -m pytest -vv -cov=hello hello_test.py
  42. ## Upload Data to S3
  43. sync_data_to_s3:
  44. ifeq (default,$(PROFILE))
  45. aws s3 sync data/ s3://$(BUCKET)/data/
  46. else
  47. aws s3 sync data/ s3://$(BUCKET)/data/ --profile $(PROFILE)
  48. endif
  49. ## Download Data from S3
  50. sync_data_from_s3:
  51. ifeq (default,$(PROFILE))
  52. aws s3 sync s3://$(BUCKET)/data/ data/
  53. else
  54. aws s3 sync s3://$(BUCKET)/data/ data/ --profile $(PROFILE)
  55. endif
  56. ## Set up python interpreter environment
  57. create_environment:
  58. ifeq (True,$(HAS_CONDA))
  59. @echo ">>> Detected conda, creating conda environment."
  60. ifeq (3,$(findstring 3,$(PYTHON_INTERPRETER)))
  61. conda create --name $(PROJECT_NAME) python=3
  62. else
  63. conda create --name $(PROJECT_NAME) python=2.7
  64. endif
  65. @echo ">>> New conda env created. Activate with:\nsource activate $(PROJECT_NAME)"
  66. else
  67. $(PYTHON_INTERPRETER) -m pip install -q virtualenv virtualenvwrapper
  68. @echo ">>> Installing virtualenvwrapper if not already installed.\nMake sure the following lines are in shell startup file\n\
  69. export WORKON_HOME=$$HOME/.virtualenvs\nexport PROJECT_HOME=$$HOME/Devel\nsource /usr/local/bin/virtualenvwrapper.sh\n"
  70. @bash -c "source `which virtualenvwrapper.sh`;mkvirtualenv $(PROJECT_NAME) --python=$(PYTHON_INTERPRETER)"
  71. @echo ">>> New virtualenv created. Activate with:\nworkon $(PROJECT_NAME)"
  72. endif
  73. ## Test python environment is setup correctly
  74. test_environment:
  75. $(PYTHON_INTERPRETER) test_environment.py
  76. #################################################################################
  77. # PROJECT RULES #
  78. #################################################################################
  79. #################################################################################
  80. # Self Documenting Commands #
  81. #################################################################################
  82. .DEFAULT_GOAL := help
  83. # Inspired by <http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html>
  84. # sed script explained:
  85. # /^##/:
  86. # * save line in hold space
  87. # * purge line
  88. # * Loop:
  89. # * append newline + line to hold space
  90. # * go to next line
  91. # * if line starts with doc comment, strip comment character off and loop
  92. # * remove target prerequisites
  93. # * append hold space (+ newline) to line
  94. # * replace newline plus comments by `---`
  95. # * print line
  96. # Separate expressions are necessary because labels cannot be delimited by
  97. # semicolon; see <http://stackoverflow.com/a/11799865/1968>
  98. .PHONY: help
  99. help:
  100. @echo "$$(tput bold)Available rules:$$(tput sgr0)"
  101. @echo
  102. @sed -n -e "/^## / { \
  103. h; \
  104. s/.*//; \
  105. :doc" \
  106. -e "H; \
  107. n; \
  108. s/^## //; \
  109. t doc" \
  110. -e "s/:.*//; \
  111. G; \
  112. s/\\n## /---/; \
  113. s/\\n/ /g; \
  114. p; \
  115. }" ${MAKEFILE_LIST} \
  116. | LC_ALL='C' sort --ignore-case \
  117. | awk -F '---' \
  118. -v ncol=$$(tput cols) \
  119. -v indent=19 \
  120. -v col_on="$$(tput setaf 6)" \
  121. -v col_off="$$(tput sgr0)" \
  122. '{ \
  123. printf "%s%*s%s ", col_on, -indent, $$1, col_off; \
  124. n = split($$2, words, " "); \
  125. line_length = ncol - indent; \
  126. for (i = 1; i <= n; i++) { \
  127. line_length -= length(words[i]) + 1; \
  128. if (line_length <= 0) { \
  129. line_length = ncol - indent - length(words[i]) - 1; \
  130. printf "\n%*s ", -indent, " "; \
  131. } \
  132. printf "%s ", words[i]; \
  133. } \
  134. printf "\n"; \
  135. }' \
  136. | more $(shell test $(shell uname) = Darwin && echo '--no-init --raw-control-chars')
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...