question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ability to avoid duplicate alembic comparator dispatch with `registered_entities`

See original GitHub issue

Has some resemblance to https://github.com/olirice/alembic_utils/issues/56, or at least covers the same code, but i think is a different problem.

I’m using https://github.com/schireson/pytest-alembic to test my migrations, which ends up reexecuting the env.py many times within a single process (in many cases, once per migration), which leads to the same comparator getting reregistered numerous times. It’s doesn’t break alembic, but it does get progressively slower.

Due to the way register_entities works (https://github.com/olirice/alembic_utils/blob/bdaa374d27c597ba79cd1d0b56ea5d3e87404a07/src/alembic_utils/replaceable_entity.py#L208), there’s not a great way to hook it into alembic without this happening.

A random example of how this could be avoided through a change to alembic_utils, might look like

@dataclass
class Registry:
    entities: List

    def register_entities(self, ...):
         """I'm what is now `register_entities`."""

registry = Registry()
register_entities = registry.register_entities

@comparators.dispatch_for("schema")
def compare_registered_entities(...):
    ...

This suggestion is sort-of based on how sqlalchemy/alembic themselves do things, but there are other, probably less drastic options. For example, just defining the functions in such a way that i could make the call to comparators.dispatch_for myself.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
arthurHamon2commented, May 20, 2022

Thanks for this improvement, we literally went from 10 minutes to 4 minutes in our CI just upgrading to alembic_utils 0.7.7 🎉 FYI we are using both libraries, pytest-alembic and alembic-utils !

1reaction
DanCardincommented, Apr 11, 2022

Love to see it, just upgraded and all seems well for our migrations. thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

alembic/compare.py at main · sqlalchemy/alembic - GitHub
a unique constraint on the metadata side *might* have a name. # 4. The backend may double up indexes as unique constraints and....
Read more >
사회복지학과 - 부산가톨릭대학교에 오신 것을 환영합니다~!
By going straight through the skin to circulation, we창?혲re able to eliminate a ton of the disadvantages that come with the traditional ways...
Read more >
Experts for thin-client software-defined radio nodes - Linknovate
Name Score Grants News Rutgers University 422.2 1 ‑ Amazon 49.2 ‑ 5 IBM 44.9 ‑ 5
Read more >
Audit/ Certifications under Goods & Services Tax Act
administration was able to do audit of about ... will be liable to GST audit even though 10 other registered entities have.
Read more >
Sitharaman Asks Psbs To Push Credit Bhargava, Venu Face ...
SEVERE THIRD WAVE know said. “The finance ministry's revenue by taxpayers over anomalies since the his turn came to counter them. UNLIKELY: NK...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found