Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 6144

FileNotFoundError: [Errno 2] No such file or directory: 'app/mlsample/model/clf.joblib'

$
0
0

I'm trying now to build my docker imageI have my app.py:

import pandas as pdfrom flask import Flask, request, render_templateimport osfrom joblib import loadMODEL_DIR = os.environ["MODEL_DIR"]MODEL_FILE = os.environ["MODEL_FILE"]METADATA_FILE = os.environ["METADATA_FILE"]MODEL_PATH = os.path.join(MODEL_DIR, MODEL_FILE)METADATA_PATH = os.path.join(MODEL_DIR, METADATA_FILE)app = Flask(__name__)#Loading modelclf = load(MODEL_PATH)@app.route('/', methods=['GET', 'POST'])def index():    result = ''    text = ''    #print(clf.predict(["I am angry"]))    if request.method == 'POST':        text = request.form.get("textTocompute")        result = clf.predict([text])    return render_template("index.html", result=result, text=text)if __name__ == "__main__":    app.run(host='0.0.0.0')

the requirements.txt:flaskjoblibnumpypandasmatplotlibscikit-learn

and the Dockerfile :

FROM python:3.6WORKDIR /appRUN mkdir ./mlsampleRUN mkdir ./mlsample/modelENV MODEL_DIR=app/mlsample/modelENV MODEL_FILE=clf.joblibENV METADATA_FILE=metadata.jsonENV FLASK_APP=app.pyCOPY requirements.txt .RUN pip install -r requirements.txtCOPY reviewDataCleaned.csv .COPY docker-ml.py .RUN python ./docker-ml.pyCOPY app.py .COPY templates ./templatesEXPOSE 5000CMD ["python", "app.py"]

I want to build this but I got this error:

=> ERROR [ 9/11] RUN python ./docker-ml.py 32.8s

[ 9/11] RUN python ./docker-ml.py:                                                                                   32.42 Loading reviewDataCleaned dataset...                                                                              32.42 fitting model                                                                                                     32.42 Serializing model to app/mlsample/model/clf.joblib                                                                32.42 Traceback (most recent call last):                                                                                32.42   File "./docker-ml.py", line 54, in <module>32.42     dump(clf,MODEL_PATH)32.42   File "/usr/local/lib/python3.6/site-packages/joblib/numpy_pickle.py", line 481, in dump32.42     with open(filename, 'wb') as f:32.42 FileNotFoundError: [Errno 2] No such file or directory: 'app/mlsample/model/clf.joblib'

Dockerfile:25

  23 |     COPY docker-ml.py .  24 |       25 | >>> RUN python ./docker-ml.py  26 |       27 |     COPY app.py .--------------------ERROR: failed to solve: process "/bin/sh -c python ./docker-ml.py" did not complete successfully: exit code: 1

How can I fix it?


Viewing all articles
Browse latest Browse all 6144

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>