Skip to content

Commit

Permalink
fix: update importing onnx module with conditional checks (#105)
Browse files Browse the repository at this point in the history
* fix: update importing onnx module with conditional checks

* fix: update the version also in init file
  • Loading branch information
rcmalli authored Feb 9, 2024
1 parent ccd6566 commit f856563
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
# Changelog
All notable changes to this project will be documented in this file.

### [1.5.8]

#### Fix

- Fix ONNX import call for the utilities when ONNX is not installed.

### [1.5.7]

#### Added
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "quadra"
version = "1.5.7"
version = "1.5.8"
description = "Deep Learning experiment orchestration library"
authors = [
"Federico Belotti <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion quadra/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "1.5.7"
__version__ = "1.5.8"


def get_version():
Expand Down
11 changes: 9 additions & 2 deletions quadra/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import dotenv
import mlflow
import numpy as np
import onnx
import pytorch_lightning as pl
import rich.syntax
import rich.tree
Expand All @@ -31,6 +30,14 @@
from quadra.callbacks.mlflow import get_mlflow_logger
from quadra.utils.mlflow import infer_signature_model

try:
import onnx # noqa

ONNX_AVAILABLE = True
except ImportError:
ONNX_AVAILABLE = False


IMAGE_EXTENSIONS: List[str] = [".png", ".jpg", ".jpeg", ".bmp", ".tiff", ".tif", ".pbm", ".pgm", ".ppm", ".pxm", ".pnm"]


Expand Down Expand Up @@ -311,7 +318,7 @@ def finish(
artifact_path=model_path,
signature=signature,
)
elif model_type in ["onnx", "simplified_onnx"]:
elif model_type in ["onnx", "simplified_onnx"] and ONNX_AVAILABLE:
signature = infer_signature_model(model, inputs)
with mlflow.start_run(run_id=mlflow_logger.run_id) as _:
if model.model_path is None:
Expand Down

0 comments on commit f856563

Please sign in to comment.