All things Data Science, learning journey, portfolio projects and all tips and tricks along the way.
This Makefile defines a set of commands to automate tasks related to installing dependencies, running tests, formatting code, and performing linting. Makefiles are used in Unix-based systems to define rules and dependencies for building projects or executing tasks.
Here's a breakdown of the Makefile targets:
-
install:- This target is used to install the required dependencies for the project.
- It runs the following commands:
pip install --upgrade pip: This command upgrades thepippackage manager to the latest version.pip install -r requirements.txt: This command installs the Python dependencies listed in therequirements.txtfile.
-
test:- This target is used to run tests on Jupyter notebooks using the
pytest-nbvalplugin, which allows testing Jupyter notebooks. - It runs the following commands:
python -m pytest --nbval ./pandas/ObesityExploration.ipynb: This command runs tests on theObesityExploration.ipynbJupyter notebook usingpytest.python -m pytest --nbval ./pandas/learning_pandas.ipynb: This command runs tests on thelearning_pandas.ipynbJupyter notebook usingpytest.python -m pytest --nbval ./pandas/portfolio-projects/prob_1_analyze_sales_data.ipynb: This command runs tests on theprob_1_analyze_sales_data.ipynbJupyter notebook located in theportfolio-projectsdirectory usingpytest.
- This target is used to run tests on Jupyter notebooks using the
-
format:- This target is used to format the Python code using the
blackcode formatter. - It runs the
black *.pycommand, which formats all Python files in the current directory.
- This target is used to format the Python code using the
-
lint:- This target is used to perform code linting using
pylint. - It runs the
pylintcommand without specifying a file or directory, which typically means it will check all Python files in the current directory.
- This target is used to perform code linting using
-
all:- This is a special target that specifies a group of tasks that should be executed together when running
make allor simplymake. - The
alltarget includes theinstall,lint, andtesttargets. Therefore, runningmake allwill execute all these tasks in sequence.
- This is a special target that specifies a group of tasks that should be executed together when running
Each target in the Makefile specifies the commands to be executed when that target is called. You can run a specific target by using the make command followed by the target name, for example:
make install
make test
make format
make lint
make all
Makefiles are helpful for automating repetitive tasks in your project workflow, and they are commonly used in software development to streamline build processes, testing, and other routine tasks.