Skip to content

Commit f3d095f

Browse files
committed
refactor(native): Python - remove support for scoped loading
1 parent 4bdc91c commit f3d095f

File tree

5 files changed

+1
-215
lines changed

5 files changed

+1
-215
lines changed

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

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,7 @@ fn python_load_config(mut cx: FunctionContext) -> JsResult<JsPromise> {
2727
PyModule::from_code(py, cube_code, "__init__.py", "cube")?;
2828

2929
let config_module = PyModule::from_code(py, &file_content_arg, &options_file_name, "")?;
30-
let settings_py = if config_module.hasattr("__execution_context_locals")? {
31-
let execution_context_locals = config_module.getattr("__execution_context_locals")?;
32-
33-
if config_module.hasattr("config")? {
34-
execution_context_locals.get_item("config")?
35-
} else {
36-
config_module.getattr("settings")?
37-
}
38-
} else if config_module.hasattr("config")? {
30+
let settings_py = if config_module.hasattr("config")? {
3931
config_module.getattr("config")?
4032
} else {
4133
// backward compatibility
@@ -109,25 +101,6 @@ fn python_load_model(mut cx: FunctionContext) -> JsResult<JsPromise> {
109101
CLRepr::PythonRef(PythonRef::PyExternalFunction(fun)),
110102
);
111103
}
112-
113-
// TODO remove all other ways of defining functions
114-
} else if model_module.hasattr("__execution_context_locals")? {
115-
let execution_context_locals = model_module
116-
.getattr("__execution_context_locals")?
117-
.downcast::<PyDict>()?;
118-
119-
for (local_key, local_value) in execution_context_locals.iter() {
120-
if local_value.is_instance_of::<PyFunction>() {
121-
let has_attr = local_value.hasattr("cube_context_func")?;
122-
if has_attr {
123-
let fun: Py<PyFunction> = local_value.downcast::<PyFunction>()?.into();
124-
collected_functions.insert(
125-
local_key.to_string(),
126-
CLRepr::PythonRef(PythonRef::PyExternalFunction(fun)),
127-
);
128-
}
129-
}
130-
}
131104
} else {
132105
let inspect_module = py.import("inspect")?;
133106
let args = (model_module, inspect_module.getattr("isfunction")?);

packages/cubejs-backend-native/test/jinja.test.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -119,32 +119,6 @@ suite('Python model', () => {
119119
});
120120
});
121121

122-
darwinSuite('Scope Python model', () => {
123-
it('load scoped-utils.py', async () => {
124-
const pythonModule = await loadPythonCtxFromUtils('scoped-utils.py');
125-
126-
expect(pythonModule.functions).toEqual({
127-
load_data: expect.any(Object),
128-
load_data_sync: expect.any(Object),
129-
arg_bool: expect.any(Object),
130-
arg_kwargs: expect.any(Object),
131-
arg_named_arguments: expect.any(Object),
132-
arg_sum_integers: expect.any(Object),
133-
arg_str: expect.any(Object),
134-
arg_null: expect.any(Object),
135-
arg_sum_tuple: expect.any(Object),
136-
arg_sum_map: expect.any(Object),
137-
arg_seq: expect.any(Object),
138-
new_int_tuple: expect.any(Object),
139-
new_str_tuple: expect.any(Object),
140-
new_safe_string: expect.any(Object),
141-
new_object_from_dict: expect.any(Object),
142-
load_class_model: expect.any(Object),
143-
throw_exception: expect.any(Object),
144-
});
145-
});
146-
});
147-
148122
suite('Jinja (new api)', () => {
149123
const initJinjaEngine: InitJinjaFn = (() => {
150124
let pyCtx: native.PythonCtx;

packages/cubejs-backend-native/test/python.test.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -236,26 +236,3 @@ darwinSuite('Old Python Config', () => {
236236
);
237237
});
238238
});
239-
240-
darwinSuite('Scoped Python Config', () => {
241-
test('test', async () => {
242-
const config = await loadConfigurationFile('scoped-config.py');
243-
expect(config).toEqual({
244-
schemaPath: 'models',
245-
pgSqlPort: 5555,
246-
telemetry: false,
247-
contextToApiScopes: expect.any(Function),
248-
checkAuth: expect.any(Function),
249-
queryRewrite: expect.any(Function),
250-
});
251-
252-
if (!config.checkAuth) {
253-
throw new Error('checkAuth was not defined in config.py');
254-
}
255-
256-
await config.checkAuth(
257-
{ requestId: 'test' },
258-
'MY_SECRET_TOKEN'
259-
);
260-
});
261-
});

packages/cubejs-backend-native/test/scoped-config.py

Lines changed: 0 additions & 28 deletions
This file was deleted.

packages/cubejs-backend-native/test/templates/scoped-utils.py

Lines changed: 0 additions & 110 deletions
This file was deleted.

0 commit comments

Comments
 (0)