MLRun deploy_function调用失败:404 Client Error问题求助
我正在遵循MLRun快速入门教程,执行project.deploy_function(serving_fn)前一切正常,但调用时返回如下错误:
error submitting nuclio deploy task: 404 Client Error: Not Found for url: http://localhost:8080/api/v1/projects/first-project-xxx/nuclio/serving/deploy: details: Not Found, caused by: 404 Client Error: Not Found for url: http://localhost:8080/api/v1/projects/first-project-xxx/nuclio/serving/deploy
通过Docker安装了MLRun,可访问MLRun UI(http://localhost:8060)、Nuclio Dashboard/controller(http://localhost:8070),但MLRun API(http://localhost:8080)返回{"detail":"Not Found"}。在IDE中运行教程代码,能在MLRun UI看到项目,但部署服务函数时失败,找不到对应OpenAPI格式的API文档验证路径有效性,希望了解配置问题或正确的API调用方式。
1. 确认MLRun API的实际运行端口
Docker部署的MLRun默认API端口并非8080,通常是5000。执行以下命令查看容器端口映射:
docker ps | grep mlrun-api
查看输出中的端口映射(比如0.0.0.0:5000->8080/tcp),这里外部访问端口是5000,而非8080。
2. 修正MLRun客户端的API地址配置
在代码开头指定正确的API地址:
import mlrun mlrun.set_env("MLRUN_API_URL", "http://localhost:5000")
或者在运行代码前设置环境变量:
export MLRUN_API_URL=http://localhost:5000
3. 验证API服务可用性
访问修正后的API根路径(比如http://localhost:5000/api/v1),如果返回包含projects等端点的JSON响应,说明服务正常。若仍返回404,重启MLRun API容器:
docker restart mlrun-api
4. 确保Nuclio与MLRun的集成配置正确
在代码中明确指定Nuclio地址,避免集成错误:
serving_fn.spec.nuclio_env = {"NUCLIO_DASHBOARD_URL": "http://localhost:8070"}
5. 核对项目名称的准确性
错误中的项目名为first-project-xxx,确保代码中使用的项目名与MLRun UI中显示的完全一致,无拼写或格式错误。
内容的提问来源于stack exchange,提问作者Arnaud

