Skip to content

Commit

Permalink
enhance: Make bulk_writer's requirments optional (#2086)
Browse files Browse the repository at this point in the history
See also: #2067

Signed-off-by: yangxuan <[email protected]>
  • Loading branch information
XuanYang-cn authored May 14, 2024
1 parent 502ef37 commit 3198bd2
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 28 deletions.
5 changes: 4 additions & 1 deletion examples/example_bulkwriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@
FieldSchema, CollectionSchema, DataType,
Collection,
utility,
BulkInsertState,
)

from pymilvus.bulk_writer import (
LocalBulkWriter,
RemoteBulkWriter,
BulkFileType,
bulk_import,
get_import_progress,
list_import_jobs,
BulkInsertState,
)

# minio
Expand Down
22 changes: 0 additions & 22 deletions pymilvus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,6 @@
# or implied. See the License for the specific language governing permissions and limitations under
# the License.

from .bulk_writer.bulk_import import (
bulk_import,
get_import_progress,
list_import_jobs,
)

# bulk writer
from .bulk_writer.constants import (
BulkFileType,
)
from .bulk_writer.local_bulk_writer import (
LocalBulkWriter,
)
from .bulk_writer.remote_bulk_writer import (
RemoteBulkWriter,
)
from .client import __version__
from .client.abstract import AnnSearchRequest, Hit, Hits, RRFRanker, SearchResult, WeightedRanker
from .client.asynch import SearchFuture
Expand Down Expand Up @@ -143,12 +127,6 @@
"ResourceGroupInfo",
"Connections",
"IndexType",
"BulkFileType",
"LocalBulkWriter",
"RemoteBulkWriter",
"bulk_import",
"get_import_progress",
"list_import_jobs",
"AnnSearchRequest",
"RRFRanker",
"WeightedRanker",
Expand Down
28 changes: 28 additions & 0 deletions pymilvus/bulk_writer/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from importlib.util import find_spec

expected_pkgs = ["minio", "azure", "requests", "pyarrow"]

missing = [pkg for pkg in expected_pkgs if find_spec(pkg) is None]

if len(missing) > 0:
msg = f"Missing packages: {missing}. Please install bulk_writer by pip install pymilvus[bulk_writer] first"
raise ModuleNotFoundError(msg)


from .bulk_import import (
bulk_import,
get_import_progress,
list_import_jobs,
)
from .constants import BulkFileType
from .local_bulk_writer import LocalBulkWriter
from .remote_bulk_writer import RemoteBulkWriter

__all__ = [
"BulkFileType",
"LocalBulkWriter",
"RemoteBulkWriter",
"bulk_import",
"get_import_progress",
"list_import_jobs",
]
14 changes: 9 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ dependencies=[
"ujson>=2.0.0",
"pandas>=1.2.4",
"numpy<1.25.0;python_version<='3.8'",
"requests",
"minio>=7.0.0",
"pyarrow>=12.0.0",
"azure-storage-blob",
"milvus-lite>=2.4.0",
]

Expand All @@ -42,6 +38,13 @@ dynamic = ["version"]
"repository" = 'https://github.com/milvus-io/pymilvus'

[project.optional-dependencies]
bulk_writer = [
"requests",
"minio>=7.0.0",
"pyarrow>=12.0.0",
"azure-storage-blob",
]

model = [
"milvus-model>=0.1.0",
]
Expand All @@ -51,7 +54,7 @@ test = [
"pytest-cov>=2.8.1",
"pytest-timeout>=1.3.4",
"grpcio-testing",
"ruff>=0.3.3",
"ruff>0.4.0",
"black",
]

Expand Down Expand Up @@ -113,6 +116,7 @@ lint.ignore = [
"PLR0915", # To many statements TODO
"C901", # TODO
"PYI041", # TODO
"E402",
]

# Allow autofix for all enabled rules (when `--fix`) is provided.
Expand Down

0 comments on commit 3198bd2

Please sign in to comment.