There are 3 workflows that need to be passed after creating the PR.
This workflow checks if all notebooks are formatted as per black's guidelines. There are two ways to apply black on notebooks.
a) Manually:
$ pip install black[jupyter]==22.3.0 # check this version in requirements-dev.txt
$ black <path/to/notebook>
b) Pre-commit: we have already configured black in pre-commit.yaml
file.
$ pip install pre-commit
$ pre-commit install
After the above configuration, on every commit, pre-commit will run black on modified notebooks.
Gotcha: black_format
workflow checks all the notebooks in the repo, so it may be possible that you have already reformated your notebook but still workflow fails due to an existing un-formated notebook. In this case, you can search unformatted notebooks in logs (see below image) and put a comment mentioning the notebook name.
You need to put import <package>
in try..except ModuleNotFoundError
block. This is only applicable when package
is not in requirements.txt or it is not pre-installed in pip packages.
Example:
This workflow will fail on the following code.
import os
import pandas as pd
import tensorflow_probability as tfp
The above imports should be written as follows:
import os # pre-installed in python
import pandas as pd # available in requirements.txt
try:
import tensorflow_probability as tfp # put try...except
except ModuleNotFoundError:
%pip install -qqq tensorflow_probability # use -qqq flag
import tensorflow_probability as tfp
This workflow execute your notebook.