Beginner: Python, git, bash, etc ✅

If you need help with foundational technologies for the course, like getting your python code to work, using git, working at the command line, etc, post here!

2 Likes

Noob Q: GitHub desktop isn’t supported for Ubuntu-do you all have any favourite or suggested alternatives?

TIA! :slight_smile:

1 Like

It looks possible to use Github Desktop with Ubuntu as well. Personally I haven’t used it though

Like Jeremy just showed, VS Code has a lot of Git features too, and I often use Git through that actually…
Don’t know how the features compare though…

6 Likes

I use Ubuntu-based distros and use the VSCodium and Github CLI. The prior being easier to use.

Folks using github don’t even need an IDE to edit their Jekyll/HTML code … you can use the cloud based VSCode via github like this:

  1. Go to your github repo (e.g., GitHub - fastai/tinypets: Minimal JS interface to an image classifer)

  2. Click the period key, .

Your repo will open up in the cloud based version of VSCode. From there, you can make your edits, commit them using the IDE, and build out your site without ever having to install or work in an IDE locally.

This is how I built out my fastpages based site, ohmeow.com

5 Likes

Yeah, good point! I liked this feature, too. Also, it is a quite convenient method to set up tutorials or workshops, as one doesn’t need any local environment but can work in browser instead.

Or you can even click the Edit button in GitHub, and it’ll open up their basic editor in a textbox.

2 Likes

Some of my colleagues speak highly of GitKraken, esp. when it comes to integrations with Git hosting providers. I’m a command line and magit(in emacs) person myself. I’ve also used Gitg in the past & sometimes used tig(terminal ui).

2 Likes

Ah yes, if you’re already using vscode like mentioned above, the built-in stuff is pretty great too.

lazygit is a nice terminal TUI app for git

Problems with nbdev’s notebook2script module. The line

notebook2script('app.ipynb')

I get the error:

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
Input In [28], in <cell line: 1>()
----> 1 notebook2script('app.ipynb')

File ~\anaconda3\lib\site-packages\nbdev\export.py:438, in notebook2script(fname, silent, to_dict, bare)
    436     update_version()
    437     update_baseurl()
--> 438 files = nbglob(fname=fname)
    439 d = collections.defaultdict(list) if to_dict else None
    440 modules = create_mod_files(files, to_dict, bare=bare)

File ~\anaconda3\lib\site-packages\nbdev\export.py:422, in nbglob(fname, recursive, extension, config_key)
    420 fname = Path(fname or get_config().path(config_key))
    421 if fname.is_file(): return [fname]
--> 422 if recursive == None: recursive=get_config().get('recursive', 'False').lower() == 'true'
    423 if fname.is_dir(): pat = f'**/*{extension}' if recursive else f'*{extension}'
    424 else: fname,_,pat = str(fname).rpartition(os.path.sep)

File ~\anaconda3\lib\site-packages\nbdev\imports.py:29, in get_config(cfg_name)
     27 cfg_path = Path.cwd()
     28 while cfg_path != cfg_path.parent and not (cfg_path/cfg_name).exists(): cfg_path = cfg_path.parent
---> 29 config = Config(cfg_path, cfg_name=cfg_name)
     30 _add_new_defaults(config.d, config.config_file,
     31         host="github", doc_host="https://%(user)s.github.io", doc_baseurl="/%(lib_name)s/")
     32 return config

File ~\anaconda3\lib\site-packages\fastcore\foundation.py:260, in Config.__init__(self, cfg_path, cfg_name, create)
    258         cfg_path.mkdir(exist_ok=True, parents=True)
    259         self.save()
--> 260     else: raise FileNotFoundError(f"Could not find {cfg_name}")
    261 self.d = read_config_file(self.config_file)

FileNotFoundError: Could not find settings.ini

I’d appreciate any help.

What version of nbdev do you have? Try upgrading it pip install nbdev --upgrade

I had nbdev version 1.2.8 installed. I ran the upgrade, but it seems this is the latest version.

The error is complaining about a missing settings.ini file. I’m not super familiar with nbdev, but you could try putting this file in the directory that notebook2script is running in.

I think nbdev expects to be run from the nvdev_template repo.

1 Like

The latest version doesn’t require settings.ini. My guess is in this case there’s a 2nd install of jupyter in system python that’s getting in the way.

2 Likes

Thank you @lex ! I ran it outside of the ndev repo and it’s working now :slight_smile:

How to prevent .git folder to grow too large?

I have been working on a repo of mine for weeks. Without the .git folder, the repo is about 4MB, but the .git folder itself is about 200MB. I looked inside of it and removed two of the largest which are folders named a8 and pack, but then I can’t do git push many more.

I know I can use .gitignore file to stop pushing images and large files to github. Could this .gitignore file alone prevent the .git folder to grow too large? What else should I do to prevent my new repo’s .git folder to grow unnecessarily large?

@Daniel, What you need to understand is that git clone downloads the entire history of your repo. This is so that all delta calculations on commits and merges are done locally, which facilitates a lot of git’s performance. In terms of text files, storage today is pretty much endless and a full copy is a good tradeoff.
The tradeoff is not so certain for large files like images. The solution is to use the Large File Storage extension, which lazily downloads files when a commit is checked out, rather than during cloning.

git-lfs is covered a bit in some of the early Live Videos.

I’m fairly sure adding git-lfs won’t by default shrink your existing.
You’ll might need to search for a procedure, but at worst if you can throw your history away, you can start with a blank repo, add git-lfs, then copy your images into the repo.

btw, its not at all required to know how git works under the hood, but I found Chapter 10 - Git Internals a facinating read, and repeating the examples enlightning.

1 Like

What is the cause of having a huge .git folder (200MB) when the repo itself without it is only 4MB?
Is it because I have done too many git push for smaller changes?

Should I be careful of doing git push, otherwise even without any images or large files, .git can still be huge?