infiniflow / infinity

The AI-native database built for LLM applications, providing incredibly fast hybrid search of dense vector, sparse vector, tensor (multi-vector), and full-text
https://infiniflow.org
Apache License 2.0
2.6k stars 273 forks source link

[Question]: Issues with Client Development on Windows and Remote Database Connection #1647

Open joynn opened 2 months ago

joynn commented 2 months ago

Describe your problem

Hello, I am currently using both the Python API and the HTTP API to connect to a standalone database service. However, it seems that the default connection is only allowed through "localhost." How can I customize the configuration file? I couldn't find any relevant documentation regarding this parameter and its path. Also, is it true that versions of the SDK after 0.2.0.dev7 are only available for Linux and not Windows? How can I develop code on Windows to connect to a 0.3.0.dev4 database? Thank you.

JinHai-CN commented 2 months ago
  1. Yes, Python SDK is only for Linux now. On windows, you may use Python SDK to connect infinity 0.3.0 by using WSL , or you can use HTTP API to connect Infinity. In fact, HTTP API have much more functions than Python SDK.

  2. Please check the document: https://github.com/infiniflow/infinity/blob/main/docs/references/pysdk_api_reference.md#connect, you can you following code to connect the remote server with IP 192.168.1.1:

    import infinity
    infinity_object = infinity.connect(infinity.NetworkAddress("192.168.1.1", 23817)) 

BTW, Infinity python SDK also supports to open a local directory use following code:

import infinity
infinity_object = infinity.connect("/var/infinity")

We migrated all infinity server functions into python SDK. That is why python SDK is only available for Linux.

joynn commented 2 months ago

Hello. Actually, for the database server I deployed using Docker, I can successfully access it using "localhost" on the host machine, but not using the real IP. There is no firewall and no network issue. Do I need to modify some config file to enable remote access? But I don't know where the config file is located and how to load it.

JinHai-CN commented 2 months ago
(infinity_env) infiniflow@infiniflow:~/infinity_data$ docker run -d --name infinity -v /home/infiniflow/infinity_data/:/var/infinity --ulimit nofile=500000:500000 --network=host infiniflow/infinity:nightly
047a2adaec8a797296b9c7a8c33f9db021fff5cdcf8111354b16a5d02defc8bf
(infinity_env) infiniflow@infiniflow:~/infinity_data$ docker container ls -a
CONTAINER ID   IMAGE                         COMMAND                  CREATED         STATUS         PORTS     NAMES
047a2adaec8a   infiniflow/infinity:nightly   "bash -c 'cp -rf /re…"   6 seconds ago   Up 4 seconds             infinity
(infinity_env) infiniflow@infiniflow:~/infinity_data$ cd ~/Documents/development/infinity
(infinity_env) infiniflow@infiniflow:~/Documents/development/infinity$ python example/simple_example.py 
shape: (3, 3)
┌─────┬─────────────────────────────────┬───────────────────┐
│ num ┆ body                            ┆ vec               │
│ --- ┆ ---                             ┆ ---               │
│ i32 ┆ str                             ┆ list[f64]         │
╞═════╪═════════════════════════════════╪═══════════════════╡
│ 1   ┆ unnecessary and harmful         ┆ [1.0, 1.2, … 0.9] │
│ 2   ┆ Office for Harmful Blooms       ┆ [4.0, 4.2, … 4.5] │
│ 3   ┆ A Bloom filter is a space-effi… ┆ [4.0, 4.2, … 4.5] │
└─────┴─────────────────────────────────┴───────────────────┘
import infinity
from infinity.common import NetworkAddress

try:
    # open a local directory to store the data
    # infinity_instance = infinity.connect("/var/infinity")

    # connect to server with 127.0.0.1
    infinity_instance = infinity.connect(NetworkAddress("192.168.200.127", 23817))

I just tried the latest docker image of as above. Use example/simple_example.py updated with IP address as above code. And it works.

You'd better to check if there are network issue, such as port conflict, incorrect ip address, etc. Use netstat or lsof to check if Infinity is listening on the port.

Infinity installed with deb/rpm can load config file, but docker running infinity can't load config file yet, this problem will be solved in the next Dev release. infinity -f infinity_conf.toml

joynn commented 2 months ago

嗯嗯,谢谢大佬

PorYoung commented 2 months ago
  1. Yes, Python SDK is only for Linux now. On windows, you may use Python SDK to connect infinity 0.3.0 by using WSL , or you can use HTTP API to connect Infinity. In fact, HTTP API have much more functions than Python SDK.
  2. Please check the document: https://github.com/infiniflow/infinity/blob/main/docs/references/pysdk_api_reference.md#connect, you can you following code to connect the remote server with IP 192.168.1.1:
import infinity
infinity_object = infinity.connect(infinity.NetworkAddress("192.168.1.1", 23817)) 

BTW, Infinity python SDK also supports to open a local directory use following code:

import infinity
infinity_object = infinity.connect("/var/infinity")

We migrated all infinity server functions into python SDK. That is why python SDK is only available for Linux.

Hello, since the HTTP server's listening IP is set to localhost in http_server.cpp, it cannot be accessed from external networks. Does this situation actually exist? Should it be changed to the IP specified in the infinity_conf.toml file?

https://github.com/infiniflow/infinity/blob/e62d9dba35872ed595be920d4c7335b055d219bc/src/network/http_server.cpp#L3336

By the way, in version 0.3.0-dev7, the provided example of the search API seems incorrect: https://github.com/infiniflow/infinity/pull/874#issue-2205075924. Could you provide more examples of the HTTP API, as some of them differ from the SDK API?

https://github.com/infiniflow/infinity/blob/e62d9dba35872ed595be920d4c7335b055d219bc/src/network/http/http_search.cpp#L137-L140

JinHai-CN commented 2 months ago
  1. Yes, Python SDK is only for Linux now. On windows, you may use Python SDK to connect infinity 0.3.0 by using WSL , or you can use HTTP API to connect Infinity. In fact, HTTP API have much more functions than Python SDK.
  2. Please check the document: https://github.com/infiniflow/infinity/blob/main/docs/references/pysdk_api_reference.md#connect, you can you following code to connect the remote server with IP 192.168.1.1:
import infinity
infinity_object = infinity.connect(infinity.NetworkAddress("192.168.1.1", 23817)) 

BTW, Infinity python SDK also supports to open a local directory use following code:

import infinity
infinity_object = infinity.connect("/var/infinity")

We migrated all infinity server functions into python SDK. That is why python SDK is only available for Linux.

Hello, since the HTTP server's listening IP is set to localhost in http_server.cpp, it cannot be accessed from external networks. Does this situation actually exist? Should it be changed to the IP specified in the infinity_conf.toml file?

Yes, it shall be fixed by #1759

https://github.com/infiniflow/infinity/blob/e62d9dba35872ed595be920d4c7335b055d219bc/src/network/http_server.cpp#L3336

By the way, in version 0.3.0-dev7, the provided example of the search API seems incorrect: #874 (comment). Could you provide more examples of the HTTP API, as some of them differ from the SDK API?

https://github.com/infiniflow/infinity/blob/e62d9dba35872ed595be920d4c7335b055d219bc/src/network/http/http_search.cpp#L137-L140

Yes, we are preparing to release v0.3.0. And the document will be updated accordingly.