如何在 REST API 请求中指定模型版本标签?
How to specify the model version label in a REST API request?
如文档中所述,使用 version_labels
字段,您可以为模型版本指定标签以处理金丝雀部署。
例如,您可以将模型 43 标记为 stable
,将模型 44 标记为 canary
。
这个功能听起来很不错,但我没有在文档中找到如何调整我的 POST 请求以指定我想使用的标签。
直到现在,我一直在使用这样的东西:
curl -d '{"instances": <<my input data>>}' -X POST http://localhost:8501/v1/models/<<my model name>>:predict
有什么想法吗?
此处定义了 TensorFlow Serving 的 REST API:https://www.tensorflow.org/tfx/serving/api_rest#url_4
对于预测方法,它将是:
http://host:port/v1/models/${MODEL_NAME}[/versions/${MODEL_VERSION}]:predict
其中 ${MODEL_VERSION}
将是 stable
或 canary
更新:
根据对 this GitHub 问题的评论,@misterpeddy 指出,截至 2019 年 8 月 14 日:
Re: not being able to access the version using labels via HTTP - this is something that's not possible today (AFAIR) - only through the grpc interface can you declare labels :(
据我所知,此功能尚未实现。
原答案:
看起来 HTTP API 处理程序的当前实现希望版本为数字。
您可以看到试图解析 URL here.
的正则表达式
prediction_api_regex_(
R"((?i)/v1/models/([^/:]+)(?:/versions/(\d+))?:(classify|regress|predict))")
\d
定义了对数字版本指示符而不是文本标签的期望。
我已经打开了相应的 TensorFlow Serving 问题 here。
如文档中所述,使用 version_labels
字段,您可以为模型版本指定标签以处理金丝雀部署。
例如,您可以将模型 43 标记为 stable
,将模型 44 标记为 canary
。
这个功能听起来很不错,但我没有在文档中找到如何调整我的 POST 请求以指定我想使用的标签。
直到现在,我一直在使用这样的东西:
curl -d '{"instances": <<my input data>>}' -X POST http://localhost:8501/v1/models/<<my model name>>:predict
有什么想法吗?
此处定义了 TensorFlow Serving 的 REST API:https://www.tensorflow.org/tfx/serving/api_rest#url_4
对于预测方法,它将是:
http://host:port/v1/models/${MODEL_NAME}[/versions/${MODEL_VERSION}]:predict
其中 ${MODEL_VERSION}
将是 stable
或 canary
更新:
根据对 this GitHub 问题的评论,@misterpeddy 指出,截至 2019 年 8 月 14 日:
Re: not being able to access the version using labels via HTTP - this is something that's not possible today (AFAIR) - only through the grpc interface can you declare labels :(
据我所知,此功能尚未实现。
原答案:
看起来 HTTP API 处理程序的当前实现希望版本为数字。
您可以看到试图解析 URL here.
的正则表达式prediction_api_regex_(
R"((?i)/v1/models/([^/:]+)(?:/versions/(\d+))?:(classify|regress|predict))")
\d
定义了对数字版本指示符而不是文本标签的期望。
我已经打开了相应的 TensorFlow Serving 问题 here。