Skip to main content

genjson

Generates the SAP Data Intelligence (SAP DI) solution files that enables to locally code new custom python operators and prepares for uploading to an SAP DI instance as a solution.

A specific folder structure is required in order use the gensolution that complies to a general github repository setup. This can be setup with gensolution --project.

In addition the operator script needs to provide additional information that is used to create the operator description files operator.json and configSchema.json.

Required Folder Structure

  • project
    • src: containing the source code of the operator packages
      • package1
        • [operator] - operator is placeholder for the name of the operator
          • [operator].py
        • package2
          • ...
    • solution: containing the solution folders that corresponds to the SAP DI python subengine folder structure. The structure is generated if not existing.
      • operators
        • package_version.zip (solution for uploading to a SAP DI instance
        • package_version
          • manifest.json
          • content
            • files
              • ...

Usage

The genjson-script needs to be exectuted at the root of the project folder (Exception when using ```gensolution --project``).

usage: gensolution.py [-h] [--project PROJECT] [--version VERSION] [--debug]
                      [--force]

Generate SAP Data Intelligence solution for local operator code

optional arguments:
  -h, --help         show this help message and exit
  --project PROJECT  Creates new project with folder structure for locally
                     programming operators
  --version VERSION  version format <num.num.num>
  --debug            for debug-level information
  --force            removes subdirectories from <solution/operators>

Operator Template

The following code is reduced to the bare minimum you need for local (offline) development of operators.


def process(msg):

    # start custom code

    # example of accessing config parameter
    filename = api.config.filename

    # end custom code

    # return message
    return  api.Message(attributes = {'filename':api.config.filename}, body=filename)

### definitions for local development to test
### - will not be read when called by vflow of SAP Data Intelligence
try:
    api
except NameError:
    class api:
        # default input - only for testing
        def get_default_input():
            body = '0'
            attributes = {'format': 'csv', "storage.filename": "test_file.txt"}
            return api.Message(attributes=attributes, body=body)

        # config parameter are required for testing and generating configSchema.json
        class config:
            # operator infos necessary for solution import
            tags = {'python36': ''}  # tags that helps to select the appropriate container
            operator_description = 'Read File from Container'
            version = "0.0.2"  # for creating the manifest.json
            config_params = dict()

            # operator parameter for config the operator and producing configSchema.json
            filename = './data/test_file.txt'
            config_params['filename'] = {'title': 'Filename', 'description':'Filename (path)', 'type':'string'}

        class Message:
            def __init__(self,body = None,attributes = ""):
                self.body = body
                self.attributes = attributes

        # just takes default
        def set_port_callback(port, callback):
            print("Port: ",port)
            msg = api.get_default_input()
            callback(msg)

        # call function providing input data and config parameter
        def call(msg,config,port,callback):
            api.config = config
            msg = process(msg)
            callback(msg)
            return msg


# list input and output ports with specified types for creating operator.json
inports = [{"name":"input","type":"message"}]
outports = [{"name":"output","type":"message"}]

# Triggers the request for every message - will be un-commented with gensolution or do it manually
api.set_port_callback(inports[0]["name"], process)

## test standalone
if __name__ == '__main__':
    config = api.config
    config.filename = "./newfile.txt"
    msg = api.Message(attributes={"filename":"new","Suffix":config.filename.split('.')[-1]},body='do it')
    api.call(msg,config,inports[0]["name"],process)

    print("Attributes: ",msg.attributes)
    print("Body: ",msg.body)
    ```

Release files for gensolution 0.0.14

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

Source distribution (sdist)

Source distribution for gensolution 0.0.14
File Size Uploaded
gensolution-0.0.14.tar.gz 9.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gensolution 0.0.14
File Interpreter ABI Platform
gensolution-0.0.14-py3-none-any.whl Python 3 none any Details

Total release size:20.4 kB

Release files / gensolution-0.0.14.tar.gz

Download URL gensolution-0.0.14.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
652538fb412c6e40bfe1bb9d17a57e5c3721db7e9806587699f12da6f548d05a
BLAKE2b-256 checksum
How to use checksums
e95e73e89a34f9a37ad674aa4f8bae7fc3abf83fb691608f4e9f7586e7b9597f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

Release files / gensolution-0.0.14-py3-none-any.whl

Download URL gensolution-0.0.14-py3-none-any.whl
Size 10.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1f8765bbcda34a6f7adc3f9e745595655dd86e67f7b35c80ff1b41c0e64944d7
BLAKE2b-256 checksum
How to use checksums
69802645a3f4c5275a7c6f48042ba556fc16393cb4ac2446639ed8b2878446bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.0.14 This release

2 release files

0.0.13

2 release files

0.0.12

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.8

2 release files

0.0.7

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