Skip to content

Commit cd67469

Browse files
committed
Allow importing modules from python files within globals.py
1 parent f0f8875 commit cd67469

File tree

1 file changed

+9
-0
lines changed
  • packages/cubejs-backend-native/src/python

1 file changed

+9
-0
lines changed

packages/cubejs-backend-native/src/python/entry.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,15 @@ fn python_load_model(mut cx: FunctionContext) -> JsResult<JsPromise> {
7979
py_runtime_init(&mut cx, channel.clone())?;
8080

8181
let conf_res = Python::with_gil(|py| -> PyResult<CubePythonModel> {
82+
let sys_path = py.import("sys")?.getattr("path")?.downcast::<PyList>()?;
83+
84+
let config_dir = Path::new(&model_file_name)
85+
.parent()
86+
.unwrap_or_else(|| Path::new("."));
87+
let config_dir_str = config_dir.to_str().unwrap_or(".");
88+
89+
sys_path.insert(0, PyString::new(py, config_dir_str))?;
90+
8291
let cube_code = include_str!(concat!(
8392
env!("CARGO_MANIFEST_DIR"),
8493
"/python/cube/src/__init__.py"

0 commit comments

Comments
 (0)