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

Wrap errors for error handling in UC and MLflow #3692

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
14 changes: 8 additions & 6 deletions composer/utils/object_store/mlflow_object_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,13 +517,15 @@ def _get_artifact_info(self, object_name):
Returns:
Optional[FileInfo]: The :class:`~mlflow.entities.FileInfo` for the object, or None if it does not exist.
"""
from mlflow.exceptions import MlflowException
# MLflow doesn't support info for a singleton artifact, so we need to list all artifacts in the
# parent path and find the one with the matching name.
artifact_path = self.get_artifact_path(object_name)
artifact_dir = os.path.dirname(artifact_path)
artifacts = self._mlflow_client.list_artifacts(self.run_id, artifact_dir)
for artifact in artifacts:
if not artifact.is_dir and artifact.path == artifact_path:
return artifact

return None
try:
artifacts = self._mlflow_client.list_artifacts(self.run_id, artifact_dir)
for artifact in artifacts:
if not artifact.is_dir and artifact.path == artifact_path:
return artifact
except MlflowException as e:
_wrap_mlflow_exceptions(object_name, e)
8 changes: 5 additions & 3 deletions composer/utils/object_store/uc_object_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,11 @@ def upload_object(
"""
# remove unused variable
del callback
with open(filename, 'rb') as f:
self.client.files.upload(self._get_object_path(object_name), f)
try:
with open(filename, 'rb') as f:
self.client.files.upload(self._get_object_path(object_name), f)
except Exception as e:
_wrap_errors(self.get_uri(object_name), e)

def download_object(
self,
Expand Down Expand Up @@ -192,7 +195,6 @@ def download_object(
tmp_path = str(filename) + f'{uuid.uuid4()}.tmp'

try:

try:
contents = self.client.files.download(self._get_object_path(object_name)).contents
assert contents is not None
Expand Down
Loading