-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
166 lines (120 loc) · 4.95 KB
/
Makefile
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
159
160
161
162
163
164
165
166
# Makefile for linguistic processing for newspapers
# Read the README.md for more information on how to use this Makefile.
# Or run `make` for online help.
###
# SETTINGS FOR THE MAKE PROGRAM
# Define the shell to use for executing commands
SHELL := /bin/dash
# Enable strict error handling
export SHELLOPTS := errexit:pipefail
# Keep intermediate files generated for the build process
.SECONDARY:
# Delete intermediate files if the target fails
.DELETE_ON_ERROR:
# Suppress all default rules
.SUFFIXES:
# A variable for representing an empty string
EMPTY :=
$(call log.debug, EMPTY)
###
# SETTINGS FOR THE BUILD PROCESS
# Load local config if it exists (ignore silently if it does not exist)
-include config.local.mk
# Load our make logging functions
include cookbook/log.mk
# Set the logging level: DEBUG, INFO, WARNING, ERROR
LOGGING_LEVEL ?= INFO
$(call log.info, LOGGING_LEVEL)
# Keep make output concise for longish recipes
ifeq "$(filter DEBUG,$(LOGGING_LEVEL))" "DEBUG"
$(call log.debug, LOGGING_LEVEL)
MAKE_SILENCE_RECIPE ?= $(EMPTY)
else
MAKE_SILENCE_RECIPE ?= @
endif
$(call log.debug, MAKE_SILENCE_RECIPE)
# Set the number of parallel launches of newspapers (uses xargs)
# Note: For efficient parallelization the number of cores should be PARALLEL_NEWSPAPERS * MAKE_PARALLEL_PROCESSING_NEWSPAPER_YEAR
PARALLEL_NEWSPAPERS ?= 1
$(call log.debug, PARALLEL_NEWSPAPERS)
# Set the number of parallel jobs of newspaper-year files to process
MAKE_PARALLEL_PROCESSING_NEWSPAPER_YEAR ?= 1
$(call log.debug, MAKE_PARALLEL_PROCESSING_NEWSPAPER_YEAR)
# Get the current git version
ifndef git_version
git_version := $(shell git describe --tags --always)
endif
$(call log.info, git_version)
export git_version
###
# SETTING DEFAULT VARIABLES FOR THE PROCESSING
# The build directory where all local input and output files are stored
# The content of BUILD_DIR can be removed anytime without issues regarding s3
BUILD_DIR ?= build.d
$(call log.debug, BUILD_DIR)
# Specify the newspaper to process. Just a suffix appended to the s3 bucket name
# is ok! Can also be something like actionfem/actionfem-1933 to restrict further
NEWSPAPER ?= actionfem
$(call log.info, NEWSPAPER)
# Help: Show this help message
help:
@echo "Usage: make <target>"
@echo "Targets:"
@echo " setup # Prepare the local directories"
@echo " collection # Call make all for each newspaper found in the file $(NEWSPAPERS_TO_PROCESS_FILE)"
@echo " all # Resync the data from the S3 bucket to the local directory and process all years of a single newspaper"
@echo " newspaper # Process a single newspaper for all years"
@echo " sync # Sync the data from the S3 bucket to the local directory"
@echo " resync # Remove the local synchronization file stamp and sync again."
@echo " clean-build # Remove the entire build directory"
@echo " clean-newspaper # Remove the local directory for a single newspaper"
@echo " update-requirements # Update the requirements.txt file with the current pipenv requirements."
@echo " lb-spacy-package # Package the Luxembourgish spaCy model"
@echo " help # Show this help message"
.DEFAULT_GOAL := help
PHONY_TARGETS += help
###
# INCLUDES AND CONFIGURATION FILES
#------------------------------------------------------------------------------
# Load newspaper list configuration and processing rules
include cookbook/newspaper_list.mk
# Load input path definitions for rebuilt content
include cookbook/paths_rebuilt.mk
# Load input path definitions for language identification
include cookbook/paths_langident.mk
# Load output path definitions for linguistic processing
include cookbook/paths_lingproc.mk
# Load general setup
include cookbook/setup.mk
# Load setup rules for linguistic processing
include cookbook/setup_lingproc.mk
###
# MAIN TARGETS
#------------------------------------------------------------------------------
include cookbook/main_targets.mk
###
# SYNCHRONIZATION TARGETS
#------------------------------------------------------------------------------
# Synchronize both input and output data with S3
sync: sync-input sync-output
PHONY_TARGETS += sync
# Include synchronization rules for rebuilt content
include cookbook/sync_rebuilt.mk
# Include synchronization rules for linguistic processing output
include cookbook/sync_lingproc.mk
# Include cleanup rules
include cookbook/clean.mk
###
# PROCESSING TARGETS
#------------------------------------------------------------------------------
# Include main linguistic processing rules
include cookbook/processing_lingproc.mk
###
# FINAL DECLARATIONS AND UTILITIES
#------------------------------------------------------------------------------
# Declare all targets that don't produce files
.PHONY: $(PHONY_TARGETS)
# Include path conversion utilities
include cookbook/local_to_s3.mk
# Include testing and inspection utilities
include cookbook-repo-addons/test_eyeball_lingproc.mk