Skip to main content

Python Microservices Library

PyPI version Build Status Coverage Status Requirements Status Total alerts Language grade: Python

PyMS, Python MicroService, is a collections of libraries, best practices and recommended ways to build microservices with Python.

Documentation

To know how use, install or build a project see the docs: https://py-ms.readthedocs.io/en/latest/

Motivation

When we started to create microservice with no idea, we were looking for tutorials, guides, best practices, but we found nothing to create professional projects. Most articles say:

  • "Install flask"
  • "Create routes"
  • (Sometimes) "Create a swagger specs"
  • "TA-DA! you have a microservice"

But... what happens with our configuration out of code like Kubernetes configmap? what happens with transactionality? If we have many microservices, what happens with traces?.

There are many problems around Python and microservices and we can`t find anyone to give a solution.

We start creating these projects to try to solve all the problems we have found in our professional lives about microservices architecture.

Nowadays, is not perfect and we have a looong roadmap, but we hope this library could help other felas and friends ;)

Installation

pip install py-ms

Quickstart

You need to create 2 files: main.py and config.yml:

main.py

from flask import jsonify

from pyms.flask.app import Microservice

ms = Microservice(path=__file__) # 1.1
app = ms.create_app() # 2.1


@app.route("/") # 3.1
def example():
    return jsonify({"main": "hello world"})


if __name__ == '__main__':
    app.run()

config.yml

pyms: # 1.2
  requests:
    data: {}
ms: # 1.3
  DEBUG: true
  APP_NAME: business-glossary
  APPLICATION_ROOT : ""
  SECRET_KEY: "gjr39dkjn344_!67#"

So what did that code do?

  1. Create a instance of PyMS Microservice class (#1.1). This initialization inject the configuration defined in the 1.3 block and could be accessed through current_app.config. Then, initialize the service defined in the 1.2 block. See Services for more details.
  2. Initialize Flask instance, Connexion if it was defined in the pyms configuration block, create a tracer, add health-check blueprint, initialize libs and set the PyMS Microservice in ms attribute and you can access to it with current_app.ms. This steps has their each functions and you can easy override it.
  3. create_app return the flask instance and you can interact with it as a typical flask app

See Documentation https://py-ms.readthedocs.io/en/latest/ to learn more.

How To Contrib

We appreciate opening issues and pull requests to make PyMS even more stable & useful! See This doc for more details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py-ms-1.4.1.tar.gz (32.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_ms-1.4.1-py3-none-any.whl (72.2 kB view details)

Uploaded Python 3

File details

Details for the file py-ms-1.4.1.tar.gz.

File metadata

  • Download URL: py-ms-1.4.1.tar.gz
  • Upload date:
  • Size: 32.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.7

File hashes

Hashes for py-ms-1.4.1.tar.gz
Algorithm Hash digest
SHA256 31f5bfdcc9874b0cb26f44121b198c950cf68ffd3f7217d939e9e3347c74d4e9
MD5 12f02394e5605f4e7da12e8d2ac5f1e8
BLAKE2b-256 425a628e8ca1b72fd882cc76ca92579f5002b31d283be89727d3305b1b78e4f8

See more details on using hashes here.

File details

Details for the file py_ms-1.4.1-py3-none-any.whl.

File metadata

  • Download URL: py_ms-1.4.1-py3-none-any.whl
  • Upload date:
  • Size: 72.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.7

File hashes

Hashes for py_ms-1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1e1c6cfed7cd5ec91287adf5ad703037d2719815cd4dd987cd3993564cb284c8
MD5 9de4cd5988fcae54b0bd197e93ddafd2
BLAKE2b-256 44edc1228eae0cf1da5a1435c4d0f34fa73f9a618a15f174e9a207b162a91e8b

See more details on using hashes here.

Release history Release notifications | RSS feed

2.8.0

2 files

2.7.0

2 files

2.6.1

2 files

2.6.0

2 files

2.5.1

2 files

2.5.0

2 files

2.4.3

2 files

2.4.1

2 files

2.4.0

2 files

2.3.0

2 files

2.2.2

2 files

2.2.0

2 files

2.1.0

2 files

2.0.0

2 files

1.5.0

2 files

This release

1.4.1 This release

2 files

1.3.2

2 files

1.3.1

3 files

1.2.0

2 files

1.1.0

2 files

1.0.3

2 files

1.0.1

2 files

1.0.0

3 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page