Skip to content

A framework for microservice based document transformation.

License

Notifications You must be signed in to change notification settings

B4rtware/morpho

Repository files navigation

Morpho Logo

Python port for the go written doctrans

Morpho is a framework for microservice based web services. It offers the ability to transform a given document with a provided function.

In the first place this framework was created to be used for research purposes.

💡 Installation

pip install morpho

via git

  1. make sure to use at least python 3.8
  2. clone the repo git clone https://github.com/B4rtware/morpho.git
  3. cd morpho and install dependencies via
    • poetry install (Poetry) or
    • use the provided requirements.txt

⚙️ Server Example

... without options

service.py

from morpho.server import Service


def work(document: str) -> str:
    return document


service = Service(name="Echo", version="0.0.1", worker=work)

if __name__ == "__main__":
    service.run()

Tested with Python 3.8.1 and morpho v1.0.0b8 ✔️

... with options

service.py

from morpho.server import Service
from pydantic import BaseModel


class Options(BaseModel):
    name: str


def work(document: str, options: Options) -> str:
    return document + options.name


service = Service(name="AppendName", version="0.0.1", worker=work, options_type=Options)

if __name__ == "__main__":
    service.run()

Tested with Python 3.8.1 and morpho v1.0.0b8 ✔️

🖥️ Client Example

This example expects a service named Echo that was started with the --register option and was registered with the Eureka server with the url http://localhost:8761/eureka/.

client.py

from morpho.rest.models import TransformDocumentRequest
from morpho.client import Client
from morpho.client import ClientConfig


morpho = Client(
    ClientConfig("http://localhost:8761/eureka/")
)

request = TransformDocumentRequest(
    document="This is a Document!",
    service_name="Echo"
)

response = morpho.transform_document(request=request)

print(response.document)

>>> This is a Document!

Tested with Python 3.8.1 and morpho v1.0.0b8 ✔️

👩🏽‍💻 Development

Creating a new release

  1. Run the following command poetry version <version>
    Morpho uses the following schema: ^\d+\.\d+\.\d+((b|a)\d+)?$

  2. Bump the version within the file: morpho/__version__.py
    Make sure it's the same version used when bumping with poetry

  3. Open Changelog.md and write the new changelog:

    • Use the following # header: v<version> - (dd.mm.yyyy)
      Used ## headers:
    • 💌 Added
    • 🔨 Fixed
    • ♻️ Changed
  4. Stage the modified files and push them with the following commit message:

    chore: bump to version <version>

  5. Run the following command poetry build to create a tarball and a wheel based on the new version

  6. Create a new github release and:

    1. Copy and paste the changelog content without the # header into the description of the release textbox
    2. Use the # header style to fill in the Release title (copy it from the Changelog.md)
    3. Copy the version with the v-prefix into the Tag version
  7. Attach the produced tarball and wheel (dist/) to the release

  8. Check This is a pre-release if it's either an alpha or beta release (a|b) - optional

  9. Publish release

📝 License

MIT

About

A framework for microservice based document transformation.

Topics

Resources

License

Stars

Watchers

Forks

Languages