INNER CODE UNIT · Python

__call__

maxpumperla/learning_ray · notebooks/app.py:19

    def __call__(self, request) -> str:
        input_text = request.query_params["input_text"]
        return self._classifier(input_text)[0]["label"]


basic_deployment = SentimentAnalysis.bind()


@serve.deployment(num_replicas=2, ray_actor_options={"num_cpus": 2})
@serve.ingress(app)
class SentimentAnalysis:
    def __init__(self):
        self._classifier = pipeline("sentiment-analysis")

    @app.get("/")
    def classify(self, input_text: str) -> str:
        import os
        print("from process:", os.getpid())

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…