Skip to content

Introduce specialized registry for Jinja macros#460

Merged
izeigerman merged 6 commits intomainfrom
better-jinja-macros
Mar 1, 2023
Merged

Introduce specialized registry for Jinja macros#460
izeigerman merged 6 commits intomainfrom
better-jinja-macros

Conversation

@izeigerman
Copy link
Contributor

@izeigerman izeigerman commented Feb 28, 2023

What hasn't been covered:

  1. Capturing of dynamic macro references introduced via adapter.dispatch.
  2. Built-in jinja methods are still being packed into each individual model.
  3. The native SQLMesh project loader still relies on the old approach when parsing jinja macros.

@izeigerman izeigerman requested review from a team, crericha and tobymao February 28, 2023 23:30
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we call a bunch of private methods? maybe lets make them public

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rendered in this case is ModelConfig so it's technically ok.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sure this doesn't mess with anywhere that we depend on order, perhaps in hashing etc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, why do you think we may rely on order for dependencies?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a precaution

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

won't this mask valid exceptions?

Copy link
Contributor Author

@izeigerman izeigerman Feb 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests fail without it. So previously we were just ignoring missing environment variables. Not sure how the current behavior is different from before.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the issue is we are loading all targets and we should only load the one requested.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think this is something I introduced?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, doesn't look like it. Looks like Profile.to_sqlmesh intentionally returns all of them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I can fix.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the date_dict be part of builtin_jinja? Or special here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's determined at runtime, so yeah - special.

@izeigerman izeigerman force-pushed the better-jinja-macros branch from e9a9ba9 to fc81f6d Compare March 1, 2023 00:14
Copy link
Contributor

@georgesittas georgesittas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@izeigerman izeigerman force-pushed the better-jinja-macros branch from 6eb8269 to bfc734b Compare March 1, 2023 21:18
self._target = value
if not self.project_name:
raise ConfigError(f"Must assign project_name before assigning target")
self._builtins["target"] = self._target.target_jinja(self.project_name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is target?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found it. All good.

@izeigerman izeigerman merged commit 20eaadf into main Mar 1, 2023
@izeigerman izeigerman deleted the better-jinja-macros branch March 1, 2023 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants