Submit your innovative use case or inspiring success story to the 2023 Dataiku Frontrunner Awards! LET'S GO

Streamlit webapp .get_predictor()

mfnz
Level 1
Streamlit webapp .get_predictor()

Hi everyone,

I am attempting to convert a Dash webapp to Streamlit. The app simply takes inputs parameters from the users and generates predictions based on a model trained in the same flow where the app is stored.

Although everything works smoothly in both Dash and Streamlit, I am encountering issues when attempting to call the machine learning models in Streamlit.

Below is the code snippet that is returning an error in Streamlit:

model = dataiku.Model("3cxcmJox")
model_pred = model.get_predictor()

 FileNotFoundError: [Errno 2] No such file or directory: '/home/dataiku/data/saved_models/FLOW/3cxcmJox/versions/1664296109477/core_params.json'

File "/opt/dataiku/python-code-envs/pyenv-streamlit/lib/python3.7/site-packages/streamlit/scriptrunner/script_runner.py", line 475, in _run_script
exec(code, module.__dict__)

File "/home/dataiku/workspace/code_studio-versioned/streamlit/app.py", line 122, in <module>
model.get_predictor()

File "/opt/dataiku/python/dataiku/core/saved_model.py", line 278, in get_predictor
self._predictors[version_id] = build_predictor_for_saved_model(model_folder, sm.get("conditionalOutputs", []))

File "/opt/dataiku/python/dataiku/core/saved_model.py", line 402, in build_predictor_for_saved_model
core_params = dkujson.load_from_filepath(osp.join(model_folder, "core_params.json"))

File "/opt/dataiku/python/dataiku/core/dkujson.py", line 37, in load_from_filepath
with open(filepath) as fp:

 

Does anyone have a solution to this issue?

Thanks in advance

 

0 Kudos
2 Replies
AlexT
Dataiker

Hi @mfnz,
The get_predictor does not currently work in a container and streamlit webapp runs only in containerized execution.
For now, you won't be able to use get_predictor in the streamlet webapp as this now requires direct access to the DSS filesystem.

We are working on allowing get_predictor to in a containerized environment in a future release. 

Thanks

sreejay222
Level 2

Hi AlexT, 

is there any other way we can read the saved model to containers? 

0 Kudos