Skip to content

Commit

Permalink
chore: let PyRemoteFunction with getter
Browse files Browse the repository at this point in the history
  • Loading branch information
grieve54706 committed Dec 3, 2024
1 parent ae44f70 commit 545d023
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
6 changes: 6 additions & 0 deletions wren-core-py/src/remote_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,19 @@ use wren_core::mdl::function::FunctionType;
#[pyclass(name = "RemoteFunction")]
#[derive(Serialize, Deserialize, Clone)]
pub struct PyRemoteFunction {
#[pyo3(get)]
pub function_type: String,
#[pyo3(get)]
pub name: String,
#[pyo3(get)]
pub return_type: Option<String>,
/// It's a comma separated string of parameter names
#[pyo3(get)]
pub param_names: Option<String>,
/// It's a comma separated string of parameter types
#[pyo3(get)]
pub param_types: Option<String>,
#[pyo3(get)]
pub description: Option<String>,
}

Expand Down
26 changes: 13 additions & 13 deletions wren-core-py/tests/test_modeling_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,19 @@ def test_read_function_list():
def test_get_available_functions():
session_context = SessionContext(manifest_str, "tests/functions.csv")
functions = session_context.get_available_functions()
add_two = next(x.to_dict() for x in functions if x["name"] == "add_two")
assert add_two["name"] == "add_two"
assert add_two["function_type"] == "scalar"
assert add_two["description"] == "Adds two numbers together."
assert add_two["return_type"] == "int"
assert add_two["param_names"] == "f1,f2"
assert add_two["param_types"] == "int,int"

max_if = next(x.to_dict() for x in functions if x["name"] == "max_if")
assert max_if["name"] == "max_if"
assert max_if["function_type"] == "window"
assert max_if["param_names"] is None
assert max_if["param_types"] is None
add_two = next(f for f in functions if f.name == "add_two")
assert add_two.name == "add_two"
assert add_two.function_type == "scalar"
assert add_two.description == "Adds two numbers together."
assert add_two.return_type == "int"
assert add_two.param_names == "f1,f2"
assert add_two.param_types == "int,int"

max_if = next(f for f in functions if f.name == "max_if")
assert max_if.name == "max_if"
assert max_if.function_type == "window"
assert max_if.param_names is None
assert max_if.param_types is None


@pytest.mark.parametrize(
Expand Down

0 comments on commit 545d023

Please sign in to comment.