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

add pypi release #270

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions .github/workflows/pypi_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ jobs:
- name: Install minimal dependencies and import
shell: bash
run: |
sleep 30
sleep 180
poetry run pip install "infinity-emb[server]==${{ env.VERSION }}"
poetry run infinity_emb --help
poetry run python -c "import infinity_emb"
# print version
echo version=$(poetry run python -c "import infinity_emb;print(infinity_emb.__version__)") >> $GITHUB_OUTPUT
echo PIP_VERSION=$(poetry run python -c "import infinity_emb;print(infinity_emb.__version__)") >> $GITHUB_OUTPUT
2 changes: 1 addition & 1 deletion libs/infinity_emb/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use the Python base image
FROM nvidia/cuda:12.1.0-base-ubuntu22.04 AS base
FROM nvidia/cuda:12.1.1-base-ubuntu22.04 AS base

ENV PYTHONUNBUFFERED=1 \
\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
ORTModelForSequenceClassification,
)
from transformers import AutoConfig, AutoTokenizer # type: ignore
except (ImportError, RuntimeError) as ex:
except (ImportError, RuntimeError, Exception) as ex:
CHECK_ONNXRUNTIME.mark_dirty(ex)


Expand Down
25 changes: 12 additions & 13 deletions libs/infinity_emb/infinity_emb/transformer/embedder/optimum.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import numpy as np

from infinity_emb._optional_imports import CHECK_ONNXRUNTIME, CHECK_TRANSFORMERS
from infinity_emb.args import EngineArgs
from infinity_emb.primitives import EmbeddingReturnType, PoolingMethod
from infinity_emb.transformer.abstract import BaseEmbedder
Expand All @@ -16,24 +17,22 @@
optimize_model,
)

try:
from optimum.onnxruntime import ( # type: ignore[import-untyped]
ORTModelForFeatureExtraction,
)
from transformers import AutoConfig, AutoTokenizer # type: ignore[import-untyped]
if CHECK_ONNXRUNTIME.is_available:
try:
from optimum.onnxruntime import ( # type: ignore[import-untyped]
ORTModelForFeatureExtraction,
)

OPTIMUM_AVAILABLE = True
except (ImportError, RuntimeError):
OPTIMUM_AVAILABLE = False
except (ImportError, RuntimeError, Exception) as ex:
CHECK_ONNXRUNTIME.mark_dirty(ex)

if CHECK_TRANSFORMERS.is_available:
from transformers import AutoConfig, AutoTokenizer # type: ignore[import-untyped]


class OptimumEmbedder(BaseEmbedder):
def __init__(self, *, engine_args: EngineArgs):
if not OPTIMUM_AVAILABLE:
raise ImportError(
"optimum.onnxruntime is not installed."
"`pip install infinity_emb[optimum]`"
)
CHECK_ONNXRUNTIME.mark_required()
provider = device_to_onnx(engine_args.device)

onnx_file = get_onnx_files(
Expand Down
6 changes: 2 additions & 4 deletions libs/infinity_emb/infinity_emb/transformer/utils_optimum.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@
try:
from optimum.onnxruntime import ORTOptimizer # type: ignore
from optimum.onnxruntime.configuration import OptimizationConfig # type: ignore
except ImportError:
pass
except RuntimeError:
pass
except (ImportError, RuntimeError, Exception) as ex:
CHECK_ONNXRUNTIME.mark_dirty(ex)

if CHECK_TORCH.is_available:
import torch
Expand Down
Loading