Skip to content

Commit

Permalink
chore: Update python deps
Browse files Browse the repository at this point in the history
- pip
- cargo

and fix few small issues.
  • Loading branch information
milenkovicm committed Nov 27, 2024
1 parent d2a8f77 commit 430093c
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 14 deletions.
2 changes: 1 addition & 1 deletion python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ datafusion-python = { version = "42" }

pyo3 = { version = "0.22", features = ["extension-module", "abi3", "abi3-py38"] }
pyo3-log = "0.11.0"
tokio = { version = "1.35", features = ["macros", "rt", "rt-multi-thread", "sync"] }
tokio = { version = "1.41", features = ["macros", "rt", "rt-multi-thread", "sync"] }

[lib]
crate-type = ["cdylib"]
Expand Down
8 changes: 4 additions & 4 deletions python/examples/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
# specific language governing permissions and limitations
# under the License.

# %%

from ballista import BallistaBuilder
from datafusion.context import SessionContext

# Ballista will initiate with an empty config
# set config variables with `config`
ctx: SessionContext = BallistaBuilder()\
.config("ballista.job.name", "example ballista")\
.config("ballista.shuffle.partitions", "16")\
.config("datafusion.execution.target_partitions", "4")\
.standalone()

#ctx_remote: SessionContext = ballista.remote("remote_ip", 50050)

# Select 1 to verify its working
ctx.sql("SELECT 1").show()
#ctx_remote.sql("SELECT 2").show()
# %%
4 changes: 2 additions & 2 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
# under the License.

[build-system]
requires = ["maturin>=0.15,<0.16"]
requires = ["maturin>=1.5.1,<1.6.0"]
build-backend = "maturin"

[project]
name = "ballista"
description = "Python client for Apache Arrow Ballista Distributed SQL Query Engine"
readme = "README.md"
license = {file = "LICENSE.txt"}
requires-python = ">=3.6"
requires-python = ">=3.7"
keywords = ["ballista", "sql", "rust", "distributed"]
classifier = [
"Development Status :: 2 - Pre-Alpha",
Expand Down
3 changes: 2 additions & 1 deletion python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
datafusion==35.0.0
datafusion==42.0.0
maturin==1.5.1
pyarrow
pytest
16 changes: 10 additions & 6 deletions python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,9 @@ use datafusion::execution::SessionStateBuilder;
use datafusion::prelude::*;
use datafusion_python::context::PySessionContext;
use datafusion_python::utils::wait_for_future;

use std::collections::HashMap;

use pyo3::prelude::*;
use std::collections::HashMap;
mod utils;
use utils::to_pyerr;

#[pymodule]
fn ballista_internal(_py: Python, m: Bound<'_, PyModule>) -> PyResult<()> {
Expand Down Expand Up @@ -66,7 +63,11 @@ impl PyBallistaBuilder {
/// Construct the standalone instance from the SessionContext
pub fn standalone(&self, py: Python) -> PyResult<PySessionContext> {
// Build the config
let config: SessionConfig = SessionConfig::from_string_hash_map(&self.conf)?;
let mut config: SessionConfig = SessionConfig::new_with_ballista();
for (key, value) in &self.conf {
let _ = config.options_mut().set(&key, value);
}

// Build the state
let state = SessionStateBuilder::new()
.with_config(config)
Expand All @@ -85,7 +86,10 @@ impl PyBallistaBuilder {
/// Construct the remote instance from the SessionContext
pub fn remote(&self, url: &str, py: Python) -> PyResult<PySessionContext> {
// Build the config
let config: SessionConfig = SessionConfig::from_string_hash_map(&self.conf)?;
let mut config: SessionConfig = SessionConfig::new_with_ballista();
for (key, value) in &self.conf {
let _ = config.options_mut().set(&key, value);
}
// Build the state
let state = SessionStateBuilder::new()
.with_config(config)
Expand Down
1 change: 1 addition & 0 deletions python/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use ballista_core::error::BallistaError;
use pyo3::exceptions::PyException;
use pyo3::PyErr;

#[allow(dead_code)]
pub(crate) fn to_pyerr(err: BallistaError) -> PyErr {
PyException::new_err(err.to_string())
}

0 comments on commit 430093c

Please sign in to comment.