0

I am trying to test a model that I onboarded to the Acumos platform (with python client). Running the image in docker fails with this error :

File "h5py/h5f.pyx", line 85, in h5py.h5f.open OSError: Unable to open file (unable to open file: name = 'data/keras/ticketsModel/model.hdf5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)

My code looks like that :

from acumos.session import AcumosSession
from acumos.modeling import Model, List, create_dataframe
from tensorflow.python.keras.models import load_model

# This version tells me : unable to open file: name = 'data/keras/ticketsModel/model.hdf5'
#def classify_ticket(inText: str) -> str:
#    current_model = load_model('data/keras/ticketsModel/model.hdf5')
#    return current_model.predict(inText)

# This version tells me : NotImplementedError: numpy() is only available when eager execution is enabled.
current_model = load_model('data/keras/ticketsModel/model.hdf5')
def classify_ticket(inText: str) -> str:
    return current_model.predict(inText)

model = Model(classify=classify_ticket)
session = AcumosSession()
session.dump(model,'ticket_classification','acumos_out')

Any help is greatly appreciated !

  • It appears that the Acumos python client library did not pick up your HDF5 file and include it in the bundle that was on-boarded. I've asked our expert to respond here. – chrisinmtown Mar 21 '19 at 17:01
  • `error message = 'No such file or directory'` - I think it's a pretty clear error message – ForceBru Mar 21 '19 at 17:02
  • What does your `Dockerfile` look like? – C.Nivs Mar 21 '19 at 17:12
  • Thanks for your help ; what do you mean by "what does you Dockerfile look like" ? The docker image starts correctly by saying [2019-03-21 16:20:26 +0000] [1] [INFO] Starting gunicorn 19.9.0 [2019-03-21 16:20:26 +0000] [1] [INFO] Listening at: http://0.0.0.0:3330 (1) [2019-03-21 16:20:26 +0000] [1] [INFO] Using worker: sync [2019-03-21 16:20:26 +0000] [15] [INFO] Booting worker with pid: 15 [2019-03-21 16:20:26 +0000] [16] [INFO] Booting worker with pid: 16 Adding route /classify [input:['inText'], output:['value']] Adding route /classify [input:['inText'], output:['value']] – frédéric chantrel Mar 21 '19 at 17:27
  • @C.Nivs is asking how the docker image was built. Those instructions are often in a file named "Dockerfile". But that is not relevant in Acumos, where the docker image is constructed by a service automatically. – chrisinmtown Mar 21 '19 at 19:46

2 Answers2

0

The acumos library currently serializes models on behalf of users so that it can bundle objects in a portable manner while minimizing developer effort. An option to provide custom serialization logic may be added in the future however.

The solution to your problem should be to load your model above the function definition, e.g.:

current_model = load_model('data/keras/ticketsModel/model.hdf5')

def classify_ticket(inText: str) -> str:
    return current_model.predict(inText)
trianta2
  • 3,952
  • 5
  • 36
  • 52
  • Before doing this the model was loaded above the function definition but I had an other error : AttributeError: 'Model' object has no attribute 'predict'. – frédéric chantrel Mar 21 '19 at 20:18
  • That means `current_model` does not have a `predict` method. Perhaps you should check that `current_model` is the type you expect. – trianta2 Mar 21 '19 at 20:25
  • When I replace the three last lines of the code in my first comment by this call **test_prediction = classify_ticket("this is my test")** everything works fine so the current_model have a predict method. The load_method comes from here **from tensorflow.python.keras.models import load_model** – frédéric chantrel Mar 21 '19 at 20:49
  • @frédéricchantrel Please update your original question with the latest code. – chrisinmtown Mar 22 '19 at 13:07
  • @chrisinmtown I've updated my original question with the 2 errors in comment – frédéric chantrel Mar 22 '19 at 13:37
  • @chrisinmtown Sorry, I had two variables with the same name so that's why there was no method predict ! But now I've got a new error during the dump of acumos : "numpy() is only available when eager execution is enabled.") NotImplementedError: numpy() is only available when eager execution is enabled. Have you got an idea of what's wrong ? – frédéric chantrel Mar 22 '19 at 14:01
  • @frédéricchantrel I see your new SO question for the numpy issue. If this one is solved, please accept trianta2's answer by clicking on the big check mark next to it. – chrisinmtown Mar 22 '19 at 14:54
0

Can you look inside the zip file generated when you dump the model and tell me all the files that are there and their sized?