Skip to content

Repository files navigation

ukis-logo UKIS WMP Python Tasks

taskarchive containing example / test tasks implementations for wmp python execution.

[[TOC]]

requirements:

  • Linux based OS
  • WMP version >= 0.12.0
  • Python Install in version >= 3.13
  • python packages: openapi-python-client (for wmp-api client generation), pyinstaller (for binary build)

Build

Install required packages for build

Additional python packages are used for code generation and build. So you must install these before calling any of the create*.sh scripts.

Execute the following command to install the required python packages in the default environment:

# required for wmp rest api client code generation
pip install openapi-python-client

# optional: only required for binary build 
pip install pyinstaller

It is required to install these globally (in the default environment), because the dedicated venv gets cleared in build steps.

Alternatively: you can simply add these requirements in the requirements.txt file.

Build deliverables

Important: for correct execution of the build scripts please ensure you currently don't have any python environment activated... please deactivate any active venv with deactivate command

# always create python virtual environment before anything else, using:
./createEnv.sh

# you might have to remove previously created environment before createEnv will try to create venv again
rm -rf target/venv 

# re-generate wmp-external-task-service-api client (already called in createEnv.sh)
# make sure openapi-python-client package is installed
./generateClient.sh

# create binary delivery
# make sure pyinstaller package installed
./createInstall.sh

# create archive delivery
./createArchive.sh

hint: to force re-generate wmp-external-task-api client you can always run ./generateClient.sh

resulting build artifacts are created in target/ukis-wmp-python-task-*

If script calls continue failing you might want to clean up caches for a clean build

Build with custom build python

If you want to use a custom / manually build python version, make sure to clean up caches this is required to rebuild the venv with the custom python version. To (re-)create the venv with a custom python binary you have to provide this with other arguments to the createEnv.sh like:

#usage: ./createEnv.sh <requirements file> <venv filepath> <custom python binary filepath>
./createEnv.sh "requirements.txt" "./target/venv" "/home/user/bin/python3.14"

Simply keep the first two parameters (requirements + venv) set to the default values (shown above) and just change the 3rd parameter to your custom python binary filepath.

Clean up caches for a clean build

If a Build fails, you want to use another python version, or you simply want to ensure a clean build. It is necessary to remove the existing venv and possible other generated files using:

rm -rf target/

Unit Test

  • To run the unit tests go to the folder ukis-wmp-python-task/src and run python -m unittest discover ../test.

Delivery Variant 1: PyInstaller

  • To build the project as an executable file, run the createInstall.sh script (after createEnv.sh).

Delivery Variant 2: Archive

  • To build the project as an archive, run the createArchive.sh script (after createEnv.sh).

Installation

To install this taskarchive in a WMP instance simply place the created zip-archive or binary in the wmp-instance/tasks folder.

For development use you can also clone this repository inside the wmp-instance/tasks folder and rename it to ukis-wmp-python-task-<version>, filling out <version> with the actual version (specified e.g. in topic field of bpmn task)

Make sure your wmp-instance/config/conf.d/execution.yml configuration contains the python execution:

---
name: "executions.yml"
revision: 0
configClass: "de.dlr.wmp.task.execution.data.ExecutionsConfig"
config:
  executions:
    PythonExecution:
      className: "de.dlr.wmp.external.python.PythonPullingTaskArchiveExecutor"
      enabled: true
      wmpUrl: "http://localhost:8080/engine-rest"
      wmpLogUrl: "http://localhost:8080/engine-rest/wmp/log"
#      wmpUser: "demo"                                            # optional
#      wmpPassword: "demo"                                        # optional
#      wmpToken: "<token>"                                        # optional
#      ttl: "PT5M"                                                # optional
#      venvName: "venv"                                           # optional
#      srcFolder: "src"                                           # optional
#      startFile: "main.py"                                       # optional
#      errorRetrySeconds: 5                                       # optional
#      maxRetries: 10                                             # optional
#      rootLoggingLevel: "DEBUG"                                  # optional
#      enabledLogger: "[\"console\", \"file\", \"http\"]"         # optional
#      logPath: "task_execution.log"                              # optional
#      pythonBinary: "/home/user/python/python-3.14.6/bin/python" # optional

Make sure that wmpUrl and wmpLogUrl are set to the REST API endpoints of the wmp instance. Usually you just have to correct the Host and Port of the URLs.

and also check, that python task topic groups configured in wmp-instance/config/conf.d/topicGroups.yml are set to this execution, for example like this:

---
name: "topicGroups.yml"
revision: 0
configClass: "de.dlr.wmp.task.execution.topicgroup.TopicGroupConfigList"
config:
    topicGroups:
      - name: "topicGroup-PythonTest"
        topics:
          - "ukis-wmp-python-task:0.12.0-SNAPSHOT:de.dlr.wmp.task.test_mapping_task.TestMappingTask"
          - "ukis-wmp-python-task:0.12.0-SNAPSHOT:de.dlr.wmp.task.example_task.ExampleTask"
          - "ukis-wmp-python-task:0.12.0-SNAPSHOT:de.dlr.wmp.task.error_task.ErrorTask"
        numWorkers: 6
        lockTimeDuration: "PT60S"
        initialDelayDuration: "PT0.1S"
        scheduleIntervalDuration: "PT0.1S"
        shutdownTimeoutDuration: "PT10S"
        retryCycle: "R3/PT1S"
        execution: "PythonExecution"
        enabled: true
        usePriority: true
        pullBasedTaskExecution: true
        pollTimeout: "PT5M"
        errorDetailLevel: "stacktrace"
      - ...

Contributing

The German Aerospace Center (Deutsches Zentrum für Luft- und Raumfahrt e.V.) and Werum Software & Systems AG welcomes contributions from the community. For more detailed information, see our guide on contributing if you're interested in getting involved.

License

The source files in this repository are made available under the Apache License Version 2.0.

WMP uses and includes third-party dependencies published under various licenses. By downloading and using WMP artifacts, you agree to their terms and conditions.

About

WMP taskarchive for example python tasks (currently also containing the execution part)

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages