Giter Site home page Giter Site logo

mfe-coding-workshop's Introduction

Topics

  • Version Control (git)
  • Advanced Python
  • Production Python

Version Control

  • Why use version control tools?
  • git vs. GitHub
  • Sourcetree
  • git on white board (distributed version control flow)
  • basic git commands:
    • git init and git clone
    • git status, git add and git commit
    • git push
    • git pull
    • git checkout and git branch
    • git merge and resolve conflicts
    • git rebase
    • git stash
  • Github specials
    • fork
    • pull requests

Advanced Python

Setup

  1. Pro tip: use Python3

Anaconda

Anaconda is very good Python package manager + environment manager + additional scientific libraries. Highly recommend for local development. Not recommend for servers, as its ~3GB.

  1. Download and install Anaconda Python 3.6 here
  2. Create environment conda create --name test --file conda-requirements.txt
  3. source activate test (vs. source deactivate)
  4. whichp python

Note that the test environment folder is usually stored with your anaconda. To check, try which conda.

pip + virtualenv

pip is light-weigt Python pacakge manager. virtualenv is light-weight Python environment manager.

  1. Install Python3
  2. Go to the folder where you want to install your env, usually the repo.
  3. Setup environment virtualenv env -p python3
  4. source env/bin/activate (vs. deactivate)
  5. pip install -r requirements.txt
  6. which python

Fluent Python

Please refer to src/fluent_python/*.py for the code.

  • List Comprehension
  • Generator, yield, yield from
  • Decorator
  • Functional programming
  • Variable Scope
  • Operator overloading
  • Interface and abc
  • Inheritance vs. Composition (no .py, draw on board and look at Sklearn)
  • Python function call-by

Production Python

Development Environment

  • Local/Development: your laptop or a sandbox on a development server
  • Testing: for all the tests, shares the same environement as staging and production
  • Staging: an environment for final testing immediately prior to deploying to production. A mirror of production, but not facing to the users.
  • Production: the environment that users/clients directly interact with

img

Python Debug

  • Why bother debugging?
  • You need to debug when:
    • you see a Shape ratio of 40
    • you are trying to understand your teammate's code
  • How many of you debug via:
    • print(...)
    • Binary search
    • pdb/ipdb
  • Examples
    • debug in ipdb (make sure you pip install ipdb)
    • debug in ipython notebook (use the magic command %debug after you see an error)

Python Tests

  • Why bother testings?
    • Collborations
    • Too big to fail
    • Know who to blame
  • Different types of tests
    • lint checks
    • unit test
    • integration test
    • regression test
    • ...

Lint

  • Why we need Lint?
  • flake8: try flake8 src/production_code
  • pylint: try pylint src/production_code
  • mypy: type hint (only), try mypy src/mypy_examples

Unit Test

  • Why do we need unit tests?
  • try: pytest src/production_code

Continuous Integration

Continuous Integration (CI) tools help you stick to your team’s quality standards by running tests every time you push a new commit and reporting the results to a pull request.

Examples:

makefile

  • Make your life easier
  • make lint instead of running flake8 + pylint + mypy
  • make install <- who doesn't like 1-click setup?
  • checkout Makefile

docker (very brief, no code)

mfe-coding-workshop's People

Contributors

frankthetank123 avatar

Stargazers

Yiheng Li avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.