Toke Emil Heldbo Reines
11/12/2024, 9:22 AMpath="/" destroys the open API documentation and gives "Not found. E.g. This simple API:
import bentoml
from fastapi import Depends, FastAPI
app = FastAPI()
@bentoml.service(
name="The_cake_is_a_lie",
)
@bentoml.mount_asgi_app(app) # Only works with path="/"
class Service:
@bentoml.api(output_spec=dict)
def classify(self) -> dict:
return {"Cake": None}
@app.get("/metadata", tags=["Metadata"])
def metadata():
return {"metadata": "Yay"}
if __name__ == "__main__":
Service.serve_http(port=3000)
I have services that calls asgi endpoints on root, like "/some_statistics", etc, but it only works if they get their own path. Is this intended or can I circumvent it somehow?Chaoyu
11/12/2024, 9:33 AMself to access the service
return f"Hello {self.name}"`Chaoyu
11/12/2024, 9:33 AMToke Emil Heldbo Reines
11/12/2024, 9:34 AMChaoyu
11/12/2024, 10:00 AMChaoyu
11/12/2024, 10:00 AMToke Emil Heldbo Reines
11/12/2024, 10:01 AM@app.get("/metadata", tags=["Metadata"])
def metadata(service: XrayService = dependable_service):
mlflow = service.bentoml_model.custom_objects["mlflow"]
# We convert nans to -1 to avoid serialization issues
metrics = mlflow["metrics"]
metrics = {k: -1 if np.isnan(v) else v for k, v in metrics.items()}
mlflow["metrics"] = metrics
return {
"name": service.bentoml_model.tag.name,
"version": service.bentoml_model.tag.version,
"config": service.bentoml_model.custom_objects["config"],
"output_schema": service.bentoml_model.custom_objects["output_schema"],
"mlflow": mlflow,
}
Anything mlflow related, training/evaluation metrics, version etc. Making sure that the model i containerized is actually the one being served 🙂Chaoyu
11/12/2024, 10:02 AMChaoyu
11/12/2024, 10:02 AMChaoyu
11/12/2024, 10:02 AMToke Emil Heldbo Reines
11/12/2024, 10:03 AMChaoyu
11/12/2024, 10:03 AMToke Emil Heldbo Reines
11/12/2024, 10:04 AMToke Emil Heldbo Reines
11/12/2024, 10:04 AMChaoyu
11/12/2024, 10:05 AM