Skip to content

Commit ac62631

Browse files
committed
Allow importing modules from python files within globals.py
1 parent e8d4184 commit ac62631

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
@@ -71,6 +71,15 @@ fn python_load_model(mut cx: FunctionContext) -> JsResult<JsPromise> {
7171
py_runtime_init(&mut cx, channel.clone())?;
7272

7373
let conf_res = Python::with_gil(|py| -> PyResult<CubePythonModel> {
74+
let sys_path = py.import("sys")?.getattr("path")?.downcast::<PyList>()?;
75+
76+
let config_dir = Path::new(&model_file_name)
77+
.parent()
78+
.unwrap_or_else(|| Path::new("."));
79+
let config_dir_str = config_dir.to_str().unwrap_or(".");
80+
81+
sys_path.insert(0, PyString::new(py, config_dir_str))?;
82+
7483
let cube_code = include_str!(concat!(
7584
env!("CARGO_MANIFEST_DIR"),
7685
"/python/cube/src/__init__.py"

0 commit comments

Comments
 (0)