Skip to main content

omg.py

A micro-framework for the excellent Open Microservices Guide, for suppportive code written in Python 3.6+.

Note: this is pre-release software, and is subject to improvement. Contributions are welcome! This framework is being developed for other languages, as well. If you'd like to help, let us know!

Intended / Example Usage

$ cat service.py
import omg
from uuid import uuid4

service = omg.Microservice(name='uuid')

@service.register()
def new(prefix: str) -> str:
    """Generates a UUID, with a given prefix."""
    return f'{prefix}{uuid4().hex}'

if __name__ == '__main__':
    service.serve()

register takes some optional arguments: name and path. You can also call service.add(f=new), instead.

Next, run the command $ omg-generate microservice.yml files will automatically be generated, for your application:

$ omg-generate service:service
…
'microservice.yml' written to disk!
$ cat microservice.yml
actions:
  new:
    help: Generates a UUID, with a given prefix.
    arguments:
      prefix:
        in: query
        required: true
        type: string
    http:
      method: get
      path: /new
      port: 8080
    output:
      type: string
lifecycle:
  startup:
    command:
    - python3
    - /app/service.py
omg: 1
$ cat Dockerfile
FROM kennethreitz/pipenv
COPY . /app
CMD ["python3", "service.py"]

Now, run your microservice!

$ python service.py
2019-05-09 14:45:39,342 - micro - DEBUG - Initiating 'uuid' service.
2019-05-09 14:45:39,344 - micro - DEBUG - Registering Flask endpoint: '/new'
2019-05-09 14:45:39,344 - micro - DEBUG - Dockerfile './Dockerfile' already exists!
2019-05-09 14:45:39,345 - micro - DEBUG - Microservice Manifest './microservice.yml' already exists!
2019-05-09 14:45:39,346 - micro - INFO - Serving on: '*:8080'

This will spawn a Flask application (using the production-ready waitress web server), preconfigured to serve the masses!

Or, use the omg-cli:

$ omg run new -a prefix='user-'

Installation

$ pip install omg.py

P.S. Do provide feedback, if you desire! :)

✨ 🍰 ✨

Release files for omg-micro 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for omg-micro 0.4.0
File Size Uploaded
omg-micro-0.4.0.tar.gz 7.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for omg-micro 0.4.0
File Interpreter ABI Platform
omg_micro-0.4.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 13.9 kB

Release files / omg-micro-0.4.0.tar.gz

Download URL omg-micro-0.4.0.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
24904ef50b6186b623171c6887e86ffbaab44b227ac68d3f564a97186968cb32
BLAKE2b-256 checksum
How to use checksums
d6c19026d977093af34ce2ee16ef2a595858ba63c9eab2da899dbc0c9a4db762
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

Release files / omg_micro-0.4.0-py2.py3-none-any.whl

Download URL omg_micro-0.4.0-py2.py3-none-any.whl
Size 6.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
00cc676726cbe11fecb45d3c043c4d404d216bcf9932ce6ab09fba88d72ae7f2
BLAKE2b-256 checksum
How to use checksums
b36e29376cf474fac8adae53012d6ad2c41f12010fe41015ebe18de1ab328e79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release 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