Solution - Git / Installing the notebooks for part 2?

Update - Thanks to James post below, I learned/realized that the dl2 course notebooks currently live under
‘fastai/fastai_docs/dev_course’

and not alongside the first course:
‘fastai/course-v3/nbs/’

where I was expecting it (as dl2)…since that’s where dl1 lives.

hence wasting a lot of time with git when in fact I already had the notebooks, but didn’t realize it.

Original post:
It seems I must be overlooking something but after spending 20 minutes, time to ask here:

What is the proper git command to sync and get the notebooks for the part 2 course?

I can see the notebooks of course here:

But can’t seem to be able to get a local copy to thus work with.

*I’ve updated fastai, tried to clone, etc. the notebooks but they refuse to pull down for me. I also pip installed the dev version ala:
pip install “git+https://github.com/fastai/fastai#egg=fastai[dev]”

Thanks!

1 Like

@LessW2020 whilst folks would love to help you, you’ll need to do more to provide the information needed for that help to be provided. Please review these suggestions:

fyi -
1 - I did search, multiple times in fact -it usually is pulling stuff for other part 2 (ala 2018), etc.
2 - I also included what steps I’ve taken above.

Anyway I’ll go re-read the whole 2019 thread and rewatch the class to see if I missed it somewhere.
Thanks

Hi Less,
What do you mean by “they refuse to pull down for me”?
Do you mind to share the commands and their outputs you see?

Hi Herchu,
I mean that after running a relevant command (which I’ll list below), my fastai folder has nothing contained for the “course-v3/nbs/dl2”…I still have “course-v3/nbs/dl1” but no notebooks for part 2.

I tried as follows:
1 - conda update fastai

2 - git clone https://github.com/fastai/fastai_docs/tree/master/dev_course -
this failed

3 - git clone https://github.com/fastai/fastai_docs
did an update but no change re: v3 part 2 nbs

4 - conda install - c fastai fastai
thought this might force something in but just said all packages installed

5 - pip install “git+https://github.com/fastai/fastai#egg=fastai[dev]”
this installed a few things but again, no v3 part nbs

6 - made a fork and tried to git clone that but said my ‘fastai_docs’ dir was not empty.

7 - Opened a notebook on github directly looking for a ‘download’ option but no luck there.

Anyway, I’m watching the lesson 8 again right now and taking notes. Maybe I missed something but if you have any input I would appreciate it!

Hi Less,

This should get you going. I’d suggest deleting your local copy of fastai_docs or, in the event that you have some local changes there that you’d like to keep, you can just move the repo to a temporary location outside of where you do the following. Also note that the part II is a separate repository from part I. Part I is in the fastai/course-v3 and Part II is in fastai/fastai_docs repo (most likely because it just started and its development is still in progress).

  1. Make sure you aren’t in another repository. i.e. you shouldn’t be in course-v3 at all.
    Note: My setup on most machines is I have a develop folder in my home directory that all my projects/repos live.

  2. git clone https://github.com/fastai/fastai_docs.git

  3. cd fastai_docs

  4. conda activate "Your fastai environment"

  5. jupyter notebook

  6. Browse to dev_course/dl2 in the jupyter notebook file browser.

9 Likes

Thanks James - that was the issue. I already had it from the earlier git commands I tried…but, I was looking for it to be where dl1 was - under course-v3…had no idea it was under the docs section.

Anyway, wasn’t a git issue at all but ‘where it lives’ issue.

Thanks very much!
Less

Glad, thanks to James, it’s working now.

If you need/want to commit your changes to Github the procedure is a bit different. Let me know if you are interested and I’ll post it.

Hi Herchu,
Would definitely be interested in knowing how to commit here, so if you could post that would be very useful!
Thanks very much!
Less

The standard way is to use the “fork-and-branch” workflow. It’s a bit complicated because it allows to manage several use-cases and probably overkill for this course notebooks. There’s a simpler workflow that may work for you.

The general idea is to pull the last version of the notebooks from the official fast.ai repository but push your changes to a remote repository of your own.

In your local repository you will have two branches: master and your own (for example: ‘MY_WORK’). On master there will be the clean, updated fast.ai version, on ‘MY_WORK’ your work along with the fast.ai changes.

