pkeilbach / htwg-practical-nlp

A practical course on natural language processing @ HTWG Konstanz.
https://pkeilbach.github.io/htwg-practical-nlp/
8 stars 3 forks source link

Check dependencies in `Makefile` #135

Open pkeilbach opened 2 weeks ago

pkeilbach commented 2 weeks ago

Previously the make commands for Jupyter, Mkdocs, and Pytest, were dependent on the project, i.e. every time you executed make docs, the full setup was run:

docs: project
    .venv/bin/mkdocs serve

On the one hand this was good, because it made sure that the requirements are up to date before executing the command.

On the other hand, this was very time consuming, so I decided to remove this dependency. So now, the command is much faster, because it assumes that the project was setup correctly and does not check on requirements:

docs:
    .venv/bin/mkdocs serve

However, I want to make it more evident that the user needs to execute make before this command can be executed. So ideally, if the dependency is not fulfilled, the user should get a message on the console to execute make.

This could be as simple as

docs:
    .venv/bin/mkdocs serve || echo "You need to execute 'make' first"

However, this would mean to repeat the or clause || in all mentioned commands.

So the plan is to avoid repetition and implement the following approach, which is the scope of this issue:

# General check for any tool in .venv/bin
check-tool:
    @if [ ! -f .venv/bin/$(tool) ]; then \
        echo "You need to execute 'make' first to install dependencies"; \
        exit 1; \
    fi

# Target to run Jupyter notebook
jupyter: tool=jupyter
jupyter: check-tool
    .venv/bin/jupyter notebook --no-browser

It should work for every command below the jupyter command. You can search for TODO issue-135 in the code. Dependent on #134 .