Skip to content

Commit

Permalink
fix(schema): Load jinja engine only when jinja templates exist
Browse files Browse the repository at this point in the history
  • Loading branch information
ovr committed Jun 19, 2023
1 parent 53c6ee9 commit ffe4dd2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions packages/cubejs-backend-native/src/python/template/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ fn init_template_engine<'a, C: Context<'a>>(_cx: &mut C, opts: EngineOptions) ->
);

if let Err(_) = TEMPLATE_ENGINE.set(Mutex::new(engine)) {
// I am working on a new jinja engine implementation on top of isolated instances per tenant
// to support multi tenancy
#[cfg(debug_assertions)]
error!("Unable to init jinja engine, it was already started");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,16 @@ export class DataSchemaCompiler {
* @protected
*/
async doCompile() {
if (NATIVE_IS_SUPPORTED && !isFallbackBuild()) {
const files = await this.repository.dataSchemaFiles();
const hasJinjaTemplate = files.filter((file) => file.fileName.endsWith('.jinja'));

if (hasJinjaTemplate && NATIVE_IS_SUPPORTED && !isFallbackBuild()) {
initJinjaEngine({
debugInfo: getEnv('devMode'),
});
clearTemplates();
}

const files = await this.repository.dataSchemaFiles();
const toCompile = files.filter((f) => !this.filesToCompile || this.filesToCompile.indexOf(f.fileName) !== -1);

const errorsReport = new ErrorReporter(null, [], this.errorReport);
Expand Down

0 comments on commit ffe4dd2

Please sign in to comment.