简体   繁体   中英

where does docker upload server.py file?

Setting: lots of mp3 records of customer support conversations somewhere in a db. Each mp3 record has 2 channels, one is customer rep, another is customer's voice.

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. I have all 3 functions for each step.

embedding is a vector tensor:

"tensor([[0.6540e+00, 0.8760e+00, 0.898e+00, 
    0.8789e+00, 0.1000e+00, 5.3733e+00]])

Tested with postman. Get embedding 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.

I need to clarify important feature about docker.

When i run "python server.py" flask makes it available on my local pc - 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? where does it become available online, can docker upload all the files to default docker cloud?

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

Below is the example 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/

And then build the image, docker build -t server.

Ref:- 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. Eg

docker run -p 9090:9090 server

-p Publish a container's port(s) to the host

And access your application on localhost:9090 or 127.0.0.1:9090 or machineIP:ExposePort

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM