-
Notifications
You must be signed in to change notification settings - Fork 286
Workflow executor example workflow API #1102
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
Open
JoshuaL3000
wants to merge
26
commits into
opea-project:main
Choose a base branch
from
JoshuaL3000:workflow-executor-example
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 20 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
727e9f3
Add workflow executor example
JoshuaL3000 87ed7db
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] bc5cc12
Update workflow executor example
JoshuaL3000 03f0d01
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 11344a6
Update workflow executor example
JoshuaL3000 00de5a8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 7f8f957
Rename CI script to 'test_compose_on_xeon.sh'
JoshuaL3000 14944f9
Update test files and add custom prompt
JoshuaL3000 891324f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] f8f3afd
Rename test script
JoshuaL3000 62fd863
Fix start_vllm_service.sh and handle convert dict to str in tools.py
JoshuaL3000 d251aa5
Update workflow id and retest pydantic version
JoshuaL3000 bfb0522
Add docstring for multiple files
JoshuaL3000 b784a68
Update workflow executor example for example workflow API
JoshuaL3000 77675ce
Update readme for example workflow
JoshuaL3000 3745142
Update test scripts and readme
JoshuaL3000 9b14045
Update workflow executor example for example workflow API
JoshuaL3000 07d4ed4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 683654b
Update workflow id
JoshuaL3000 0098bf1
Merge branch 'main' into workflow-executor-example
xiguiw 256dfbd
Merge branch 'main' into workflow-executor-example
chensuyue e4e8a70
Merge branch 'main' into workflow-executor-example
ZePan110 0523b68
Update docker compose path for agent comps change
JoshuaL3000 cbc87e7
Merge branch 'main' into workflow-executor-example
JoshuaL3000 8bb3f30
Enable test for workflow example API after package upgrades
JoshuaL3000 219cab2
Update wf_api_port
JoshuaL3000 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
set -e | ||
|
||
WORKPATH=$(dirname "$PWD") | ||
vllm_port=${vllm_port} | ||
[[ -z "$vllm_port" ]] && vllm_port=8084 | ||
export WORKDIR=$WORKPATH/../../ | ||
echo "WORKDIR=${WORKDIR}" | ||
export SDK_BASE_URL=$1 | ||
export SERVING_TOKEN=${SERVING_TOKEN} | ||
export HF_TOKEN=${HUGGINGFACEHUB_API_TOKEN} | ||
export llm_engine=vllm | ||
export ip_address=$(hostname -I | awk '{print $1}') | ||
export llm_endpoint_url=http://${ip_address}:${vllm_port} | ||
export model=mistralai/Mistral-7B-Instruct-v0.3 | ||
export recursion_limit=25 | ||
export temperature=0 | ||
export max_new_tokens=1000 | ||
export TOOLSET_PATH=$WORKDIR/GenAIExamples/WorkflowExecAgent/tools/ | ||
|
||
function start_agent() { | ||
echo "Starting Agent services" | ||
cd $WORKDIR/GenAIExamples/WorkflowExecAgent/docker_compose/intel/cpu/xeon | ||
WORKDIR=$WORKPATH/docker_image_build/ docker compose -f compose_vllm.yaml up -d | ||
echo "Waiting agent service ready" | ||
sleep 5s | ||
} | ||
|
||
function main() { | ||
echo "==================== Start agent service ====================" | ||
start_agent | ||
echo "==================== Agent service started ====================" | ||
} | ||
|
||
main |
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,40 @@ | ||
#!/bin/bash | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
set -e | ||
|
||
wf_api_port=${wf_api_port} | ||
[[ -z "$wf_api_port" ]] && wf_api_port=5000 | ||
WORKPATH=$(dirname "$PWD") | ||
LOG_PATH="$WORKPATH/tests/example_workflow" | ||
export WORKDIR=$WORKPATH/../../ | ||
echo "WORKDIR=${WORKDIR}" | ||
|
||
function start_example_workflow_api() { | ||
echo "Starting example workflow API" | ||
cd $WORKDIR/GenAIExamples/WorkflowExecAgent/tests/example_workflow | ||
docker build -f Dockerfile.example_workflow_api -t example-workflow-service . | ||
docker run -d -p ${wf_api_port}:${wf_api_port} --rm --network=host --name example-workflow-service -it example-workflow-service | ||
echo "Waiting example workflow API ready" | ||
until [[ "$n" -ge 100 ]] || [[ $ready == true ]]; do | ||
docker logs example-workflow-service &> ${LOG_PATH}/example-workflow-service.log | ||
n=$((n+1)) | ||
if grep -q "Uvicorn running on" ${LOG_PATH}/example-workflow-service.log; then | ||
break | ||
fi | ||
if grep -q "No such container" ${LOG_PATH}/example-workflow-service.log; then | ||
echo "container example-workflow-service not found" | ||
exit 1 | ||
fi | ||
sleep 5s | ||
done | ||
} | ||
|
||
function main() { | ||
echo "==================== Start example workflow API ====================" | ||
start_example_workflow_api | ||
echo "==================== Example workflow API started ====================" | ||
} | ||
|
||
main |
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
11 changes: 11 additions & 0 deletions
11
WorkflowExecAgent/tests/example_workflow/Dockerfile.example_workflow_api
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 @@ | ||
FROM ubuntu:22.04 | ||
|
||
RUN apt-get -qq update | ||
|
||
WORKDIR /home/ubuntu | ||
|
||
COPY launch_workflow_service.sh requirements.txt main.py workflow.py ./ | ||
|
||
RUN chmod +x ./launch_workflow_service.sh | ||
|
||
CMD ["./launch_workflow_service.sh"] |
18 changes: 18 additions & 0 deletions
18
WorkflowExecAgent/tests/example_workflow/launch_workflow_service.sh
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,18 @@ | ||
#!/bin/bash | ||
|
||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
apt-get -qq -y install --no-install-recommends unzip curl ca-certificates | ||
apt-get -qq -y install --no-install-recommends python3 python3-pip | ||
|
||
curl -L -o ./archive.zip https://www.kaggle.com/api/v1/datasets/download/blastchar/telco-customer-churn | ||
unzip ./archive.zip -d ./ | ||
rm ./archive.zip | ||
|
||
pip install virtualenv && \ | ||
virtualenv venv && \ | ||
source venv/bin/activate && \ | ||
pip install -r requirements.txt | ||
|
||
uvicorn main:app --reload --port=5000 --host=0.0.0.0 |
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,58 @@ | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import logging | ||
|
||
from fastapi import APIRouter, FastAPI | ||
from workflow import run_workflow | ||
|
||
logger = logging.getLogger(__name__) | ||
logger.setLevel(logging.DEBUG) | ||
|
||
app = FastAPI() | ||
|
||
router = APIRouter(prefix="/serving", tags=["Workflow Serving"]) | ||
|
||
app.results = {} | ||
|
||
|
||
@router.post("/servable_workflows/{wf_id}/start", summary="Start Workflow") | ||
async def start_workflow(wf_id: int, params: dict): | ||
try: | ||
app.results = run_workflow(params["params"]) | ||
wf_key = "example_key" | ||
return {"msg": "ok", "wf_key": wf_key} | ||
|
||
except Exception as e: | ||
logging.error(e, exc_info=True) | ||
return {"msg": "error occurred"} | ||
|
||
|
||
@router.get("/serving_workflows/{wf_key}/status", summary="Get Workflow Status") | ||
async def get_status(wf_key: str): | ||
try: | ||
if app.results: | ||
status = "finished" | ||
else: | ||
status = "failed" | ||
|
||
return {"workflow_status": status} | ||
except Exception as e: | ||
logging.error(e) | ||
return {"msg": "error occurred"} | ||
|
||
|
||
@router.get("/serving_workflows/{wf_key}/results", summary="Get Workflow Results") | ||
async def get_results(wf_key: str): | ||
try: | ||
if app.results: | ||
return app.results | ||
else: | ||
return {"msg": "There is an issue while getting results !!"} | ||
|
||
except Exception as e: | ||
logging.error(e) | ||
return {"msg": "There is an issue while getting results !!"} | ||
|
||
|
||
app.include_router(router) |
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,7 @@ | ||
fastapi | ||
numpy | ||
pandas | ||
requests==2.28.1 | ||
scikit-learn | ||
uvicorn | ||
xgboost | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please check with Suyue if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @lvliang-intel, Suyue has confirmed xgboost is in the BOM list |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.