├── ep01-nbs-vs-projects ├── project │ ├── src │ │ ├── mypackage │ │ │ ├── __init__.py │ │ │ └── mycode.py │ │ └── setup.py │ └── README.md ├── Ep01-ShowNotes_figures │ ├── ep1.png │ ├── grid.png │ ├── import.png │ ├── install.png │ ├── folder-struct.png │ └── jupyter-terminal.png └── Ep01-ShowNotes.md ├── ep04-IDE ├── Ep04-ShowNotes_figures │ ├── vs.png │ ├── select.png │ ├── changeall.png │ └── inspector.png └── Ep04-ShowNotes.md ├── ep02-terminal ├── Ep02-ShowNotes_figures │ ├── ep2.png │ ├── spotlight.png │ └── terminal-app.png └── Ep02-ShowNotes.md ├── ep08-github-pr ├── Ep08-ShowNotes_figures │ ├── pr-1.jpg │ ├── pr-2.jpg │ ├── sync.jpg │ ├── sync.png │ ├── clone.jpg │ ├── collab.jpg │ ├── enter.png │ ├── 3-lines.jpg │ ├── git-loc.png │ ├── git-push.png │ ├── new-feature.png │ ├── clone-terminal.png │ ├── new-repository.jpg │ └── new-repository-details.jpg └── Ep08-ShowNotes.md ├── ep03-environments ├── Ep03-ShowNotes_figures │ ├── ep3.png │ ├── active-env.png │ ├── installer.png │ ├── watermark.png │ └── conda-version.png └── Ep03-ShowNotes.md ├── ep06-git-basics ├── Ep06-ShowNotes_figures │ ├── git-diff.png │ ├── git-commit.png │ ├── git-status.png │ ├── gitignore.png │ └── git-version.png └── Ep06-ShowNotes.md ├── ep09-github-collab ├── Ep09-ShowNotes_figures │ ├── cli.png │ ├── fork.png │ ├── clone-1.png │ ├── clone-2.png │ ├── comment.png │ ├── fork-2.png │ ├── fork-3.png │ ├── pr-com.png │ ├── pr-diff.png │ ├── branch-1.png │ ├── branch-2.png │ ├── changes-1.png │ ├── feat-sele.png │ ├── list-remote.png │ ├── list-remote-2.png │ ├── create-pull-request.png │ └── pull-request-interface.png └── Ep09-ShowNotes.md ├── ep05-debugging ├── Ep05-ShowNotes_figures │ ├── pycharm-debug.png │ ├── pycharm-line.png │ ├── pycharm-start.png │ ├── jupyterlab-start.png │ ├── pdb_set-trace-1.png │ ├── pdb_set-trace-2.png │ ├── pycharm-console.png │ ├── pycharm-breakpoint.png │ └── jupyterlab-breakpoint.png └── Ep05-ShowNotes.md ├── ep07-git-branching ├── Ep07-ShowNotes_figures │ └── branching-1.png └── Ep07-ShowNotes.md ├── .gitignore ├── README.md └── ep10-oop └── Ep10-ShowNotes.md /ep01-nbs-vs-projects/project/src/mypackage/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ep01-nbs-vs-projects/project/README.md: -------------------------------------------------------------------------------- 1 | This is an example project. -------------------------------------------------------------------------------- /ep01-nbs-vs-projects/project/src/mypackage/mycode.py: -------------------------------------------------------------------------------- 1 | def hello_world_func(): 2 | return 'hello world' -------------------------------------------------------------------------------- /ep04-IDE/Ep04-ShowNotes_figures/vs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep04-IDE/Ep04-ShowNotes_figures/vs.png -------------------------------------------------------------------------------- /ep04-IDE/Ep04-ShowNotes_figures/select.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep04-IDE/Ep04-ShowNotes_figures/select.png -------------------------------------------------------------------------------- /ep02-terminal/Ep02-ShowNotes_figures/ep2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep02-terminal/Ep02-ShowNotes_figures/ep2.png -------------------------------------------------------------------------------- /ep04-IDE/Ep04-ShowNotes_figures/changeall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep04-IDE/Ep04-ShowNotes_figures/changeall.png -------------------------------------------------------------------------------- /ep04-IDE/Ep04-ShowNotes_figures/inspector.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep04-IDE/Ep04-ShowNotes_figures/inspector.png -------------------------------------------------------------------------------- /ep08-github-pr/Ep08-ShowNotes_figures/pr-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep08-github-pr/Ep08-ShowNotes_figures/pr-1.jpg -------------------------------------------------------------------------------- /ep08-github-pr/Ep08-ShowNotes_figures/pr-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep08-github-pr/Ep08-ShowNotes_figures/pr-2.jpg -------------------------------------------------------------------------------- /ep08-github-pr/Ep08-ShowNotes_figures/sync.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep08-github-pr/Ep08-ShowNotes_figures/sync.jpg -------------------------------------------------------------------------------- /ep08-github-pr/Ep08-ShowNotes_figures/sync.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep08-github-pr/Ep08-ShowNotes_figures/sync.png -------------------------------------------------------------------------------- /ep03-environments/Ep03-ShowNotes_figures/ep3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep03-environments/Ep03-ShowNotes_figures/ep3.png -------------------------------------------------------------------------------- /ep08-github-pr/Ep08-ShowNotes_figures/clone.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep08-github-pr/Ep08-ShowNotes_figures/clone.jpg -------------------------------------------------------------------------------- /ep08-github-pr/Ep08-ShowNotes_figures/collab.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep08-github-pr/Ep08-ShowNotes_figures/collab.jpg -------------------------------------------------------------------------------- /ep08-github-pr/Ep08-ShowNotes_figures/enter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep08-github-pr/Ep08-ShowNotes_figures/enter.png -------------------------------------------------------------------------------- /ep01-nbs-vs-projects/Ep01-ShowNotes_figures/ep1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep01-nbs-vs-projects/Ep01-ShowNotes_figures/ep1.png -------------------------------------------------------------------------------- /ep02-terminal/Ep02-ShowNotes_figures/spotlight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep02-terminal/Ep02-ShowNotes_figures/spotlight.png -------------------------------------------------------------------------------- /ep06-git-basics/Ep06-ShowNotes_figures/git-diff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep06-git-basics/Ep06-ShowNotes_figures/git-diff.png -------------------------------------------------------------------------------- /ep08-github-pr/Ep08-ShowNotes_figures/3-lines.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep08-github-pr/Ep08-ShowNotes_figures/3-lines.jpg -------------------------------------------------------------------------------- /ep08-github-pr/Ep08-ShowNotes_figures/git-loc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep08-github-pr/Ep08-ShowNotes_figures/git-loc.png -------------------------------------------------------------------------------- /ep08-github-pr/Ep08-ShowNotes_figures/git-push.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep08-github-pr/Ep08-ShowNotes_figures/git-push.png -------------------------------------------------------------------------------- /ep09-github-collab/Ep09-ShowNotes_figures/cli.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep09-github-collab/Ep09-ShowNotes_figures/cli.png -------------------------------------------------------------------------------- /ep09-github-collab/Ep09-ShowNotes_figures/fork.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep09-github-collab/Ep09-ShowNotes_figures/fork.png -------------------------------------------------------------------------------- /ep01-nbs-vs-projects/Ep01-ShowNotes_figures/grid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep01-nbs-vs-projects/Ep01-ShowNotes_figures/grid.png -------------------------------------------------------------------------------- /ep02-terminal/Ep02-ShowNotes_figures/terminal-app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep02-terminal/Ep02-ShowNotes_figures/terminal-app.png -------------------------------------------------------------------------------- /ep06-git-basics/Ep06-ShowNotes_figures/git-commit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep06-git-basics/Ep06-ShowNotes_figures/git-commit.png -------------------------------------------------------------------------------- /ep06-git-basics/Ep06-ShowNotes_figures/git-status.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep06-git-basics/Ep06-ShowNotes_figures/git-status.png -------------------------------------------------------------------------------- /ep06-git-basics/Ep06-ShowNotes_figures/gitignore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep06-git-basics/Ep06-ShowNotes_figures/gitignore.png -------------------------------------------------------------------------------- /ep08-github-pr/Ep08-ShowNotes_figures/new-feature.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep08-github-pr/Ep08-ShowNotes_figures/new-feature.png -------------------------------------------------------------------------------- /ep09-github-collab/Ep09-ShowNotes_figures/clone-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep09-github-collab/Ep09-ShowNotes_figures/clone-1.png -------------------------------------------------------------------------------- /ep09-github-collab/Ep09-ShowNotes_figures/clone-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep09-github-collab/Ep09-ShowNotes_figures/clone-2.png -------------------------------------------------------------------------------- /ep09-github-collab/Ep09-ShowNotes_figures/comment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep09-github-collab/Ep09-ShowNotes_figures/comment.png -------------------------------------------------------------------------------- /ep09-github-collab/Ep09-ShowNotes_figures/fork-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep09-github-collab/Ep09-ShowNotes_figures/fork-2.png -------------------------------------------------------------------------------- /ep09-github-collab/Ep09-ShowNotes_figures/fork-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep09-github-collab/Ep09-ShowNotes_figures/fork-3.png -------------------------------------------------------------------------------- /ep09-github-collab/Ep09-ShowNotes_figures/pr-com.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep09-github-collab/Ep09-ShowNotes_figures/pr-com.png -------------------------------------------------------------------------------- /ep09-github-collab/Ep09-ShowNotes_figures/pr-diff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep09-github-collab/Ep09-ShowNotes_figures/pr-diff.png -------------------------------------------------------------------------------- /ep01-nbs-vs-projects/Ep01-ShowNotes_figures/import.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep01-nbs-vs-projects/Ep01-ShowNotes_figures/import.png -------------------------------------------------------------------------------- /ep01-nbs-vs-projects/Ep01-ShowNotes_figures/install.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep01-nbs-vs-projects/Ep01-ShowNotes_figures/install.png -------------------------------------------------------------------------------- /ep03-environments/Ep03-ShowNotes_figures/active-env.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep03-environments/Ep03-ShowNotes_figures/active-env.png -------------------------------------------------------------------------------- /ep03-environments/Ep03-ShowNotes_figures/installer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep03-environments/Ep03-ShowNotes_figures/installer.png -------------------------------------------------------------------------------- /ep03-environments/Ep03-ShowNotes_figures/watermark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep03-environments/Ep03-ShowNotes_figures/watermark.png -------------------------------------------------------------------------------- /ep05-debugging/Ep05-ShowNotes_figures/pycharm-debug.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep05-debugging/Ep05-ShowNotes_figures/pycharm-debug.png -------------------------------------------------------------------------------- /ep05-debugging/Ep05-ShowNotes_figures/pycharm-line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep05-debugging/Ep05-ShowNotes_figures/pycharm-line.png -------------------------------------------------------------------------------- /ep05-debugging/Ep05-ShowNotes_figures/pycharm-start.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep05-debugging/Ep05-ShowNotes_figures/pycharm-start.png -------------------------------------------------------------------------------- /ep06-git-basics/Ep06-ShowNotes_figures/git-version.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep06-git-basics/Ep06-ShowNotes_figures/git-version.png -------------------------------------------------------------------------------- /ep08-github-pr/Ep08-ShowNotes_figures/clone-terminal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep08-github-pr/Ep08-ShowNotes_figures/clone-terminal.png -------------------------------------------------------------------------------- /ep08-github-pr/Ep08-ShowNotes_figures/new-repository.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep08-github-pr/Ep08-ShowNotes_figures/new-repository.jpg -------------------------------------------------------------------------------- /ep09-github-collab/Ep09-ShowNotes_figures/branch-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep09-github-collab/Ep09-ShowNotes_figures/branch-1.png -------------------------------------------------------------------------------- /ep09-github-collab/Ep09-ShowNotes_figures/branch-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep09-github-collab/Ep09-ShowNotes_figures/branch-2.png -------------------------------------------------------------------------------- /ep09-github-collab/Ep09-ShowNotes_figures/changes-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep09-github-collab/Ep09-ShowNotes_figures/changes-1.png -------------------------------------------------------------------------------- /ep09-github-collab/Ep09-ShowNotes_figures/feat-sele.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep09-github-collab/Ep09-ShowNotes_figures/feat-sele.png -------------------------------------------------------------------------------- /ep03-environments/Ep03-ShowNotes_figures/conda-version.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep03-environments/Ep03-ShowNotes_figures/conda-version.png -------------------------------------------------------------------------------- /ep05-debugging/Ep05-ShowNotes_figures/jupyterlab-start.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep05-debugging/Ep05-ShowNotes_figures/jupyterlab-start.png -------------------------------------------------------------------------------- /ep05-debugging/Ep05-ShowNotes_figures/pdb_set-trace-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep05-debugging/Ep05-ShowNotes_figures/pdb_set-trace-1.png -------------------------------------------------------------------------------- /ep05-debugging/Ep05-ShowNotes_figures/pdb_set-trace-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep05-debugging/Ep05-ShowNotes_figures/pdb_set-trace-2.png -------------------------------------------------------------------------------- /ep05-debugging/Ep05-ShowNotes_figures/pycharm-console.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep05-debugging/Ep05-ShowNotes_figures/pycharm-console.png -------------------------------------------------------------------------------- /ep07-git-branching/Ep07-ShowNotes_figures/branching-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep07-git-branching/Ep07-ShowNotes_figures/branching-1.png -------------------------------------------------------------------------------- /ep09-github-collab/Ep09-ShowNotes_figures/list-remote.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep09-github-collab/Ep09-ShowNotes_figures/list-remote.png -------------------------------------------------------------------------------- /ep01-nbs-vs-projects/Ep01-ShowNotes_figures/folder-struct.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep01-nbs-vs-projects/Ep01-ShowNotes_figures/folder-struct.png -------------------------------------------------------------------------------- /ep05-debugging/Ep05-ShowNotes_figures/pycharm-breakpoint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep05-debugging/Ep05-ShowNotes_figures/pycharm-breakpoint.png -------------------------------------------------------------------------------- /ep09-github-collab/Ep09-ShowNotes_figures/list-remote-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep09-github-collab/Ep09-ShowNotes_figures/list-remote-2.png -------------------------------------------------------------------------------- /ep05-debugging/Ep05-ShowNotes_figures/jupyterlab-breakpoint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep05-debugging/Ep05-ShowNotes_figures/jupyterlab-breakpoint.png -------------------------------------------------------------------------------- /ep01-nbs-vs-projects/Ep01-ShowNotes_figures/jupyter-terminal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep01-nbs-vs-projects/Ep01-ShowNotes_figures/jupyter-terminal.png -------------------------------------------------------------------------------- /ep08-github-pr/Ep08-ShowNotes_figures/new-repository-details.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep08-github-pr/Ep08-ShowNotes_figures/new-repository-details.jpg -------------------------------------------------------------------------------- /ep09-github-collab/Ep09-ShowNotes_figures/create-pull-request.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep09-github-collab/Ep09-ShowNotes_figures/create-pull-request.png -------------------------------------------------------------------------------- /ep09-github-collab/Ep09-ShowNotes_figures/pull-request-interface.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lightning-AI/engineering-class/HEAD/ep09-github-collab/Ep09-ShowNotes_figures/pull-request-interface.png -------------------------------------------------------------------------------- /ep01-nbs-vs-projects/project/src/setup.py: -------------------------------------------------------------------------------- 1 | import setuptools 2 | 3 | 4 | setuptools.setup( 5 | name='mypackage', 6 | version='0.1', 7 | author='sebastian', 8 | packages=setuptools.find_packages(), 9 | ) -------------------------------------------------------------------------------- /ep02-terminal/Ep02-ShowNotes.md: -------------------------------------------------------------------------------- 1 | # Episode 2: The Terminal 2 | 3 | [[Watch Episode 2](https://www.youtube.com/watch?v=KhQKqaxU7BQ)] 4 | 5 | 6 | ## Opening the Terminal 7 | 8 | If you are on a Mac, you can find the terminal in the Applications/Utilities folder: 9 | 10 | 11 | 12 | 13 | 14 | On a Mac, our favorite shortcut to open the Terminal.app is to press Command+Space and type terminal into the Spotlight search: 15 | 16 | 17 | 18 | ## Terminal Commands 19 | 20 | Here is a summary of the terminal commands we covered in this episode: 21 | 22 | - `ls`: shows the contents of the current directory 23 | - `mkdir NewDirectory`: creates a new directory called `NewDirectory` 24 | - `cd NewDirectory`: navigates into a directory called `NewDirectory` 25 | - `open .`: opens the current directory in the macOS Finder app 26 | - `clear`: clears the terminal 27 | - `touch some_file.py`: creates a new, empty file called `some_file.py` 28 | - `mv some_file.py main.py`: renames the `some_file.py` file to `main.py` 29 | - `rm main.py`: removes (deletes) the file `main.py` 30 | - `rm -r SomeDirectory`: removes a folder called `SomeDirectory` 31 | 32 | 33 | 34 | ## Links 35 | 36 | - iTerm2: [https://iterm2.com](https://iterm2.com/) 37 | - Wiliam's open source work: [https://github.com/williamFalcon](https://github.com/williamFalcon) 38 | - Sebastian's open source work: [https://github.com/rasbt](https://github.com/rasbt) 39 | 40 | 41 | 42 | --- 43 | 44 | 45 | 46 | ## Questions or Suggestions? 47 | 48 | If you have questions or suggestions, please don't hesitate to reach out to William ([@_willfalcon](https://twitter.com/_willfalcon)) and Sebastian ([@rasbt](https://twitter.com/rasbt)) on Twitter or join our [Slack Channel](https://pytorch-lightning.slack.com/archives/C03GS6MTCCQ). For more episodes, also check out the [Lightning Bits: Engineering for Researchers](http://pytorchlightning.ai/edu/engineering-class). -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_store 2 | 3 | # Other Python-related things 4 | .ipynb_checkpoints 5 | 6 | # Byte-compiled / optimized / DLL files 7 | __pycache__/ 8 | *.py[cod] 9 | *$py.class 10 | 11 | # C extensions 12 | *.so 13 | 14 | # Distribution / packaging 15 | .Python 16 | build/ 17 | develop-eggs/ 18 | dist/ 19 | downloads/ 20 | eggs/ 21 | .eggs/ 22 | lib/ 23 | lib64/ 24 | parts/ 25 | sdist/ 26 | var/ 27 | wheels/ 28 | pip-wheel-metadata/ 29 | share/python-wheels/ 30 | *.egg-info/ 31 | .installed.cfg 32 | *.egg 33 | MANIFEST 34 | 35 | # PyInstaller 36 | # Usually these files are written by a python script from a template 37 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 38 | *.manifest 39 | *.spec 40 | 41 | # Installer logs 42 | pip-log.txt 43 | pip-delete-this-directory.txt 44 | 45 | # Unit test / coverage reports 46 | htmlcov/ 47 | .tox/ 48 | .nox/ 49 | .coverage 50 | .coverage.* 51 | .cache 52 | nosetests.xml 53 | coverage.xml 54 | *.cover 55 | *.py,cover 56 | .hypothesis/ 57 | .pytest_cache/ 58 | 59 | # Translations 60 | *.mo 61 | *.pot 62 | 63 | # Django stuff: 64 | *.log 65 | local_settings.py 66 | db.sqlite3 67 | db.sqlite3-journal 68 | 69 | # Flask stuff: 70 | instance/ 71 | .webassets-cache 72 | 73 | # Scrapy stuff: 74 | .scrapy 75 | 76 | # Sphinx documentation 77 | docs/_build/ 78 | 79 | # PyBuilder 80 | target/ 81 | 82 | # Jupyter Notebook 83 | .ipynb_checkpoints 84 | 85 | # IPython 86 | profile_default/ 87 | ipython_config.py 88 | 89 | # pyenv 90 | .python-version 91 | 92 | # pipenv 93 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 94 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 95 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 96 | # install all needed dependencies. 97 | #Pipfile.lock 98 | 99 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 100 | __pypackages__/ 101 | 102 | # Celery stuff 103 | celerybeat-schedule 104 | celerybeat.pid 105 | 106 | # SageMath parsed files 107 | *.sage.py 108 | 109 | # Environments 110 | .env 111 | .venv 112 | env/ 113 | venv/ 114 | ENV/ 115 | env.bak/ 116 | venv.bak/ 117 | 118 | # Spyder project settings 119 | .spyderproject 120 | .spyproject 121 | 122 | # Rope project settings 123 | .ropeproject 124 | 125 | # mkdocs documentation 126 | /site 127 | 128 | # mypy 129 | .mypy_cache/ 130 | .dmypy.json 131 | dmypy.json 132 | 133 | # Pyre type checker 134 | .pyre/ 135 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Lightning Bits: Engineering for Researchers 2 | 3 | 4 | 5 | This repository contains additional materials and show notes for the [Lightning Bits: Engineering for Researchers](https://www.pytorchlightning.ai/edu/engineering-class) video series. 6 | 7 | 8 | 9 | ## Ep 01: Notebooks vs Python Projects 10 | 11 | - [🍿 Watch Episode 1](https://youtu.be/JGnoTN1OnWY) 12 | - [📖 Read show notes](ep01-nbs-vs-projects/Ep01-ShowNotes.md) 13 | - [ep01-nbs-vs-projects/project](ep01-nbs-vs-projects/project): Layout of an example project 14 | - [A glimpse of Sebastian's typical workflows using both notebooks and Python projects/packages](https://github.com/rasbt/machine-learning-notes/tree/main/templates/pl_classifier) 15 | 16 | 17 | 18 | ## Ep 02: The 8 Essential Terminal Commands you Need to Know 19 | 20 | - [🍿 Watch Episode 2](https://youtu.be/KhQKqaxU7BQ) 21 | - [📖 Read show notes](ep02-terminal/Ep02-ShowNotes.md) 22 | 23 | 24 | 25 | ## Ep 03: How to Use Virtual Environments to Keep Your Computer Organized 26 | 27 | - [🍿 Watch Episode 3](https://youtu.be/WHWsABk4Ejk) 28 | - [📖 Read show notes](ep03-environments/Ep03-ShowNotes.md) 29 | 30 | 31 | 32 | ## Ep 04: How to Be More Productive Using Python Integrated Development Environments (IDEs) 33 | 34 | - [🍿 Watch Episode 4](https://youtu.be/ISGNh4B1Z74) 35 | - [📖 Read show notes](ep04-IDE/Ep04-ShowNotes.md) 36 | 37 | 38 | 39 | ## Ep 05: How to Debug Python Code -- Find Errors More Efficiently 40 | 41 | - [🍿 Watch Episode 5](https://youtu.be/mD-1OZvuVDU) 42 | - [📖 Read show notes](ep05-debugging/Ep05-ShowNotes.md) 43 | 44 | 45 | 46 | ## Ep 06: Version Control Your Code Using Git ... And Thank Yourself Later 47 | 48 | - [🍿 Watch Episode 6](https://youtu.be/mndB6zHmU3k) 49 | - [📖 Read show notes](ep06-git-basics/Ep06-ShowNotes.md) 50 | 51 | 52 | 53 | ## Ep 07: Managing Code Projects with Git Branching 54 | 55 | - [🍿 Watch Episode 7](https://youtu.be/tzJDZY1x31I) 56 | - [📖 Read show notes](ep07-git-branching/Ep07-ShowNotes.md) 57 | 58 | 59 | 60 | ## Ep 08: Creating a Pull Request on GitHub 61 | 62 | - [🍿 Watch Episode 8](https://youtu.be/_0X_dljzr5E) 63 | - [📖 Read show notes](ep08-github-pr/Ep08-ShowNotes.md) 64 | 65 | 66 | 67 | ## Ep 09: Collaborate on Coding Projects with GitHub 68 | 69 | - [🍿 Watch Episode 9](https://youtu.be/7wb2wUMrkkE) 70 | - [📖 Read show notes](ep09-github-collab/Ep09-ShowNotes.md) 71 | 72 | 73 | 74 | ## Ep 10: Level-Up Your Python Skills Using Classes and Object-Oriented Programming Concepts 75 | 76 | - [🍿 Watch Episode 10](https://youtu.be/rf8da4pVLwY) 77 | - [📖 Read show notes](ep10-oop/Ep10-ShowNotes.md) 78 | 79 | --- 80 | 81 | 82 | 83 | ## Questions or Suggestions? 84 | 85 | If you have questions or suggestions, please don't hesitate to reach out to William ([@_willfalcon](https://twitter.com/_willfalcon)) and Sebastian ([@rasbt](https://twitter.com/rasbt)) on Twitter or join our [Slack Channel](https://pytorch-lightning.slack.com/archives/C03GS6MTCCQ). For more episodes, also check out the [Lightning Bits: Engineering for Researchers](http://pytorchlightning.ai/edu/engineering-class). 86 | -------------------------------------------------------------------------------- /ep05-debugging/Ep05-ShowNotes.md: -------------------------------------------------------------------------------- 1 | # Episode 5: Debugging Python Code 2 | 3 | 4 | 5 | [[Watch Episode 5](https://www.youtube.com/watch?v=mD-1OZvuVDU)] 6 | 7 | 8 | 9 | 10 | 11 | Learning and using a professional debugging tool is one of the key things you can do to boost your productivity. Sure, you can often get by with the goold old "`print()`" statement approach. However, instead of inserting print statements all over your code, it is often more productive to set a breakpoint, jump into the code, and execute it line by line while inspecting the variables. 12 | 13 | 14 | 15 | 16 | 17 | ## Debugging in PyCharm 18 | 19 | In PyCharm, you can launch the debugger by clicking on the "bug" symbol in the upper right corner: 20 | 21 | 22 | 23 | ![](Ep05-ShowNotes_figures/pycharm-start.png) 24 | 25 | 26 | Then, you can set a breakpoint by clicking next to the line number: a red dot should appear: 27 | 28 | ![](Ep05-ShowNotes_figures/pycharm-breakpoint.png) 29 | 30 | Now, if you run the debugger again, the code should stop at the breakpoint, and you should see the variable contents and so forth: 31 | 32 | ![](Ep05-ShowNotes_figures/pycharm-debug.png) 33 | 34 | Then, we can go the to the console and explore the code interactively: 35 | 36 | ![](Ep05-ShowNotes_figures/pycharm-console.png) 37 | 38 | ## Stepping through your code line by line 39 | 40 | 41 | 42 | Sometimes it is helpful to debug your code line by line. You can do that by setting a breakpoint early in your code and then pressing the "Step into" button repeatedly to advance your code one line at a time: 43 | 44 | 45 | 46 | ![](Ep05-ShowNotes_figures/pycharm-line.png) 47 | 48 | 49 | 50 | ## Debugging code in the termimal using the built-in `pdb` module 51 | 52 | 53 | 54 | Sometimes you want to debug code on a remote machine or server (more on running code remotely in a future episode) and don't have access to PyCharm. In this case, the [`pdb`](https://docs.python.org/3/library/pdb.html) module in Python's standard library might be a good option. 55 | 56 | 57 | 58 | ![](Ep05-ShowNotes_figures/pdb_set-trace-1.png) 59 | 60 | ![](Ep05-ShowNotes_figures/pdb_set-trace-2.png) 61 | 62 | For more information on using `pdb`, we recommend seeing the official documentation at https://docs.python.org/3/library/pdb.html, which includes a [section](https://docs.python.org/3/library/pdb.html#debugger-commands) describing the different debugger commands. 63 | 64 | 65 | 66 | The most common debugger commands are: 67 | 68 | - `l` or `ll` (longlist) shows the current position in the code 69 | - `h` for help 70 | - `s` to execute the current line 71 | - `q` to quit 72 | 73 | 74 | 75 | ## Optional: Debugging in JupyterLab 76 | 77 | Note that JupyterLab has a very powerful debugger as well. You can launch it by clicking on the "bug" symbol similar to PyCharm: 78 | 79 | ![](Ep05-ShowNotes_figures/jupyterlab-start.png) 80 | 81 | The user interface is very similar to PyCharm as well, where you can click next to the line number in order to add a breakpoint. And after setting breakpoints, you can click on "play" to start the debugger: 82 | 83 | ![](Ep05-ShowNotes_figures/jupyterlab-breakpoint.png) 84 | 85 | 86 | 87 | ## Questions or Suggestions? 88 | 89 | If you have questions or suggestions, please don't hesitate to reach out to William ([@_willfalcon](https://twitter.com/_willfalcon)) and Sebastian ([@rasbt](https://twitter.com/rasbt)) on Twitter or join our [Slack Channel](https://pytorch-lightning.slack.com/archives/C03GS6MTCCQ). For more episodes, also check out the [Lightning Bits: Engineering for Researchers](http://pytorchlightning.ai/edu/engineering-class). 90 | -------------------------------------------------------------------------------- /ep04-IDE/Ep04-ShowNotes.md: -------------------------------------------------------------------------------- 1 | # Episode 4: Interactive/Integrated Developer Environments (IDEs) 2 | 3 | 4 | 5 | [[Watch Episode 4](https://www.youtube.com/watch?v=ISGNh4B1Z74)] 6 | 7 | 8 | 9 | It's 2022. There are lots of different tools available that make your life as a programmer, engineer, and researcher more convenient. This episode is focused on [PyCharm](https://www.jetbrains.com/pycharm/), which is one of the most widely used IDEs for Python. What is an IDE? IDE is short for integrated developer environment (sometimes also called "interactive" developer environment as Sebastian mentioned in the video). You can think of it as a text editor that is spring-loaded with lots of extra features that make you more productive. In that sense, it's both *interactive* and *integrated* ;). 10 | 11 | 12 | 13 | 14 | 15 | --- 16 | 17 | 18 | 19 | 20 | 21 | (PS: While [William](https://twitter.com/_willfalcon) is showcasing some of the PyCharm essentials, [Sebastian](https://twitter.com/rasbt) is more of a [VSCode](https://code.visualstudio.com) user. However, while recording the episode and setting up a new computer, Sebastian realized that PyCharm is actually quite nice and convenient. VSCode is a more versatile code editor that can be customized for Python, PyCharm really comes with all batteries included when it comes to Python. VSCode can be very powerful as well, but it takes a lot of customization -- finding and installing the right plugins. With PyCharm, you get all the benefits out of the box. Consequently, Sebastian is currently toying with the idea of making PyCharm his primarily Python coding tool.) 22 | 23 | 24 | 25 | --- 26 | 27 | 28 | 29 | ## (Warm-up) New terminal commands 30 | 31 | 32 | 33 | - `cat myfile` : prints the contents of a file named `myfile` to the terminal. 34 | - `open myfile`: Open a file named `myfile` in a preferred program. 35 | 36 | Which program opens which file when running `open` depends on the file type and your setup. If you want to change the default program for a specific file type, you can do the following: 37 | 38 | 1) Navigate to the file (or a file with similar file type) in Finder, and right-click on it. 39 | 2) Hold down the option key and click on "Show Inspector" 40 | 41 | 42 | 43 | 3. Now, go to "Open with", select the program from the dropdown menu, and click on "Change All..." 44 | 45 | 46 | 47 | 48 | 49 | ## Installing PyCharm 50 | 51 | 52 | 53 | Installing PyCharm is pretty straightfoward. Just go to the [official website](https://www.jetbrains.com/pycharm/) and follow the download link there. Also, we recommend starting with the community edition, which is free. If you like the community version and want some extra features, consider upgrading to the professional edition. 54 | 55 | 56 | 57 | ## Selecting a project interpreter 58 | 59 | 60 | 61 | Once you opened an existing project, or created a new one, you can select your interpreter from the bottom right corner: 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | --- 70 | 71 | 72 | 73 | ## Questions or Suggestions? 74 | 75 | If you have questions or suggestions, please don't hesitate to reach out to William ([@_willfalcon](https://twitter.com/_willfalcon)) and Sebastian ([@rasbt](https://twitter.com/rasbt)) on Twitter or join our [Slack Channel](https://pytorch-lightning.slack.com/archives/C03GS6MTCCQ). For more episodes, also check out the [Lightning Bits: Engineering for Researchers](http://pytorchlightning.ai/edu/engineering-class). 76 | -------------------------------------------------------------------------------- /ep07-git-branching/Ep07-ShowNotes.md: -------------------------------------------------------------------------------- 1 | # Episode 7: Managing Code Projects with Git Branching 2 | 3 | [Watch Episode 7](https://youtu.be/tzJDZY1x31I) 4 | 5 | 6 | 7 | ## Recap 8 | 9 | In the previous episode, we covered the basic concepts and commands behind Git for version control. If you haven't watched the [previous episode](../ep06-git-basics/Ep06-ShowNotes.md), we recommend checking it out before continuing reading. 10 | 11 | 12 | 13 | ## Git Branching -- Why? 14 | 15 | In the more traditional workflow, we would create copy of a file before we make a modification -- here, this could be a code file or a text document we are working. The copy is there to ensure we have the original copy in case we don't like our changes. However, keeping multiple copies around is very tedious (and also ineffecient). Git branching is a way we can create and manage changes more elegantly. 16 | 17 | By making a new branch in Git, we implicitely make a copy of the Git repository and can make modifications without altering the original. We can have multiple branches at the same time, and the branching mechanism allows us to merge back the changes into the main branch in case we want to adopt them permanently. 18 | 19 | This is also very useful in code collaboration. "Useful" is maybe not the right word: it's pretty much "essential." We will learn more about collaborating on Git projects in the next episode. 20 | 21 | 22 | 23 | ## Essential Git Branching Commands 24 | 25 | 26 | 27 | - `git branch`: Shows a list of the existing branches in the current Git repository 28 | 29 | - `git branch my-branch`: Create a new branch called `my-branch` 30 | - `git checkout my-branch`: Change your current "position" from the current branch to `my-branch` 31 | 32 | 33 | 34 | --- 35 | 36 | **Side note: Renaming the Default Branch** 37 | 38 | For new repositories, you can change the name of the default branch from `master` to `main` using the following command: 39 | 40 | ```bash 41 | git config --global init.defaultBranch main 42 | ``` 43 | 44 | 45 | 46 | --- 47 | 48 | 49 | 50 | ![](Ep07-ShowNotes_figures/branching-1.png) 51 | 52 | **Pro Tip**: 53 | 54 | Use 55 | 56 | ```bash 57 | git checkout -b my-new-branch 58 | ``` 59 | 60 | To combine the two steps `git branch my-new-branch` and `git checkout my-new-branch`. 61 | 62 | Or, if you like if you prefer your shortcuts to be even more concise, you can use `gcb my-new-branch` to achieve the same thing! 63 | 64 | 65 | 66 | ## Merging Branches 67 | 68 | At some point, if we like the changes we made in the current branch, we may want to merge back these changes into the main branch 69 | 70 | 1. `git checkout main`: Switch back to the main branch 71 | 2. `git merge my-branch`: Merge the branch `my-branch` into the currently active branch (here: `main`) 72 | 3. `git branch -D my-branch`: Optionally delete the branch to clean up your Git repo. 73 | 74 | 75 | 76 | --- 77 | 78 | **Side note: Rebasing** 79 | 80 | Some people prefer a workflow based on `git rebase`. Usually, this means applying the changes on top of a current branch. Or more concretely, you may be asked to rebase your current commits in the feature branch (`my-branch`) on top of the main branch. 81 | 82 | If you want to learn how rebasing works, we recommend [this excellent tutorial](https://www.atlassian.com/git/tutorials/rewriting-history/git-rebase). 83 | 84 | --- 85 | 86 | 87 | 88 | 89 | ## Questions or Suggestions? 90 | 91 | If you have questions or suggestions, please don't hesitate to reach out to William ([@_willfalcon](https://twitter.com/_willfalcon)) and Sebastian ([@rasbt](https://twitter.com/rasbt)) on Twitter or join our [Slack Channel](https://pytorch-lightning.slack.com/archives/C03GS6MTCCQ). For more episodes, also check out the [Lightning Bits: Engineering for Researchers](http://pytorchlightning.ai/edu/engineering-class). 92 | 93 | -------------------------------------------------------------------------------- /ep01-nbs-vs-projects/Ep01-ShowNotes.md: -------------------------------------------------------------------------------- 1 | # Episode 1 Show Notes -- Notebooks vs Python Projects 2 | 3 | 4 | 5 | [[Watch Episode 1](https://www.youtube.com/watch?v=JGnoTN1OnWY)] 6 | 7 | 8 | 9 | 10 | ## 1. Using Jupyter Notebooks 11 | 12 | Excited to get started with using Jupyter notebooks? The most common application for working with Jupyter notebooks is JupyterLab. Jupyter notebooks are great scratch pads for brainstorming ideas, and there are two common ways to use them: locally on our computer or in the cloud. 13 | 14 | ### 1a) On Your Computer 15 | 16 | We recommend the official installation instructions for getting it set up: [https://jupyterlab.readthedocs.io/en/stable/getting_started/installation.html](https://jupyterlab.readthedocs.io/en/stable/getting_started/installation.html) 17 | 18 | Personally, we prefer installing JupyterLab via conda (more on conda in a future episode) via 19 | 20 | ```bash 21 | conda install -c conda-forge jupyterlab 22 | ``` 23 | 24 | Once you have it installed, you can type `jupyter lab` in your terminal and press Enter, and JupyterLab should open automatically in your web browser. 25 | 26 | 27 | 28 | ### 1b) In the Cloud (Colab, Grid) 29 | 30 | If you prefer working in the cloud, Google Colab is an easy and free way for doing so. You can check it out [here](https://colab.research.google.com/). 31 | 32 | If you prefer to select your own hardware, we recommend using the [Grid.ai](https://www.grid.ai/) platform where you can open JupyterLab directoy from the web browser after you created a session: 33 | 34 | 35 | 36 | 37 | 38 | ## 2. Setting Up a Basic Python Project 39 | 40 | We will revist this topic in a future episode! However, if you are curious and can't wait, here is how this works! 41 | 42 | A basic Python project can start with a simple folder structure. Of course, the exact structure depends on the use-case context, but most often we start with two folders: 43 | 44 | 1. `src` for our code files (`.py` scripts). 45 | 2. `docs` for documentation-related files. 46 | 47 | A `README.md` file also often a good idea for leaving general instructions. 48 | 49 | 50 | 51 | ### Turning a Project into a Python Package 52 | 53 | Suppose we have a file `mycode.py` that contains our code. We can convert it into a Python package so that we can import functions from it. To do this, we create a folder called `mypackage` (and arbitrary naming choice) that contains at least these 2 things: 54 | 55 | 1. A file called `__init__.py` . (This can be empty.) 56 | 2. A file containing our code. We name it `mycode.py` (another arbitary name). 57 | 58 | Lastly, we create a `setup.py` file with the following minimal contents: 59 | 60 | ```python 61 | 62 | import setuptools 63 | 64 | setuptools.setup( 65 | name='mypackage', 66 | version='0.1', 67 | author='sebastian', 68 | packages=setuptools.find_packages(), 69 | ) 70 | ``` 71 | 72 | This `setup.py` file should be next to the `mypackage` folder. After you created these files, it should look like as follows: 73 | 74 | 75 | 76 | (This starter package is available [here on GitHub](https://github.com/PyTorchLightning/engineering-class/tree/master/ep01-nbs-vs-projects).) 77 | 78 | Now, we are able to install the package using the command 79 | 80 | ```bash 81 | pip install -e path/to/the/folder/containing/setup.py 82 | ``` 83 | 84 | 85 | 86 | Finally, after completing this step, we can import code from the package in Python, anywhere on our computer! 87 | 88 | 89 | 90 | Stay tuned for a future episode where we discuss this in more detail! Also, if you have any questions, please don't hesitate to reach out on [Slack](https://pytorch-lightning.slack.com/archives/C03GS6MTCCQ)! 91 | 92 | 93 | 94 | --- 95 | 96 | 97 | 98 | ## Questions or Suggestions? 99 | 100 | If you have questions or suggestions, please don't hesitate to reach out to William ([@_willfalcon](https://twitter.com/_willfalcon)) and Sebastian ([@rasbt](https://twitter.com/rasbt)) on Twitter or join our [Slack Channel](https://pytorch-lightning.slack.com/archives/C03GS6MTCCQ). For more episodes, also check out the [Lightning Bits: Engineering for Researchers](http://pytorchlightning.ai/edu/engineering-class). -------------------------------------------------------------------------------- /ep08-github-pr/Ep08-ShowNotes.md: -------------------------------------------------------------------------------- 1 | # Episide 8: Creating a Pull Request on GitHub 2 | 3 | [Watch Episode 8](https://youtu.be/_0X_dljzr5E) 4 | 5 | 6 | 7 | ## Recap 8 | 9 | In the previous episodes, we covered the basic concepts and commands behind Git for version control. These episodes are not mandatory for creating projects on GitHub, but we recommend you check them out as well: 10 | 11 | - [Ep 06: Version Control for Code Using Git](https://youtu.be/mndB6zHmU3k) 12 | - [Ep 07: Managing Code Projects with Git Branching](https://youtu.be/tzJDZY1x31I) 13 | 14 | 15 | 16 | 17 | 18 | ## Hosting your Git Projects on GitHub 19 | 20 | As we have seen in previous episodes, Git is a program that helps you with managing your code. [GitHub](https://github.com), as the name implies, is a "hub" for hosting your projects (maintained via Git version control) on the web. You can think of GitHub as a webserver and a user interface for sharing your code projects. 21 | 22 | Note that using GitHub is entirely free, however, there is a paid tier with additional features such as private repositories if needed. 23 | 24 | There are also other related services such as BitBucket and GitLab. However, GitHub is by far the most popular choice among developers. We highly recommend using GitHub because most of the open source community is using it, and thus it makes it easier to collaborate with others. 25 | 26 | 27 | 28 | 29 | 30 | ## Creating GitHub Projects 31 | 32 | First, if you haven't done so, yet, you can sign up to GitHub and create an account here: [https://github.com](https://github.com) (note that this is entirely free). 33 | 34 | By the way, if you are interested, you can check out William's and Sebastian's GitHub repositories here: 35 | - Sebastian: [https://github.com/rasbt](https://github.com/rasbt) 36 | - William: [https://github.com/williamfalcon](https://github.com/williamfalcon) 37 | 38 | 39 | 40 | Once you have a GitHub profile, you can create a new repository from the upper right corner: 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | ## Linking A Local Project To GitHub 49 | 50 | 51 | 52 | If you followed the steps above and created a new GitHub repository, copy the following three lines from the UI: 53 | 54 | 55 | 56 | ```bash 57 | git remote add origin https://github.com/rasbt/fun_with_git.git 58 | git branch -M main 59 | git push -u origin main 60 | ``` 61 | 62 | For now, keep these lines handy, and then head to your local Git (not GitHub) repository on your computer: 63 | 64 | (The `pwd` command prints the current directory.) 65 | 66 | Then, just paste the 3 lines we copied earlier into the terminal and press Enter: 67 | 68 | 69 | 70 | Then, when you refresh your browser page, you should see your Git project now synced with your GitHub project: 71 | 72 | 73 | 74 | 75 | 76 | ## Collaborating on GitHub 77 | 78 | Note that there are two different ways we can collaborate on a code project. 79 | 80 | 1) we fork a repository. This means that we create a copy of someone else's repository under our own account. Then, we clone this forked repository to our computer and make changes locally. After making the changes locally, we push the the changes back to the repository on our GitHub repository. And, if we are finished, we submit a pull request. 81 | 82 | 2) We are added as a collaborator to someone's GitHub repository. In this case, we don't need fork the project and can clone the GitHub repository directly. This is what we are assuming below. 83 | 84 | You can add a collaborator as follows, via the Settings menu: 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | Assuming you are a collaborator, you can clone the repository and make changes to the repository: 93 | 94 | 95 | 96 | Copy the GitHub repository URL as shown above and use `git clone` on your terminal: 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | The most common workflow is to create new features in a new branch. We recommend not making changes directly to the main branch. 105 | 106 | 107 | 108 | Now, we can make changes to files in this repository. After we are satisfied with the changes, we can use our familiar git commands to stage and commit the changes 109 | 110 | ```bash 111 | git add . 112 | git commit -m 'i added a new feature!' 113 | ``` 114 | 115 | While this is all we need when we use git locally, the question is now how do we sync this back to the server? This is where a new git command comes in! `git push origin` ! 116 | 117 | 118 | 119 | 120 | 121 | Finally, after pushing the new changes to the new feature branch, we can create a new Pull Request via the GitHub interface: 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | You can think if a pull request as a suggestion to merge the new feature branch into the project's main branch. 130 | 131 | 132 | 133 | In the next episode, we will learn how to interact with collaborators via the GitHub interface upon submitting a Pull Request. 134 | 135 | --- 136 | 137 | 138 | 139 | 140 | ## Questions or Suggestions? 141 | 142 | If you have questions or suggestions, please don't hesitate to reach out to William ([@_willfalcon](https://twitter.com/_willfalcon)) and Sebastian ([@rasbt](https://twitter.com/rasbt)) on Twitter or join our [Slack Channel](https://pytorch-lightning.slack.com/archives/C03GS6MTCCQ). For more episodes, also check out the [Lightning Bits: Engineering for Researchers](http://pytorchlightning.ai/edu/engineering-class). 143 | 144 | -------------------------------------------------------------------------------- /ep03-environments/Ep03-ShowNotes.md: -------------------------------------------------------------------------------- 1 | # Episode 3: -- Environments 2 | 3 | 4 | [[Watch Episode 3](https://www.youtube.com/watch?v=WHWsABk4Ejk)] 5 | 6 | 7 | 8 | There are many ways we can set up a virtual environment: Virtualenv, Anaconda, miniconda, Mini-forge, and several others. 9 | 10 | Here, we are going to focus on miniconda and conda-forge. 11 | 12 | 13 | 14 | ## A note about Miniconda vs Mini-forge 15 | 16 | You can think of Miniconda as a *mini* version of the Anaconda, which is a Python distribution that comes with many packages pre-installed. The main tool in Anaconda & Miniconda is the so-called `conda` environment and package manager. It is a tool for creating new virtual environments and installing packages. 17 | 18 | Now, Mini-forge is a community-maintained repository for conda-compatible packages. Using either miniconda or conda-forge is fine as the `conda` commands are identical. 19 | 20 | William happily uses Miniconda while Sebastian prefers mini-forge, but as mentioned above, both William and Sebastian use the exact same `conda` commands. 21 | 22 | 23 | 24 | ## Installing Miniconda 25 | 26 | 27 | 28 | We recommend visiting the [official Miniconda website](https://docs.conda.io/en/latest/miniconda.html) to find the latest information on installing Miniconda for your machine and operating system. For example, as of this writing, Sebastian would select one of the two following options to install Miniconda on his MacBook, which has an ARM-based M1 chip: 29 | 30 | 31 | 32 | Note that you can either choose the `pkg` or `bash` file installer. The `pkg` installer guides you through an interactive UI whereas the `bash` installer requires you to install Miniconda from your command line terminal. 33 | 34 | - If you download the `pkg` file, just double-click the downloaded file and follow the instructions. 35 | - If you download the `bash file, go to your terminal, type 36 | 37 | ```bash 38 | bash Miniconda3-py39_4.12.0-MacOSX-arm64.sh 39 | ``` 40 | 41 | and follow the instructions that will be shown in the terminal. Note that the exact file name may differ based on which version of the bash installer you downloaded. Also, make sure you `cd`ed into the folder containing the installer file for this to work. 42 | 43 | 44 | 45 | **Checking the installation** 46 | 47 | After installing Miniconda, you can open a new terminal and check if it was successfully installed by running ` conda --version`. If it was correctly installed, you should see the current version number of conda, for example, as shown below: 48 | 49 | 50 | 51 | ## Useful conda & pip commands 52 | 53 | 54 | 55 | 1) **Check** what environments are currently installed on your computer: 56 | 57 | ```bash 58 | conda env list 59 | ``` 60 | 61 | 62 | 63 | 2. **Create** a new environment called `course_1`: 64 | 65 | ```bash 66 | conda create --name course_1 python=3.7 67 | ``` 68 | 69 | 70 | 71 | 3. **Activate** an environment: 72 | 73 | ```bash 74 | conda activate course_1 75 | ``` 76 | 77 | Tip: the active environment is usually indicated at the beginning of the terminal prompt as shown in the screenshot below: 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 4. **List** all packages currently installed in the active environment: 86 | 87 | ```bash 88 | pip freeze 89 | ``` 90 | 91 | 92 | 93 | To save the requirements list to a `requirements.txt` file, you can use the `>` symbol: 94 | 95 | ```bash 96 | pip freeze > requirements.txt 97 | ``` 98 | 99 | 100 | 101 | 102 | 103 | 5. **Install new** packages with pip 104 | 105 | ```bash 106 | pip install pytorch-lightning 107 | ``` 108 | 109 | Alternatively, installing directly with conda would look like as follows: 110 | 111 | ```bash 112 | conda install pytorch-lightning -c conda-forge 113 | ``` 114 | 115 | 116 | 117 | 6. **Install** packages from a **`requirements.txt`** file: 118 | 119 | ```bash 120 | pip install -r requirements.txt 121 | ``` 122 | 123 | 124 | 125 | ## Bonus: exporting an environment using conda 126 | 127 | 128 | 129 | Instead of using `pip freeze`, you can also use `conda` to snapshot your environment. For instance, you can run the following command to create a environment.yml YAML file: 130 | 131 | ```bash 132 | conda env export > environment. yml 133 | ``` 134 | 135 | Then, you can share the `environment. yml`, and someone with the file can recreate the environment using the following command: 136 | 137 | ```bash 138 | conda env create --file environment.yml 139 | ``` 140 | 141 | Alternatively, you want to install the packages from `environment.yml` into an existing environment, you can use the `update` command as follows: 142 | 143 | ```bash 144 | conda env update --file environment.yml 145 | ``` 146 | 147 | 148 | 149 | ## Bonus: Checking your current environment in Jupyter notebooks 150 | 151 | 152 | 153 | When you create a new environment, it is a good idea to install Jupyter Notebook/Lab into that environment as well -- this ensures that you don't accidentally launch a Jupyter Notebook/Lab instance attached to a different environment. 154 | 155 | To conveniently check your current computer specs, conda environment, and the installed packages, Sebastian developed the handy [watermark](https://github.com/rasbt/watermark) extension. 156 | 157 | After installing watermark as follows 158 | 159 | ```bash 160 | pip install watermark 161 | ``` 162 | 163 | you can get various information about your computer and environment as shown in the screenshots below: 164 | 165 | 166 | 167 | 168 | --- 169 | 170 | 171 | 172 | ## Questions or Suggestions? 173 | 174 | If you have questions or suggestions, please don't hesitate to reach out to William ([@_willfalcon](https://twitter.com/_willfalcon)) and Sebastian ([@rasbt](https://twitter.com/rasbt)) on Twitter or join our [Slack Channel](https://pytorch-lightning.slack.com/archives/C03GS6MTCCQ). For more episodes, also check out the [Lightning Bits: Engineering for Researchers](http://pytorchlightning.ai/edu/engineering-class). 175 | -------------------------------------------------------------------------------- /ep10-oop/Ep10-ShowNotes.md: -------------------------------------------------------------------------------- 1 | # Episode 10: Python Classes and Object-Oriented Programming 2 | 3 | [[Watch Episode 10](https://youtu.be/7wb2wUMrkkE)] 4 | 5 | The process of using classes and objects is called object-oriented programming. Fun fact: Python is a (heavily) object-oriented programming language! 6 | 7 | Technically, you could be programming in Python without creating your own classes. Instead, you could just stick to writing regular functions. 8 | 9 | However, creating classes can be very useful in certain contexts when you have complicated objects and want to track their states. This is especially true in machine learning and deep learning contexts. For example, think of big neural networks and their associated weight parameters. Instead of manually passing these weight parameters through functions, it's much easier to attach the weights as so-called attributes to the neural network and its layers. But let's not get ahead of ourselves and talk about what Python classes are in general. 10 | 11 | 12 | 13 | 14 | ## Classes are Templates 15 | 16 | In a nutshell, you can think of a class as a template that you can use to create new objects. If you like baking, the classic analogy is that the class is your cookie-cutter, and a cookie represents the associated cookie you create using this template. Note that stamping out new cookies does not affect the cookie cutter itself. Using the cookie-cutter, the original shapes of the cookies are all similar. However, you can manually tweak each cookie individually (e.g., put chocolate on it, sprinkle it, and so forth.) 17 | 18 | For non-trivial code projects, classes are a great way to organize and reuse your code! 19 | 20 | ## Python Class Terminology 101 21 | 22 | Instead of just recapping the examples we discussed in [[Episode 10](https://youtu.be/7wb2wUMrkkE)], this shownotes article lists some of the core concepts and terminology when learning about and working with Python classes. We will keep it concise so you can use it as quick reference material. 23 | 24 | 25 | So, as promised, here are some of the key terms and concepts that are helpful: 26 | 27 | - functions 28 | - variables 29 | - classes 30 | - methods 31 | - objects 32 | - attributes 33 | 34 | Let's briefly go over some examples to define what those are. 35 | 36 | ### Functions 37 | 38 | You are probably already familiar with regular Python functions. They allow us to define code for easy reuse: 39 | 40 | 41 | [In]: 42 | 43 | ```python 44 | def my_function(a, b): 45 | return f"{a} + {b} is {a + b}" 46 | 47 | print(my_function(1, 2)) 48 | ``` 49 | 50 | [Out]: 51 | 52 | ``` 53 | 1 + 2 is 3 54 | ``` 55 | 56 | [In]: 57 | ```python 58 | print(my_function(4, 5)) 59 | ``` 60 | 61 | [Out]: 62 | 63 | ``` 64 | 4 + 5 is 9 65 | ``` 66 | 67 | A function is essentially reusable code that we can execute upon calling the function. 68 | 69 | ### Variables 70 | 71 | Variables are names or containers that we can use to store values so that we can reuse them later: 72 | 73 | 74 | 75 | [In]: 76 | 77 | ```python 78 | var1 = my_function(1, 2) 79 | var2 = my_function(4, 5) 80 | 81 | print(var2 + " & " + var1) 82 | ``` 83 | 84 | [Out]: 85 | 86 | ``` 87 | var2 + " & " + var1 88 | ``` 89 | 90 | 91 | 92 | ### Classes 93 | 94 | Now, somewhat similar to the idea behind functions, classes allow us to define reusable code. However, as we will see below, classes are a bit more "comprehensive." 95 | 96 | ### Methods 97 | 98 | Classes come with methods, and we can think of methods as a Python function that is attached to the class: 99 | 100 | ```python 101 | class MyClass: 102 | def __init__(self): 103 | print('__init__ was called') 104 | 105 | def my_computation(self): 106 | print('my_computation was called') 107 | ``` 108 | 109 | In the code example above, there are two methods: `__init__` and `my_computation`. 110 | 111 | The `__init__` method is a special-purpose method referred to as "constructor." It is executed when we initialize the class (more on that in the section on "Objects" below.) 112 | 113 | 114 | 115 | ### Objects 116 | 117 | Objects are new instances that we create using a Python class (the class acts as a cookie cutter here). For instance, we can create a new object using the `MyClass` class we defined earlier as follows: 118 | 119 | [In]: 120 | 121 | ```python 122 | my_object = MyClass() 123 | ``` 124 | 125 | [Out]: 126 | 127 | ``` 128 | __init__ was called 129 | ``` 130 | 131 | As we can see above, the `__init__` method was automatically executed upon creating (constructing) the new object. Hence, it's called the "constructor" method. In contrast, we have to call other methods explicitely: 132 | 133 | [In]: 134 | 135 | ```python 136 | my_object.my_computation() 137 | ``` 138 | 139 | [Out]: 140 | 141 | ``` 142 | my_computation was called 143 | ``` 144 | 145 | 146 | 147 | 148 | ### Attributes 149 | 150 | Previously, we said that Python methods are analogous to Python functions. Howeverm the difference is that methods belong to a class (and its corresponding objects) whereas functions stand on their own. 151 | 152 | Similar to the relationship between functions on methods, we can think of "attributes" as variables attached to a class. In the following example, we define a new class with an attribute `some_attribute`. 153 | 154 | [In]: 155 | 156 | ```python 157 | class MyClass: 158 | def __init__(self, value): 159 | print('__init__ was called') 160 | self.some_attribute = value 161 | 162 | def my_computation(self): 163 | print('my_computation was called') 164 | 165 | new_value = self.some_attribute * 2 166 | print(f'value times 2 is {new_value}') 167 | 168 | my_object = MyClass(value=123) 169 | ``` 170 | 171 | 172 | [Out]: 173 | 174 | ``` 175 | __init__ was called 176 | ``` 177 | 178 | [In]: 179 | 180 | ```python 181 | my_object.my_computation() 182 | ``` 183 | 184 | [Out]: 185 | 186 | ``` 187 | my_computation was called 188 | value times 2 is 246 189 | ``` 190 | 191 | 192 | The `self` here is a convention indicating that an attribute belongs to the class (or object) so that we can refer to it in the class methods. 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | --- 201 | 202 | 203 | 204 | 205 | ## Questions Or Suggestions? 206 | 207 | If you have questions or suggestions, please don't hesitate to reach out to William ([@_willfalcon](https://twitter.com/_willfalcon)) and Sebastian ([@rasbt](https://twitter.com/rasbt)) on Twitter or join our [Slack Channel](https://pytorch-lightning.slack.com/archives/C03GS6MTCCQ). For more episodes, also check out the [Lightning Bits: Engineering for Researchers](http://pytorchlightning.ai/edu/engineering-class). 208 | 209 | -------------------------------------------------------------------------------- /ep09-github-collab/Ep09-ShowNotes.md: -------------------------------------------------------------------------------- 1 | # Episode 9: Collaborating with Pull Requests using GitHub 2 | 3 | [[Watch Episode 9](https://youtu.be/7wb2wUMrkkE)] 4 | 5 | 6 | 7 | ## Recap 8 | 9 | In the previous episode ([Ep 08](../ep08-github-pr/Ep08-ShowNotes)), we learned how to create a pull request and ended on a cliffhanger. 10 | 11 | 12 | 13 | ## Using The GitHub Interface 14 | 15 | 16 | 17 | Once a Pull Request has been opened, the easiest way to collaborate on the Pull Request is by using the GitHub interface in the web browser. 18 | 19 | 20 | 21 | ![](Ep09-ShowNotes_figures/create-pull-request.png) 22 | 23 | ![](Ep09-ShowNotes_figures/pull-request-interface.png) 24 | 25 | 26 | 27 | The GitHub user interface in the browser provides a rich interface for commenting and checking file changes: 28 | 29 | 30 | ![](Ep09-ShowNotes_figures/pr-com.png) 31 | 32 | ![](Ep09-ShowNotes_figures/pr-diff.png) 33 | 34 | 35 | 36 | 37 | ## Creating A Pull Request For An Open Source Project 38 | 39 | Suppose you want to make a change to William's `fun_with_git` project. 40 | 41 | The first step is to fork the project to your own account: 42 | 43 | ![](Ep09-ShowNotes_figures/fork.png) 44 | 45 | ![](Ep09-ShowNotes_figures/fork-2.png) 46 | 47 | Now, the project should be available as a fork under your own account: 48 | 49 | ![](Ep09-ShowNotes_figures/fork-3.png) 50 | 51 | Next, to make the proposed changes, I first clone the forked repository to my computer. Use the following `git clone` command in your terminal: 52 | 53 | ![](Ep09-ShowNotes_figures/clone-1.png) 54 | 55 | You can get the exact name via the GitHub interface: 56 | 57 | ![](Ep09-ShowNotes_figures/clone-2.png) 58 | 59 | 60 | Now, I checkout a new branch for making the proposed changes: 61 | 62 | ![](Ep09-ShowNotes_figures/branch-1.png) 63 | 64 | Suppose you made a few changes to the file and pushed these to GitHub: 65 | 66 | ```bash 67 | git add . 68 | git commit -m "changes" 69 | git push origin newfeature 70 | ``` 71 | 72 | 73 | Now, you can create a Pull Request on the projects **original** repository -- that is, William's repository. (You don't have to modify your fork at this point.) 74 | 75 | ![](Ep09-ShowNotes_figures/changes-1.png) 76 | 77 | After opening the Pull Request, suppose the maintainer asks you to make changes. All you need to do is to make the changes locally on your computer, on the existing branch of your fork. Similar to as before, just stage, commit, and push the changes: 78 | 79 | ```bash 80 | git add . 81 | git commit -m "more changes" 82 | git push origin newfeature 83 | ``` 84 | 85 | This will automatically update the Pull Request. 86 | 87 | Usually, this update cycle repeats until the maintainer is happy with the changes and merges your Pull Request. 88 | 89 | ## Syncing Forks With Upstream 90 | 91 | If you forked a repository a while ago and want to make a new Pull Request, your fork might be out of data. Before creating a new branch, making changes, and opening a new pull request, it is usually a good idea to sync your fork with the original project. 92 | 93 | More concretely, suppose some time has passed since our first Pull Request to William's `fun_with_git` repository. Now, we want to make a second Pull Request, but before we do so, we want to update our fork with William's latest changes in his original repository. 94 | 95 | We can sync our fork with the **original** repository as follows. 96 | 97 | 98 | 99 | ### 1) Configuring A Remote Branch 100 | 101 | First, let's configure a remote that points to the upstream (**original**) repository on GitHub. We start by list the current configured remote repository of your fork by executing 102 | 103 | ``` 104 | git remote -v 105 | ``` 106 | 107 | You should see something like the following where your fork shows up: 108 | 109 | ![](Ep09-ShowNotes_figures/list-remote.png) 110 | 111 | We now need to specify a new remote *upstream* repository which points to William's repository: 112 | 113 | 114 | 115 | ```bash 116 | git remote add upstream https://github.com/williamFalcon/fun_with_git 117 | ``` 118 | 119 | To verify that this worked successfully, let's use `git remote -v` again: 120 | 121 | ![](Ep09-ShowNotes_figures/list-remote-2.png) 122 | 123 | ### 2) Syncing Our Fork 124 | 125 | Now that we have configured William's repository as the `upstream` repository, we can fetch changes from it: 126 | 127 | 128 | 129 | ```bash 130 | git fetch upstream 131 | ``` 132 | 133 | 134 | 135 | Then, we checkout the main branch: 136 | 137 | ```bash 138 | git checkout main 139 | ``` 140 | 141 | 142 | 143 | And, finally, we merge the changes in `upstream/main` to your local main branch by executing 144 | 145 | 146 | 147 | ```bash 148 | git merge upstream/main 149 | ``` 150 | 151 | After this procedure, your forked repository should be up to date compared to the **original** repository, and you should be good to go in terms of making a new Pull Request. 152 | 153 | 154 | 155 | ## Making Changes To A Pull Request As Contributor 156 | 157 | 158 | If you are a maintainer of a GitHub repository and someone opened a Pull Request, you will likely be the one asking for changes. Sometimes, it might actually be useful and more productive to make the changes directly yourself instead of asking for them. You can do this as follows: 159 | 160 | First, clone the repository of the person's fork (the person who is submitting the Pull Request). You can find the address if you scroll to the bottom of the Pull Request and click on "command line instructions:" 161 | 162 | ![](Ep09-ShowNotes_figures/cli.png) 163 | 164 | Then, in the terminal, check out the contributor's branch. This is the branch listed on the top of the Pull Request: 165 | 166 | ![](Ep09-ShowNotes_figures/branch-2.png) 167 | 168 | ![](Ep09-ShowNotes_figures/feat-sele.png) 169 | 170 | You can now make changes to any file and submit them back to the Pull Request using the usual git workflow: 171 | 172 | 173 | 174 | ```bash 175 | git add . 176 | git commit -m "made some changes to the pull request" 177 | git push origin feature_selection 178 | ``` 179 | 180 | 181 | 182 | Finally, it would be nice to let the contributor that you made changes: 183 | 184 | ![](Ep09-ShowNotes_figures/comment.png) 185 | 186 | 187 | --- 188 | 189 | 190 | 191 | 192 | ## Questions Or Suggestions? 193 | 194 | If you have questions or suggestions, please don't hesitate to reach out to William ([@_willfalcon](https://twitter.com/_willfalcon)) and Sebastian ([@rasbt](https://twitter.com/rasbt)) on Twitter or join our [Slack Channel](https://pytorch-lightning.slack.com/archives/C03GS6MTCCQ). For more episodes, also check out the [Lightning Bits: Engineering for Researchers](http://pytorchlightning.ai/edu/engineering-class). 195 | 196 | -------------------------------------------------------------------------------- /ep06-git-basics/Ep06-ShowNotes.md: -------------------------------------------------------------------------------- 1 | # Episode 6: Getting Started With Version Control Using Git 2 | 3 | [Watch Episode 6](https://youtu.be/HF6KAFDk9dY) 4 | 5 | 6 | 7 | ## What is Git? 8 | 9 | Version control (also known as source control) allows us to track code changes and work and collaborate on code projects effectively. In this episode, we learn the basics of Git, the version control software most people and companies use. 10 | 11 | 12 | 13 | You can check whether Git is already installed by executing `git --version` on the command line. 14 | 15 | ![](Ep06-ShowNotes_figures/git-version.png) 16 | 17 | If it turns out that Git is not already installed on your computer, you can download the latest version from the [Git website](https://git-scm.com/downloads). 18 | 19 | 20 | 21 | ## Git and GitHub 22 | 23 | You may have heard of GitHub before, and Git and GitHub are used almost synonymously these days. However, Git is actually the program we use for version control, and GitHub is a hosting platform. Most open-source projects use both. In this episode, we will focus on Git. The following episode will then focus on GitHub as a way to host our Git projects and how to code collaboratively. 24 | 25 | 26 | 27 | ## Essential Git Commands 28 | 29 | 30 | 31 | **Renaming the Default Branch** 32 | 33 | 34 | 35 | If this is your first time using Git, we recommend executing the following command to change the global settings: 36 | 37 | ```bash 38 | git config --global init.defaultBranch main 39 | ``` 40 | 41 | 42 | 43 | This will rename the default branch to `main`, which is the common standard for most coding and open-source projects. 44 | 45 | (Note that this is something you only need to do once.) 46 | 47 | 48 | 49 | 50 | 51 | ### 1) Creating and Checking Git Repositories 52 | 53 | 54 | 55 | - `git init`: this will create a new Git repository in the current folder. 56 | - `git status`: this will check the status of the current Git repository. 57 | 58 | ![](Ep06-ShowNotes_figures/git-status.png) 59 | 60 | 61 | Note that `git init` will simply add an "invisible" `.git` folder to your current directory where it stores all git-related information. Other than that, it will leave your local folder and file structure unchanged. So, if you change your mind and want convert the folder back from a Git repository to a regular folder, just delete the `.git` folder. 62 | 63 | If you see a `.DS_Store` (similar to in the screenshot above), this is a file created by macOS for Finder indexing and search properties. We can ignore it here. 64 | 65 | 66 | 67 | **A Note About Invisible Files** 68 | 69 | On macOS, all files and folders that start with a `.` (dot) are invisible in the Finder and the Terminal. 70 | 71 | If you want to see invisible files and folders in the Finder, you can press **Command+Shift+Dot**. If you to these these in the terminal, use `ls -a` instead of `ls` when you are listing the directory contents. 72 | 73 | 74 | 75 | ### 2) Committing Changes 76 | 77 | Assume we made some changes to an existing file in the current Git repository. Now, we want to commit these changes. This is a 2-step process. First, we use `git add` and then we use `git commit`. 78 | 79 | - `git add main.py`: Adds a file named `main.py` to the list of changes to be tracked for the `git commit` command. 80 | - `git commit -m "my message"`: Commit the tracked changes to the Git history with a commit message "my message". 81 | 82 | ![](Ep06-ShowNotes_figures/git-commit.png) 83 | 84 | ### 3) Committing All Changes 85 | 86 | Above, we saw how we could track and commit individual files. However, if you have a project with many files you want to track and commit -- this is true for most projects -- adding files one by one can become very cumbersome. 87 | 88 | To track all changed files in a given directory, you can use the following modified `git add` command 89 | 90 | - `git add .`: Track all changed files in a directory 91 | - `git commit -m "my message"`: Commit tracked files (this is the same as before) 92 | 93 | Now, often you want to track and commit most **but not all** files. For example, you typically want to ignore large files. You can create a `.gitignore` file and list the files to be excluded in that file. 94 | 95 | For that to work, all we need is a .gitignore file in the same folder as the .git repository. 96 | 97 | 98 | 99 | 100 | 101 | ![](Ep06-ShowNotes_figures/gitignore.png) 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | In the example above, we are ignoring the file "file-to-ignore.docx" and the folder "folder-to-ignore." 110 | 111 | 112 | 113 | ### 4) Checking Changes 114 | 115 | - `git status`: This shows the changed and tracked files in the current Git repository 116 | - `git log`: The log command shows the commit history. 117 | - `git diff`: This command shows the lines that changed since the last commit. 118 | 119 | 120 | Lines that were removed start with a `-` sign, and lines that were added start with a `+` sign. In the example above, The `main.py` file was modified, where a line `some_line = 123` as removed and the line `new_line = 456` was added. 121 | 122 | ![](Ep06-ShowNotes_figures/git-diff.png) 123 | 124 | 125 | ## Version Control in PyCharm & VSCode 126 | 127 | 128 | 129 | Note that most IDEs also integrate Git into their UI. In this lecture, we used the Terminal to see how the basic Git commands work step by step. Many people still use Git from the command line while others prefer using Git within PyCharm or VSCode. Using the PyCharm or VSCode UI is totally up to you. However, for now we recommend using Git from the command line to familiarize yourself with the main commands. Later, we can revisit the UI interfaces. 130 | 131 | 132 | 133 | ## Further Resources 134 | 135 | - We will cover Git in more detail in future episodes, and we recommend to stay tuned! However, if you are curious to explore more on your own, check out [this resource](https://git-scm.com) for a very detailed Git coverage. 136 | 137 | 138 | **Prettier Terminal Layouts** 139 | 140 | - For a pretty output formatting where the Git branches are shown in your terminal (similar to the screenshots above), check out the [Oh My Zsh](https://github.com/ohmyzsh/ohmyzsh) project. 141 | - If you are coding on a Mac and also want to style your macOS terminal in general, also have a look at the different macOS terminal themes [here](https://github.com/lysyi3m/macos-terminal-themes). (Sebastian is using the "VS Code Dark Plus" theme for the screenshots above.) 142 | 143 | 144 | 145 | 146 | ## Questions or Suggestions? 147 | 148 | If you have questions or suggestions, please don't hesitate to reach out to William ([@_willfalcon](https://twitter.com/_willfalcon)) and Sebastian ([@rasbt](https://twitter.com/rasbt)) on Twitter or join our [Slack Channel](https://pytorch-lightning.slack.com/archives/C03GS6MTCCQ). For more episodes, also check out the [Lightning Bits: Engineering for Researchers](http://pytorchlightning.ai/edu/engineering-class). 149 | 150 | --------------------------------------------------------------------------------