[英]where does docker upload server.py file?
Setting: lots of mp3 records of customer support conversations somewhere in a db.设置:数据库中某处的大量客户支持对话的 mp3 记录。 Each mp3 record has 2 channels, one is customer rep, another is customer's voice.
每个 mp3 记录有 2 个通道,一个是客户代表,另一个是客户的声音。
I need to extract embedding(tensor) of a customer's voice.我需要提取客户声音的嵌入(张量)。 It's a 3 step process: get the channel, cut 10 secs, convert to embedding.
这是一个 3 步过程:获取通道、剪切 10 秒、转换为嵌入。 I have all 3 functions for each step.
我为每个步骤提供了所有 3 个功能。
embedding is a vector tensor: embedding 是一个向量张量:
"tensor([[0.6540e+00, 0.8760e+00, 0.898e+00,
0.8789e+00, 0.1000e+00, 5.3733e+00]])
Tested with postman.用 postman 测试。 Get embedding function:
获取嵌入 function:
I want to build a rest api that connects on 1 endpoint to the db of mp3 files and outputs embedding to another db.我想构建一个 rest api,它在 1 个端点上连接到 mp3 文件的数据库,并将嵌入输出到另一个数据库。
I need to clarify important feature about docker.我需要澄清关于 docker 的重要特征。
When i run "python server.py" flask makes it available on my local pc - 127.0.1.01/9090:当我运行“python server.py”flask 时,它可以在我的本地电脑上使用 - 127.0.1.01/9090:
def get_embedding(file):
#some code
@app.route('/health')
def check():
return jsonify({'response':'OK!'})
@app.route('/get_embedding')
def show_embedding():
return get_embedding(file1)
if __name__ == '__main__':
app.run(debug=True, port=9090)
when i do it with docker - where goes the server and files?当我使用 docker 进行操作时 - 服务器和文件在哪里? where does it become available online, can docker upload all the files to default docker cloud?
它在哪里可以在线获得,docker 可以将所有文件上传到默认的 docker 云吗?
You need to write a Dockerfile to build your Docker image and after that, Run a container
from that image exposing on the port and then you can access it machineIP:PORT
您需要编写一个 Dockerfile 来构建您的 Docker 映像,然后,从该映像运行一个
container
,暴露在端口上,然后您可以访问它machineIP:PORT
Below is the example Dockerfile下面是示例Dockerfile
#FROM tells Docker which image you base your image on (in the example, Python 3).
FROM python:3
#WORKDIR tells which directory container has to word
WORKDIR /usr/app
# COPY files from your host to the image working directory
COPY my_script.py .
#RUN tells Docker which additional commands to execute.
RUN pip install pystrich
CMD [ "python", "./my_script.py" ]
Ref:- https://docs.docker.com/engine/reference/builder/
参考:- https://docs.docker.com/engine/reference/builder/
And then build the image, docker build -t server.
然后构建镜像,
docker build -t server.
Ref:- https://docs.docker.com/engine/reference/commandline/build/
参考:- https://docs.docker.com/engine/reference/commandline/build/
Once, Image is built start a container and expose the port through which you can access your application.构建完 Image 后,启动一个容器并公开端口,您可以通过该端口访问您的应用程序。 Eg
例如
docker run -p 9090:9090 server
-p
Publish a container's port(s) to the host -p
将容器的端口发布到主机
And access your application on localhost:9090
or 127.0.0.1:9090
or machineIP:ExposePort
并在
localhost:9090
或127.0.0.1:9090
或machineIP:ExposePort
上访问您的应用程序
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.