-
-
Notifications
You must be signed in to change notification settings - Fork 278
separate source code and deployment configurations #1082
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
looking at how |
hmm nope, I think we have to rip out ConfigParser and rework Config to have its own internal data structure. then we have consumers that can consume both toml and configparser into the internal structure.
for things like "list of directories", toml can represent the list directly, so that "str value" is not appropriate. So we need to port ConfigParser to our own internal solution, for things like named sections. We then need consumers for pyproject and configparser that are separate and based on a schema. Things like the directory splitting we are doing at https://github.com/sqlalchemy/alembic/blob/main/alembic/script/base.py#L166 becomes local to the configparser consumer, because pyproject.toml gives us that directly. this is a big job |
Not sure I would go down this path. I think toml files are witten like json files, ie the file is read, modification are done to python objects then the object is serialized, rewriting the toml file (iirc comments are kept) |
how do different templates produce different configuations then ? |
I guess we would have to manually construct the python dict that represents the tool.alembic section of the toml in some way |
I never thought about thins, but I actually agree. In fact at work the have a different mean for configuring the engine and the logging, while all the other "source_config_option" are taken from alembic.ini |
Maybe it is worth changing the configuration templates now, so they no longer create an |
Ideally solution for me as a SE:
|
Any update on this issue? |
Nothing outside what's in this issue |
To follow up on @Danipulok 's question Context In that context, in those intervening years, is there:
I see this commit went in very recently which may or may not relate to this (I haven't quite parsed that addition to see if it's purely related to this repo's package management or intended to affect the end user's repo package pyproject.toml usage). Or in other words: if someone wanted to contribute some PRs toward this initiative, would they be duplicating any existing efforts? |
no as far as we are aware. Before opening a PR it make make sense to sketch the rough idea here to verify that the implementation is in the right track |
How do we feel about adoption for people who don't customize alembic too much? |
Don't want the the guy that necrobumps, but I believe this is an important issue, most Python tools are moving toward formalizing their configurations using I find the solution proposed by @Kostiantyn-Salnykov to be very reasonable, and I kindly ask @zzzeek to take another look at this issue. |
Sorry what am I looking at exactly? The steps to implement this are fully written out in my original comment. |
Sorry, I think I should have asked if there is a implementation planned in the project backlog of one of the proposed solutions instead of just asking you to "look into it", my apologies. If there is nothing planned in the project backlog do you think contributions is interesting for the project? |
I think this is backlog right now. there's no technical challenge to this as much as presenting it correctly since I dont think it's feasible to add pyproject.toml support without updating all the tutorials / templates to use this style, and at the same time making sure nothing goes wrong with the millions of existing projects out there. if you just want to bolt on pyproject support, you can even do that on your end building a short commandline wrapper for the one we have that injects pyproject values into the config (though we also have someone who wants to merge a refactor of commandline too |
That note seems to be part of the rejected portion of the pep and seems to involve tools being allowed to extend configuration that's not within a [tool] section |
Mike Bayer has proposed a fix for this issue in the main branch: WIP: allow pep 621 configuration (only docs so far) https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/5860 |
Uh oh!
There was an error while loading. Please reload this page.
this is the modern version of #708, where people called for alembic configuration to be in pyproject.toml. it's not appropriate for the whole alembic.ini to be moved to this file, and the actual problem to be solved is that Alembic's configuration model is somewhat wrong, hence we were unable to do #708 as it stands without first fixing configuration.
First let's lay out some of what exists, that is impacted by this:
So from that, we can summarize Alembic's configuration is in practice at least two separate categories:
logging.fileConfig()
inside of env.py illustrated, "hey, the logging config doesn't have to come from alembic.ini".See this is the bug. alembic.ini has two kinds of configuration, and then through vague handwavy means we sort of gave people a way to "move" the deployment configuration out of it, into their own system, which is what people do (at least, developers working in professional deployment situations. beginners, I have no idea what they do).
So given all that, here are more wrinkles:
So given all that, here are proposals:
this is all major release stuff - alembic 1.9 or greater
existing alembic projects should not be impacted at all - the existing alembic.ini format should always work, no plans to remove it
Config API should be changed to have separate notions of source config and deployment config - I would deprecate all "main_option" / "section_option" language entirely and replace it with "source_config_option" / "deployment_option" (or whatever term). These dont match up exactly.
--name
option, that is, https://alembic.sqlalchemy.org/en/latest/cookbook.html#multiple-environments. I dont know what to do here.--name
should probably look in pyproject.toml and then alembic.ini for the named sections using resolution similar to the default resolution.if Config.file_config remains, it returns the alembic.ini config, but this would not have any data from pyproject.toml inside of it
alembic init will be switched to render into pyproject.toml directly for source code options - that is we remove all the "main" stuff from alembic.ini. I don't want to have to document two styles. note that this includes:
even in the new way, there is still an alembic.ini file - with default deployment configuration used by env.py. it can be removed if one's env.py does not need it
alembic will consume source code options from pyproject.toml then fall back to alembic.ini
so that's what I have. I personally don't have time to own the effort on this, however whoever is doing it I will have a lot of very detailed review comments etc. because getting this wrong will just create expoentially more work later.
The text was updated successfully, but these errors were encountered: