Я построил модель и поместил ее за AI Platform.
Я бы хотел получить дополнительные данные из Firestore (которые я использую для хранения документов) перед отправкой прогноза.
Возможно ли это?
Если нет, то как обойти эту проблему? Одним из способов является создание другого микросервиса, который подключается к Firebase и возвращает объект, но я бы предпочел хранить все в 1 контейнере.
Например, используя пользовательский конвейер прогнозирования, у меня есть:
class MyPredictor(object):
"""An example Predictor for an AI Platform custom prediction routine."""
def __init__(self, model):
"""Stores artifacts for prediction. Only initialized via `from_path`.
"""
self._model = model
def predict(self, instances, **kwargs):
"""Performs custom prediction.
Preprocesses inputs, then performs prediction using the trained
scikit-learn model.
Args:
instances: A list of prediction input instances.
**kwargs: A dictionary of keyword args provided as additional
fields on the predict request body.
Returns:
A list of outputs containing the prediction results.
"""
# inputs = np.asarray(instances)
# outputs = self._model.predict(inputs)
import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore
cred = credentials.ApplicationDefault()
return cred
Но это дает мне Внутреннюю ошибку при обслуживании прогноза на AI-Platform.