Create a conda environment with fastai2 requirements, include nbdev.
a) git clone https://github.com/fastai/fastai
b) cd fastai
c) conda env create -f environment.yml
d) source activate fastai
e) pip install -e ".[dev]"
f) Create an editable install of fastcore outside of fastai2 (see docs here)
Run nbdev_install_git_hooks inside the repo folder
Checkout to new feature branch (this is where new feature/bug-fix should be made) git checkout -b <enter--relevant-feature-branch-name>
Make changes to Jupyter Notebook (ie., add tests, update feature, add new feature, add documentation etc.)
Save updated notebook
Run nbdev_build_lib (see Note2 below if this step produces a bug)
Run library tests nbdev_test_nbs
Commit change git commit -m "done with feature"
gh pr create -B master -b "enter body of PR here" -t "enter title"
This command will automatically create a fork for you if youâre in a repository that you donât have permission to push to.
Note: Steps 1-3 need to be only performed once when you fork fastai2 for the first time. In subsequent PRs start from the step 4.
Note2: If you get an error like: No such file or directory: '../fastai2/docs/_config.yml' then you need to clone the fastai-docs repo into the same dir as you have fastai2 in. This is because the docs dir in fastai2 is now a symlink to âŚ/fastai-doc
Confirm PR created
You can confirm that your PR has been created by running gh pr list inside fastai2 folder of your computer. You can also check the status of your PR by running gh pr status. More detailed documentation can be found here.
Updating a PR
If you want to change your code after a PR has been created you can do it by sending more commits to the same remote branch. For example: git checkout -b <enter-branch-name-same-as-before> git commit -m "updated the feature" git push
It will automatically show up in the PR on the github page.
If these are small changes they can be squashed together at the merge time and appear as a single commit in the repository.
Merging a PR
This is done by the project maintainers so nothing more for you to do, youâll see a notification on github when the PR gets merged and closed.
Workaround for authenticating on headless environments
The first time you submit a PR youâll be asked to authroize gh to work on your behalf (e.g., create forks as needed, submit PRs, etcâŚ). If you are working on a remote server (a.k.a headless environment), as I suspect most will be, follow the instructions here to complete the steps required.
Can I please request you to make the thread a wiki so that anyone can edit and we can have a complete list of steps for everyone to follow including myself
I am polishing the scripts but whenever anyone submit a PR, it will be expected that the local library and notebooks match. If you made a change to the notebooks in one of the exported cells, you can export it to the library with notebook2script.py, if you made a change to the library, you can export it back to the notebooks with script2notebook.py.
The script diff_nb_script.py can let you know if there is a difference (and will be included in the CI early next week).
I am not sure what CI/CD tools fastai is using, but GitHub Actions has a hook for on.pull_request where you can run a shell script and check for stripped notebook. I was trying to see if I can get that to run the tests described in README, but it doesnât have GPU and not great for testing.
Itâs best when each separate PR has a separate commit history, otherwise itâs a bit harder to merge since the PR has a whole bunch of unrelated stuff in it.
Just made my first PR using hub â like arora_aman, I think I still messed it up. A couple issues that came up in the process:
I notice that git add isnât part of the instructions. I assumed I should add both the notebook and the script that it changed⌠is this right?
When running python run_notebook.py -- fn <notebook> I got this error:
Traceback (most recent call last):
File ârun_notebook.pyâ, line 18, in
slow:Param(âRun slow testsâ, bool)=False, cpp:Param(âRun tests that require c++ extensionsâ, bool)=False):
File â/home/t/fastai_dev/dev/local/core/script.pyâ, line 39, in call_parse
func(**args.dict)
File ârun_notebook.pyâ, line 24, in main
for f in sorted(fns): test_nb(f, flags=flags)
File â/home/t/fastai_dev/dev/local/notebook/test.pyâ, line 113, in test_nb
raise e
File â/home/t/fastai_dev/dev/local/notebook/test.pyâ, line 110, in test_nb
ep.preprocess(pnb)
TypeError: preprocess() missing 1 required positional argument: âresourcesâ
Which I didnât know what to do with, but it meant that I wasnât able to run the built-in tests.
Iâd like to suggest a little change to Hook - should I do this with a pull request, issue or something else?
Looks like run-after-git-clone was removed Nov 2019 - any chance these instructions can be updated? (⌠I canât find nbdev_install_git_hooks either :o)
Cheers,
Pete
I edited the wiki to make use of nbdev. Probably using hub we can remove some of the intermediate steps of branching, it should take care of this. (as when you edit a file on the github website and submit a PR)