Skip to content

Commit

Permalink
migrate all the ut cases under cores and fix bug (opea-project#47)
Browse files Browse the repository at this point in the history
Signed-off-by: chensuyue <[email protected]>
Signed-off-by: lvliang-intel <[email protected]>
  • Loading branch information
chensuyue authored May 13, 2024
1 parent ca18b19 commit a9399ed
Show file tree
Hide file tree
Showing 15 changed files with 17 additions and 16 deletions.
17 changes: 10 additions & 7 deletions .github/workflows/mega-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ on:
types: [opened, reopened, ready_for_review, synchronize] # added `ready_for_review` since draft is skipped
paths:
- .github/workflows/mega-test.yml
- comps/mega/**
- comps/cores/**
- requirements.txt
- setup.py
- tests/mega/**
- tests/cores/**
workflow_dispatch:

# If there is a new commit, the previous jobs will be canceled
Expand All @@ -29,7 +29,14 @@ jobs:
runs-on: aise-cluster
steps:
- name: Clean Up Working Directory
run: sudo rm -rf ${{github.workspace}}/*
run: |
sudo rm -rf ${{github.workspace}}/*
if [[ $(docker ps -a | grep -i '${{ env.CONTAINER_NAME }}'$) ]]; then
docker start ${{ env.CONTAINER_NAME }}
echo "remove left files through container ..."
docker exec ${{ env.CONTAINER_NAME }} bash -c "rm -fr /GenAIComps || true"
docker stop ${{ env.CONTAINER_NAME }} && docker rm -vf ${{ env.CONTAINER_NAME }} || true
fi
- name: Checkout out Repo
uses: actions/checkout@v4
Expand All @@ -42,10 +49,6 @@ jobs:
- name: Docker Run
run: |
if [[ $(docker ps -a | grep -i '${{ env.CONTAINER_NAME }}'$) ]]; then
docker stop ${{ env.CONTAINER_NAME }}
docker rm -vf ${{ env.CONTAINER_NAME }} || true
fi
docker run -dit --memory="4g" --memory-reservation="1g" --disable-content-trust --privileged --name=${{ env.CONTAINER_NAME }} --shm-size="1g" \
-v ${{ github.workspace }}:/GenAIComps ut-test:1.0
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/scripts/test_ut.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ ut_log_name=/GenAIComps/.github/workflows/scripts/${test_name}_ut.log
cd /GenAIComps/tests
if [ $test_name = 'mega' ]; then
echo "run mega test"
cd mega
cd cores
find . -name "*.yaml" -exec sh -c 'x="{}"; cp $x ./' \;
find . -name "test*.py" | sed 's,\.\/,python -m pytest -vs --disable-warnings ,g' > run.sh
bash run.sh 2>&1 | tee ${ut_log_name}
else
Expand Down
2 changes: 1 addition & 1 deletion comps/cores/mega/orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
class ServiceOrchestrator(DAG):
"""Manage 1 or N micro services in a DAG through Python API."""

def __init__(self, host="0.0.0.0", port=8000, endpoint=MegaServiceEndpoint.CHAT_QNA) -> None:
def __init__(self, host="0.0.0.0", port=8000, endpoint=str(MegaServiceEndpoint.CHAT_QNA)) -> None:
self.services = {} # all services, id -> service
self.result_dict = {}
self.host = host
Expand Down
Empty file removed comps/cores/telemetry/README.md
Empty file.
3 changes: 0 additions & 3 deletions comps/cores/telemetry/requirements.txt

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def setUp(self):
self.s1 = opea_microservices["s1"]
self.s1.start()

self.service_builder = ServiceOrchestrator(port=8000)
self.service_builder = ServiceOrchestrator(port=7777)

def tearDown(self):
self.s1.stop()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def tearDown(self):
self.s1.stop()

def test_add_remote_service(self):
service_builder = ServiceOrchestratorWithYaml(yaml_file_path="./megaservice_hybrid.yaml")
service_builder = ServiceOrchestratorWithYaml(yaml_file_path="megaservice_hybrid.yaml")
self.assertEqual(service_builder.all_leaves()[0], "s2")
self.assertEqual(service_builder.docs["opea_micro_services"]["s2"]["endpoint"], "http://fakehost:8008/v1/add")

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def setUp(self):
self.s1.start()
self.s2.start()

self.service_builder = ServiceOrchestrator(port=8000)
self.service_builder = ServiceOrchestrator(port=9999)

self.service_builder.add(opea_microservices["s1"]).add(opea_microservices["s2"])
self.service_builder.flow_to(self.s1, self.s2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def tearDown(self):
self.s2.stop()

def test_schedule(self):
service_builder = ServiceOrchestratorWithYaml(yaml_file_path="./megaservice.yaml")
service_builder = ServiceOrchestratorWithYaml(yaml_file_path="megaservice.yaml")
service_builder.schedule(initial_inputs={"text": "Hello, "})
service_builder.get_all_final_outputs()
result_dict = service_builder.result_dict
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit a9399ed

Please sign in to comment.