0Pricing
MLOps Academy · درس

تحديد خدمة وواجهة برمجة التطبيقات الخاصة بها

اعرض runners عبر نقطة نهاية خدمة ذات أنواع محددة.

تحديد خدمة وواجهة برمجة التطبيقات الخاصة بها درس مجاني في MLOps Academy على CoddyKit. هذا هو الدرس 2 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في MLOps Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة MLOps Academy 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

What a Service Is

In BentoML a Service is the unit you deploy. It wraps your model and exposes one or more API endpoints clients can call. 🛎️

Runners Run the Model

A runner is BentoML's optimized wrapper around a saved model. It handles inference in its own worker so the API stays responsive.

runner = bentoml.sklearn.get("iris_clf:latest").to_runner()

Create the Service

You build a service by naming it and passing its runners. The Service object is what BentoML serves and scales.

svc = bentoml.Service("iris_classifier", runners=[runner])

Add an Endpoint

You expose a function as an API with the @svc.api decorator. That function becomes a callable HTTP route.

@svc.api(input=..., output=...)
def classify(data):
    ...

Declare Input and Output

You set typed IO descriptors so BentoML can validate and serialize. NumpyNdarray tells it to expect and return arrays.

from bentoml.io import NumpyNdarray

Call the Runner Inside

Within the API function you invoke the model through the runner. Using run sends the input to the model worker and returns the result.

result = runner.predict.run(data)
return result

Put It in service.py

BentoML looks for your code in a file by convention. You place the service in service.py at your project root.

Serve It Locally

One command starts a dev server. bentoml serve points at the file and the svc object, then watches for changes.

bentoml serve service:svc --reload

Use JSON for Dicts

Not every API speaks arrays. Swap the descriptor to JSON when your clients send and expect dictionaries instead.

from bentoml.io import JSON

Built-In Swagger Docs

Once it runs, BentoML serves interactive Swagger docs at the root URL so you can test each endpoint in the browser. 🎉

Test with a curl Call

You can hit the live endpoint from your terminal. A quick curl POST sends sample input and shows the prediction it returns.

curl -X POST localhost:3000/classify -d "[[5.1,3.5,1.4,0.2]]"

Quick Check

You want to call your model from inside an API function. What is the right wrapper to use?

Recap

You turned a runner into a Service, exposed an @svc.api endpoint with typed IO, dropped it in service.py, and served it with built-in docs. Live API done! 🙌

الأسئلة الشائعة

هل درس «تحديد خدمة وواجهة برمجة التطبيقات الخاصة بها» مجاني؟

نعم — نص درس «تحديد خدمة وواجهة برمجة التطبيقات الخاصة بها» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة MLOps Academy، انتقل إلى CoddyKit PRO. تتضمن دورة MLOps Academy 4 دروس في المجموع.

ماذا ستتعلم في «تحديد خدمة وواجهة برمجة التطبيقات الخاصة بها»؟

اعرض runners عبر نقطة نهاية خدمة ذات أنواع محددة. تتمرن على MLOps Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ MLOps Academy؟

لا تُشترط خبرة سابقة. MLOps Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 2 من أصل 4.

كم من الوقت يستغرق درس «تحديد خدمة وواجهة برمجة التطبيقات الخاصة بها»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس MLOps Academy هذا؟

نعم. كل درس في MLOps Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. حفظ نموذج في Bento Store
  2. تحديد خدمة وواجهة برمجة التطبيقات الخاصة بها
  3. تمكين المعالجة الدفعية التكيفية
  4. بناء Bento وتحويله إلى حاوية
← العودة إلى MLOps Academy