-
Notifications
You must be signed in to change notification settings - Fork 32
python workflow #755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
python workflow #755
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # | ||
| # This Dockerfile adds Python support to the SonataFlow devmode image. | ||
| # | ||
| # To build the image, run the following command: | ||
| # docker build -t sonataflow-devmode-python . | ||
| # | ||
| # To run the image with your workflow, run the following commands: | ||
| # IMAGE=sonataflow-devmode-python | ||
| # PATH_TO_WORKFLOW=<path-to-workflow-directory> | ||
| # docker run --ulimit nofile=262144:262144 -d --name sonataflow-devmode-python --add-host host.docker.internal:host-gateway -e QUARKUS_HTTP_PORT=8080 -p 8080:8080 -e KOGITO_SERVICE_URL=http://localhost:8080 -v $PATH_TO_WORKFLOW:/home/kogito/serverless-workflow-project/src/main/resources:Z -e KOGITO.CODEGEN.PROCESS.FAILONERROR=false -e QUARKUS_EMBEDDED_POSTGRESQL_DATA_DIR=/home/kogito/persistence -e QUARKUS_EXTENSIONS=org.apache.kie.sonataflow:sonataflow-addons-quarkus-python $IMAGE | ||
| # | ||
| # | ||
| # | ||
|
|
||
| FROM quay.io/kubesmarts/incubator-kie-sonataflow-devmode:1.36.0 | ||
|
|
||
| USER root | ||
|
|
||
| # Install Python & build dependencies | ||
| RUN microdnf install -y \ | ||
| python3 \ | ||
| python3-devel \ | ||
| gcc \ | ||
| gcc-c++ \ | ||
| make \ | ||
| libffi-devel \ | ||
| && microdnf clean all | ||
|
|
||
| # Install JEP (compiles native lib) | ||
| RUN pip3 install --no-cache-dir jep | ||
|
|
||
| # Copy jep SO file to known location | ||
| RUN PY_VER=$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")') \ | ||
| && cp /usr/local/lib64/python${PY_VER}/site-packages/jep/libjep.so /usr/lib64 | ||
|
|
||
| COPY --chown=185:185 path-to-your-python-scripts-folder /usr/local/lib64/python3.6/site-packages/my_scripts | ||
|
|
||
| USER 185 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Python workflow - Workflow demonstrating usage of Python scripts and functions | ||
| This workflow shows how to execute python functions and scripts from within a workflow. The workflow does the following: | ||
| - Uses existing python packages to determine current time and date and sets it to the workflow output. | ||
| - Calls a custom python function from a custom script. The function creates a greeting message. | ||
|
|
||
| ## Workflow diagram | ||
|  | ||
|
|
||
| ## Installation | ||
|
|
||
| See [official installation guide](https://github.com/rhdhorchestrator/serverless-workflows/blob/main/deploy/docs/main/python) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| quarkus.tls.trust-all=true | ||
| quarkus.kubernetes-client.trust-certs=true | ||
|
|
||
| # This property is used to select the log level, which controls the amount | ||
| # of information logged on HTTP requests based on the severity of the events. | ||
| # Possible values: OFF, FATAL, ERROR, WARN, INFO, DEBUG, ALL. | ||
| # and see https://quarkus.io/guides/logging for documentation | ||
| quarkus.log.category."org.apache.http".level=DEBUG | ||
| quarkus.log.level=INFO |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| FLOW_NAME=python | ||
| FLOW_SUMMARY=python | ||
| FLOW_DESCRIPTION=YAML based Python workflow |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| """ | ||
| Example script with functions to import from SonataFlow workflows | ||
| """ | ||
|
|
||
| def greet(name): | ||
| """Simple greeting function""" | ||
| return f"Hello, {name}!" | ||
|
|
||
| def process_data(data_list): | ||
| """Process a list of data""" | ||
| if not data_list: | ||
| return [] | ||
|
|
||
| processed = [item.upper() if isinstance(item, str) else str(item) for item in data_list] | ||
| return processed | ||
|
|
||
| def calculate_sum(numbers): | ||
| """Calculate sum of numbers""" | ||
| return sum(numbers) | ||
|
|
||
| class DataProcessor: | ||
| """Example class for data processing""" | ||
|
|
||
| def __init__(self, name): | ||
| self.name = name | ||
|
|
||
| def process(self, data): | ||
| """Process data with processor name""" | ||
| return f"Processed by {self.name}: {data}" | ||
|
|
||
| # Module-level variable | ||
| MODULE_VERSION = "1.0.0" | ||
|
|
||
| def workflow_helper(input_data): | ||
| """Helper function specifically for workflow usage""" | ||
| result = { | ||
| "processed": process_data(input_data.get("items", [])), | ||
| "greeting": greet(input_data.get("user", "Anonymous")), | ||
| "version": MODULE_VERSION | ||
| } | ||
| return result | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you using this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no. but this is an example for a real script with multiple functions. do u think i should remove the unused function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the use to it, you just want to show that an external script has multiple functions and some are used and some are not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exactly