Skip to content

Return Mega/Micro Service Version number at runtime #912

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 1 commit into from
Mar 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,26 @@ class ExampleService:
self.megaservice.flow_to(embedding, llm)
```

self.gateway = ChatQnAGateway(megaservice=self.megaservice, host="0.0.0.0", port=self.port)

````

## Check Mega/Micro Service health status and version number

Use below command to check Mega/Micro Service status.

```bash
curl http://${your_ip}:${service_port}/v1/health_check\
-X GET \
-H 'Content-Type: application/json'
````

Users should get output like below example if Mega/Micro Service works correctly.

```bash
{"Service Title":"ChatQnAGateway/MicroService","Version":"1.0","Service Description":"OPEA Microservice Infrastructure"}
```

## Contributing to OPEA

Welcome to the OPEA open-source community! We are thrilled to have you here and excited about the potential contributions you can bring to the OPEA platform. Whether you are fixing bugs, adding new GenAI components, improving documentation, or sharing your unique use cases, your contributions are invaluable.
Expand Down
4 changes: 3 additions & 1 deletion comps/cores/mega/http_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ def _create_app(self):
)
async def _health_check():
"""Get the health status of this GenAI microservice."""
return {"Service Title": self.title, "Service Description": self.description}
from comps.version import __version__

return {"Service Title": self.title, "Version": __version__, "Service Description": self.description}

@app.get("/health")
async def _health() -> Response:
Expand Down
3 changes: 2 additions & 1 deletion tests/cores/mega/test_microservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def test_add_route(self):

response = self.client.get("/v1/health_check")
self.assertEqual(
response.json(), {"Service Title": "s1", "Service Description": "OPEA Microservice Infrastructure"}
response.json(),
{"Service Title": "s1", "Version": "1.2", "Service Description": "OPEA Microservice Infrastructure"},
)

response = self.client.get("/v1/sum")
Expand Down