Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Surface dbutils error correctly #11877

Merged
merged 1 commit into from
May 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions mlflow/langchain/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,16 +330,16 @@ def _validate_and_wrap_lc_model(lc_model, loader_fn):
w = WorkspaceClient()
response = w.workspace.export(path=lc_model, format=ExportFormat.SOURCE)
decoded_content = base64.b64decode(response.content)
_validate_model_code_from_notebook(decoded_content.decode("utf-8"))

return _get_temp_file_with_content("lc_model.py", decoded_content, "wb")
except Exception:
raise mlflow.MlflowException.invalid_parameter_value(
f"If the provided model '{lc_model}' is a string, it must be a valid python "
"file path or a databricks notebook file path containing the code for defining "
"the chain instance."
)

_validate_model_code_from_notebook(decoded_content.decode("utf-8"))
return _get_temp_file_with_content("lc_model.py", decoded_content, "wb")

if not isinstance(lc_model, supported_lc_types()):
raise mlflow.MlflowException.invalid_parameter_value(
_UNSUPPORTED_MODEL_ERROR_MESSAGE.format(instance_type=type(lc_model).__name__)
Expand Down
Loading