| 1 | // Copyright 2024 Lance Developers. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | use arrow::RecordBatchStream; |
| 16 | use connection::{connect, Connection}; |
| 17 | use env_logger::Env; |
| 18 | use index::{Index, IndexConfig}; |
| 19 | use pyo3::{pymodule, types::PyModule, wrap_pyfunction, PyResult, Python}; |
| 20 | use query::{Query, VectorQuery}; |
| 21 | use table::Table; |
| 22 | |
| 23 | pub mod arrow; |
| 24 | pub mod connection; |
| 25 | pub mod error; |
| 26 | pub mod index; |
| 27 | pub mod query; |
| 28 | pub mod table; |
| 29 | pub mod util; |
| 30 | |
| 31 | #[pymodule] |
| 32 | pub fn _lancedb(_py: Python, m: &PyModule) -> PyResult<()> { |
| 33 | let env = Env::new() |
| 34 | .filter_or("LANCEDB_LOG", "warn") |
| 35 | .write_style("LANCEDB_LOG_STYLE"); |
| 36 | env_logger::init_from_env(env); |
| 37 | m.add_class::<Connection>()?; |
| 38 | m.add_class::<Table>()?; |
| 39 | m.add_class::<Index>()?; |
| 40 | m.add_class::<IndexConfig>()?; |
| 41 | m.add_class::<Query>()?; |
| 42 | m.add_class::<VectorQuery>()?; |
| 43 | m.add_class::<RecordBatchStream>()?; |
| 44 | m.add_function(wrap_pyfunction!(connect, m)?)?; |
| 45 | m.add_function(wrap_pyfunction!(util::validate_table_name, m)?)?; |
| 46 | m.add("__version__", env!("CARGO_PKG_VERSION"))?; |
| 47 | Ok(()) |
| 48 | } |