简体   繁体   English

docker 在哪里上传 server.py 文件?

[英]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:9090127.0.0.1:9090machineIP:ExposePort上访问您的应用程序

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用PHP将文本作为文件上载到另一台服务器 - Upload text as file to another server with PHP 将文件上传到 apache 服务器上的虚拟机 - Upload a file to a virtual machine on apache server 无法在需要上传文件的 JMeter 中测试 API - Unable to test an API in JMeter where I need to upload a file 将文件上传到服务器php API。 需要该文件的URL作为响应 - Upload file to server php api. need url of that file in response 构建API时,解析服务器上的业务逻辑go在哪里? - Where does the business logic go on the parse server when building an API? 如何仅在python中创建一个rest api? 或者如何在服务器上运行 py 文件? - how to create a rest api in python only? or how to run the py file on server? ng2-file-upload 500内部服务器问题 - ng2-file-upload 500 internal server issue 使用AJAX将PDF作为base64文件上载到服务器 - Upload PDF as base64 file to the server using AJAX 如何让用户将文件上传到我的服务器,从而允许他们使用附加的字符串重新下载该文件 - How to let users upload a file to my server allowing them to re-download that file with an appended string 我无法将图像文件上传到服务器(Flutter-API) - I cant upload my image file to server (Flutter-API)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM