Code Monkey home page Code Monkey logo

best_practices_python's Introduction

Best practices python

The below repository is present on Knoldus Public Github and contains the multi-module python project with best practices and standards implemented.

Requirments

Python 3.8

Package Management

Create an isolated Python virtual environments. or conda

Packaging

1.Create a new virtual environment by choosing a Python interpreter and making a ./venv directory to hold it(you can also use anaconda/any other methods available):

python3 -m venv ./venv

2.Activate the virtual environment:

source ./venv/bin/activate

3.Clone the repo to the virtual envoirment directory

git clone <repo_name>

Guide for Package Installation

Updating the pip library

$python -m pip install --upgrade pip

Requirments

pip install -r requirements.txt 

Project Structure

├── actions
│   └── actions.py
├── app.py
├── config
│   └── config.ini
├── config.yml
├── credentials.yml
├── data
│   ├── Entity_extracted_data
│   ├── Input_Data
│   ├── nlu.yml
│   ├── rules.yml
│   └── stories.yml
├── domain.yml
├── endpoints.yml
├── lib
│   ├── config_validator.py
│   ├── error_handlers.py
│   ├── logger.py
│   ├── preprocessor.py
│   ├── rasa_agent.py
│   └── response_creator.py
├── logs
│   └── 2023_02_08.log
├── models
│   └── 20221126-134706.tar.gz
├── results_model
│   ├── DIETClassifier_confusion_matrix.png
│   ├── DIETClassifier_errors.json
│   ├── DIETClassifier_histogram.png
│   ├── DIETClassifier_report.json
│   ├── intent_confusion_matrix.png
│   ├── intent_errors.json
│   ├── intent_histogram.png
│   └── intent_report.json
└── tests
    ├── test_inference.py
    └── test_preprocessor.py

User Guide

Remove the .gitkeep file present inside data/Input_data & data/Entity_extracted_data (Check for hidden files to make sure)

To Run

$python3 app.py

Check the app through Postman (the app will run on localhost:8000)

GET: Check whether the server is running or not

http://localhost:8000/ping

POST: Input a .pdf as a body through postman

http://localhost:8000/invocations

Enforcing Code Quality

Automated code quality checks are performed using pre-commit. Code quality tool are present in .pre-commit-config.yaml file. Additional code quality tools can be added or removed through the .pre-commit-config.yaml file

List of Code Quality tools used are as follows

  • flake8
  • pylint
  • bandit
  • black
  • isort

To run all present checks:

Note:Make sure to initialize git using $git init ,If it isn't initialized. Then run

$pre-commit run --all-files

Testing

Testing is performed with pytest. pytest has become the de facto Python unit testing framework. Code coverage is provided by

$ pytest-cov

Logfile is stored in logs directory in (yyyy-mm-dd) format

Container

Docker is a tool that allows for software to be packaged into isolated containers.

To build the container image:

$ docker build -t <image_name> .

To run the image in a container:

$ docker run <image_name>

best_practices_python's People

Contributors

aayushsrivastava0 avatar

Watchers

 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.