Skip to main content
One of the most important parts of the Kodexa Platform is the ability to create and manage modules. Modules are the core of the platform and are used to extract data from documents. Modules are created by using Python and the Kodexa SDK. In its simplest form, a module is simply a small Python script that receives a Document and returns a Document. The module can be as simple as:
def infer(document):
    return document
You would put this code in a module, i.e.
module/
    __init__.py
    module.py

Deployment

To deploy the module, we need to also create a module.yml file that describes the module. This file is used to describe the module, and also to provide the metadata that is used to deploy the module to the Kodexa Platform.
# A very simple first module that isn't trainable

slug: my-module
version: 1.0.0
orgSlug: kodexa
type: store
storeType: MODEL
name: My Module
metadata:
  atomic: true
  trainable: false
  moduleRuntimeRef: kodexa/base-module-runtime
  type: module
  contents:
    - module/*
The module definition is simple, it has a slug, version, orgSlug, type, storeType, name and metadata. The metadata is the most important part of the module definition. The metadata is used to describe the module and is used to deploy the module to the Kodexa Platform. In our first module, we said the module is not trainable and has no options for inference. We can now deploy this module to try it out. If you are logged in, you can deploy the module using the KDX CLI.
kdx apply -f module.yml

Debugging a Deploy

Sometimes you will want to understand what is in a deployment of a module. There are a couple of things you can do to understand what is on the server. First, you can set the deploy to keep a ZIP representation. This will allow you to see what was finally packaged in the module, you do this by updating the module.yml, i.e.
# A very simple first module that isn't trainable

slug: my-module
version: 1.0.0
orgSlug: kodexa
type: store
storeType: MODEL
name: My Module
metadata:
  atomic: true
  trainable: false
  # Adding Keep Zip will mean the implementation ZIP file is not cleaned up
  # when you run kdx apply -f <module.yml>
  keepZip: true
  moduleRuntimeRef: kodexa/base-module-runtime
  type: module
  contents:
    - module/*
The second way you can use is to download an implementation from the server, this is also useful for debugging if there is an issue in your deployment setup. You can use the KDX CLI to run:
kdx get module my-org/my-module:1.0.0 -o yaml