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

[draft/experiment] Export package so it can be leveraged in other places #445

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion docker_images/sentence_transformers/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ ENV TRANSFORMERS_CACHE=/data
# If UVICORN_TIMEOUT is too low, uvicorn will simply never loads as it will
# kill workers all the time before they finish.
RUN sed -i 's/TIMEOUT/UVICORN_TIMEOUT/g' /gunicorn_conf.py
COPY ./app /app/app
COPY ./hf_api_sentence_transformers /app/hf_api_sentence_transformers
Empty file.
4 changes: 0 additions & 4 deletions docker_images/sentence_transformers/app/pipelines/__init__.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .pipelines.feature_extraction import FeatureExtractionPipeline
from .pipelines.sentence_similarity import SentenceSimilarityPipeline

__all__ = ['SentenceSimilarityPipeline', "FeatureExtractionPipeline"]
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Dict, Type

from api_inference_community.routes import pipeline_route, status_ok
from app.pipelines import (
from hf_api_sentence_transformers.pipelines import (
FeatureExtractionPipeline,
Pipeline,
SentenceSimilarityPipeline,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from hf_api_sentence_transformers.pipelines.base import Pipeline, PipelineException # isort:skip

from hf_api_sentence_transformers.pipelines.feature_extraction import FeatureExtractionPipeline
from hf_api_sentence_transformers.pipelines.sentence_similarity import SentenceSimilarityPipeline
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from typing import List

from app.pipelines import Pipeline
from hf_api_sentence_transformers.pipelines import Pipeline
from sentence_transformers import SentenceTransformer


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from typing import Dict, List, Union

from app.pipelines import Pipeline
from hf_api_sentence_transformers.pipelines import Pipeline
from sentence_transformers import SentenceTransformer, util


Expand Down
1 change: 0 additions & 1 deletion docker_images/sentence_transformers/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ tokenizers==0.19.1
protobuf==3.18.3
huggingface_hub==0.23.3
sacremoses==0.0.53
# dummy.
21 changes: 21 additions & 0 deletions docker_images/sentence_transformers/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from setuptools import setup, find_packages
import os


VERSION = "0.0.1"

def parse_requirements(filename):
""" Load requirements from a pip requirements file """
with open(filename, 'r') as f:
return f.read().splitlines()

# Specify the path to the requirements.txt file
requirements_path = os.path.join(os.path.dirname(__file__), 'requirements.txt')


setup(
name='hf_api_sentence_transformers',
version=VERSION,
packages=find_packages(),
install_requires=parse_requirements(requirements_path)
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
from unittest import TestCase, skipIf

from app.main import ALLOWED_TASKS
from hf_api_sentence_transformers.main import ALLOWED_TASKS
from starlette.testclient import TestClient
from tests.test_api import TESTABLE_MODELS

Expand All @@ -18,7 +18,7 @@ def setUp(self):
self.old_task = os.getenv("TASK")
os.environ["MODEL_ID"] = model_id
os.environ["TASK"] = "feature-extraction"
from app.main import app
from hf_api_sentence_transformers.main import app

self.app = app

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
from unittest import TestCase, skipIf

from app.main import ALLOWED_TASKS
from hf_api_sentence_transformers.main import ALLOWED_TASKS
from parameterized import parameterized_class
from starlette.testclient import TestClient
from tests.test_api import TESTABLE_MODELS
Expand All @@ -21,7 +21,7 @@ def setUp(self):
self.old_task = os.getenv("TASK")
os.environ["MODEL_ID"] = self.model_id
os.environ["TASK"] = "sentence-similarity"
from app.main import app
from hf_api_sentence_transformers.main import app

self.app = app

Expand Down
Loading