<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Error: batch scoring with mlflow.keras flavor model in Machine Learning</title>
    <link>https://community.databricks.com/t5/machine-learning/error-batch-scoring-with-mlflow-keras-flavor-model/m-p/64014#M3130</link>
    <description>&lt;P&gt;I figured it out based on &lt;A href="https://kb.databricks.com/en_US/libraries/apache-spark-jobs-fail-with-environment-directory-not-found-error" target="_blank"&gt;this issue&lt;/A&gt; that someone posted. By switching to a single-node cluster (meaning worker node permissions are irrelevant), this code works now.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 18 Mar 2024 15:48:50 GMT</pubDate>
    <dc:creator>Miki</dc:creator>
    <dc:date>2024-03-18T15:48:50Z</dc:date>
    <item>
      <title>Error: batch scoring with mlflow.keras flavor model</title>
      <link>https://community.databricks.com/t5/machine-learning/error-batch-scoring-with-mlflow-keras-flavor-model/m-p/63829#M3122</link>
      <description>&lt;P&gt;I am logging a trained keras model using the following:&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt; fe.log_model(&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; model&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;model,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; artifact_path&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;wine_quality_prediction&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; flavor&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; mlflow.keras,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; training_set&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;training_set,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; registered_model_name&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;model_name&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; )&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;And when I call the following:&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;predictions_df &lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; fe.score_batch(model_uri&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;f&lt;/SPAN&gt;&lt;SPAN&gt;"models:/&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;SPAN&gt;model_name&lt;/SPAN&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;/&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;SPAN&gt;latest_model_version&lt;/SPAN&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;, df&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;batch_input_df)&lt;BR /&gt;display(predictions_df)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;I get the following error:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;OSError: [Errno 30] Read-only file system: '/local_disk0/.ephemeral_nfs/repl_tmp_data/ReplId-62b1a-a1cdf-baa5b-1/mlflow/models/tmpajr94lkz/raw_model/data/model.keras&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;I get the same&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am essentially just trying to adapt &lt;A href="https://docs.databricks.com/en/_extras/notebooks/source/machine-learning/feature-store-with-uc-basic-example.html" target="_blank" rel="noopener"&gt;this example&lt;/A&gt;&amp;nbsp;to use a keras model instead of a Random Forest. The code runs fine with a Random Forest, and it runs fine if I just use the native mlflow log_model(), load_model() and predict() functions. However, I do get the error if I just use&amp;nbsp;&lt;SPAN&gt;mlflow.pyfunc.load_model() to load the model and call&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;model.predict(). This&amp;nbsp;&lt;/SPAN&gt;makes me think the bug is specific to the way in which the databricks&amp;nbsp;&lt;SPAN&gt;FeatureEngineeringClient module is saving the keras model.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I would appreciate any help with this issue. &lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 15 Mar 2024 14:10:10 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/error-batch-scoring-with-mlflow-keras-flavor-model/m-p/63829#M3122</guid>
      <dc:creator>Miki</dc:creator>
      <dc:date>2024-03-15T14:10:10Z</dc:date>
    </item>
    <item>
      <title>Re: Error: batch scoring with mlflow.keras flavor model</title>
      <link>https://community.databricks.com/t5/machine-learning/error-batch-scoring-with-mlflow-keras-flavor-model/m-p/64001#M3129</link>
      <description>&lt;P&gt;Hi Kaniz,&lt;/P&gt;&lt;P data-unlink="true"&gt;Thanks for the response. Apologies if I am missing something, but since I am directly using the databricks&amp;nbsp;&lt;SPAN&gt;FeatureEngineeringClient.log_model()&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;method, I am not given the option to specify the path to write the model to. The only parameter I am given the option to provide is the artifact path and the model name, neither of which give me enough control to implement the solutions you are suggesting. I could potentially define a custom pyfunc rather than using the existing mlflow.keras flavor and then define my own save_model() and load_model() functions. However, I am struggling to see why this error is happening only when I am using the&amp;nbsp;&lt;SPAN&gt;FeatureEngineeringClient() to log and load my model, while this all works fine when I use the mlflow logging and loading (although this prevents me from leveraging the automatic feature lookups provided by the feature store).&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P data-unlink="true"&gt;Am I missing something?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 14:04:38 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/error-batch-scoring-with-mlflow-keras-flavor-model/m-p/64001#M3129</guid>
      <dc:creator>Miki</dc:creator>
      <dc:date>2024-03-18T14:04:38Z</dc:date>
    </item>
    <item>
      <title>Re: Error: batch scoring with mlflow.keras flavor model</title>
      <link>https://community.databricks.com/t5/machine-learning/error-batch-scoring-with-mlflow-keras-flavor-model/m-p/64014#M3130</link>
      <description>&lt;P&gt;I figured it out based on &lt;A href="https://kb.databricks.com/en_US/libraries/apache-spark-jobs-fail-with-environment-directory-not-found-error" target="_blank"&gt;this issue&lt;/A&gt; that someone posted. By switching to a single-node cluster (meaning worker node permissions are irrelevant), this code works now.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 15:48:50 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/error-batch-scoring-with-mlflow-keras-flavor-model/m-p/64014#M3130</guid>
      <dc:creator>Miki</dc:creator>
      <dc:date>2024-03-18T15:48:50Z</dc:date>
    </item>
  </channel>
</rss>