Setup

First create an empty repository in your Github. For instance, ‘MY_FASTAI_DOCS’ (you can mark it private if you like.)

$ git clone https://github.com/fastai/fastai_docs
$ cd fastai_docs
$ git branch MY_WORK
$ git checkout MY_WORK
$ git remote add upstream https://github.com/MY_GITHUB_ID/MY_FASTAI_DOCS
$ git remote -v
origin	https://github.com/fastai/fastai_docs (fetch)
origin	https://github.com/fastai/fastai_docs (push)
upstream	https://github.com/MY_GITHUB_ID/MY_FASTAI_DOCS (fetch)
upstream	https://github.com/MY_GITHUB_ID/MY_FASTAI_DOCS (push)
$ git push upstream MY_WORK

Before work (keeping your repo updated)

$ git checkout master
$ git pull origin master
$ git checkout MY_WORK
$ git merge master

Working on your notebooks

$ git checkout MY_WORK # if not already in your branch
... EDIT ...
$ git commit
$ git push upstream MY_WORK

Important: EDIT THE NOTEBOOKS ON A COPY OF THEM. Merging changes in Jupyter notebooks is only for the very braves.
Note: Replace MY_FASTAI_DOCS, MY_WORK and MY_GITHUB_ID with your chosen names.

6 Likes

For completion, here is a full “fork-and-branch” workflow.

Setup

In Github fork fastai_docs. You can change the name of your new repository if you like, but you cannot make it private.

$ git clone https://github.com/MY_GITHUB_ID/fastai_docs
$ cd fastai_docs
$ git remote add upstream https://github.com/fastai/fastai_docs
$ git fetch upstream
$ git pull upstream master
$ git branch MY_BRANCH

Keep your repo in sync with fastai

$ git checkout master
$ git pull upstream master
$ git merge upstream/master

Working on your repo

$ git checkout MY_BRANCH
$ git merge master  # brings fastai changes into your branch.
…EDIT NOTEBOOKS…
$ git commit
$ git push origin MY_BRANCH

Like before replace MY_WORK and MY_GITHUB_ID accordingly (and also your repo name if you had changed)
Again, edit a copy of the notebooks to avoid having to resolve conflicts during merge.

This workflow is ideal if you plan to collaborate with fast.ai or other open source projects.

8 Likes

I set up as per your instruction. It is very useful. Thanks.
Can you recommend any source where I can learn more about git?

Here’s what worked for me:
Forcing myself to add versioning to my little experiments. I’d usually find a way around it because of my laziness but really using it day to day will make you find out all of the fine details and how for ex: Diff branches work, how would you submit a PR to the fastai repo, etc.

Thanks, I will try to do that same :slight_smile:

git is an enormous piece of software and, to be honest, I don’t have the patience to learn it by reading books or similar.
The cool thing is that for everyday tasks knowing just a few thing is enough. For the rest there’s always google :wink:
Anyhow https://help.github.com/en has a lot of info as well as Stackoverflow. In SO you can also find: https://stackoverflow.com/questions/315911/git-for-beginners-the-definitive-practical-guide

Kickstarting a repo may seem overkill at first, but it pays off quickly. You’ll be able to test different approaches easily, go back and forth the changes, review them while keeping a local and a cloud backup. Besides with GitHub you can review your notebooks online without having to start Jupyter and/or the dev environment.

2 Likes

Thanks so much @regrettable-username! This worked for me. Was the information on how to get the notebooks posted elsewhere in this Forum? If so I could not find it.

You’ll find the GitHub repo in https://forums.fast.ai/t/lesson-8-2019-discussion-topic/41323?u=herchu at the “Course notebooks” link.

In the lecture Jeremy mentioned that the notebooks are under dev_course/dl2 directory.

hey, thanks for asking this question! thank god! I was looking for the nb too and wasnt able to find it. I thought I was bit “shy” to ask this question since it just seems that everyone can just figure it out on their own.

I truly meant to say thank you! :slight_smile:

1 Like

Not everyone could just figure it out on their own. I spent a lot of time in perplexity before I stumbled upon this post. The way to get the notebooks was not clearly specified.

3 Likes

I used your solution. Thanks!