Python project manager ▪ Package version manager ▪ Virtual environment wrapper ▪ Easy to create package command: replace `entry_points` of `setup.py` ▪ Easy to publish the package: you can publish packages to PyPi by `poetry publish` git Version control system make Usually it is used to compile, while I use it as a task runner 2
shell scripts instead of typing commands directly. ▪ Pay attention to tool version, OS, environment variables, etc. e.g., If you use `mosestokenizer.perl`, you should check the following: • LANG=C or LANG=en_US.UTF-8 ? • `perl` or `perl -C` (unicode switch) ? • the RELEASE-4.0 version or the HEAD of master branch? • whether to use `-a` (aggresive hyphen split) option or not. ▪ The above misc problems may be avoided by writing shell scripts. 3
▪ Use bash instead of sh. (Avoid to use `/bin/sh`.) ▪ Environment variables (`export A="aa"`) and shell variables (`A="aa"`) are different. ▪ Note that GNU and BSD (including macOS) commands are different. ▪ Use `set -eu` to stop the script when unexpected errors are occured. ▪ Use the bash built-in commands, especially `[[ ]]` instead of `[ ]`. • [ a.out = $FNAME ] returns error when $FNAME is empty. ▪ Don’t hard-code absolute path. • Maybe `pwd`, `$HOME`, `$0` are useful. 4
docs (docstring) and unit tests would help you. ▪ I use `rsync` for small debugging on remote servers. https://github.com/de9uch1/git-rsync ▪ I use `ptpython`, a rich Python REPL. ▪ Keep it simple. • The UNIX philosophy ¹, originated by Ken Thompson and Dennis Ritchie. ¹https://en.wikipedia.org/wiki/Unix_philosophy 5
can define the dependency between files and procedures. ▪ If the target file is already created, the task will not be run. • It can also compare the file timestamp. ▪ (No additional requirements.) Cons ▪ The syntax is too bad complicated and hacky. ▪ If there is a modern task runner that satisfies my functional requirements, I’d like to switch… 6
the dependency between files and procedures. ▪ Run a task defined as PHONY target with specified options: • make BEAM_SIZE=5 generate 1 $(RESULT_FILE): $(NMT_MODEL) # define the dependency by `target: source`. 2 mkdir -p $(@D)/ # $(@D) means the target directory. 3 fairseq-generate \ 4 --path $< \ # $< means the source file. 5 --beam $(BEAM_SIZE) --lenpen 1.0 \ 6 $(DATA_BIN_DIR) \ 7 > $@ # $@ means the target file. 8 9 .PHONY: generate # define as a dummy target 10 generate: $(RESULT_FILE) 7
message described by `##`-prefixed comments. ▪ GNU-like long option: Options can be passed by `--abc xyz` instead of `ABC=xyz`. ▪ No additional requirements: No additional packages are required, and also standalone `make` is executable. 9