uclahs-cds / Ligare

GNU General Public License v2.0
0 stars 0 forks source link

Migrations fail in scaffolded applications due to missing dependency #110

Closed aholmes closed 2 weeks ago

aholmes commented 1 month ago

Applications that have been scaffolded with the database module will fail to run migrations. This occurs because the database module uses BL_Python.AWS, but that is not a listed dependency in the scaffolded project's pyproject.toml.

$ bl-alembic upgrade head
Traceback (most recent call last):
  File "/home/aholmes/repos/foo/.venv/bin/bl-alembic", line 8, in <module>
    sys.exit(bl_alembic())
             ^^^^^^^^^^^^
  File "/home/aholmes/repos/foo/.venv/lib/python3.12/site-packages/BL_Python/database/migrations/alembic/__main__.py", line 27, in bl_alembic
    BLAlembic(argv, logger).run()
  File "/home/aholmes/repos/foo/.venv/lib/python3.12/site-packages/BL_Python/database/migrations/alembic/bl_alembic.py", line 356, in run
    return self._run()
           ^^^^^^^^^^^
  File "/home/aholmes/repos/foo/.venv/lib/python3.12/site-packages/BL_Python/database/migrations/alembic/bl_alembic.py", line 52, in <lambda>
    self._run = lambda: self._run_with_config(argv)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/aholmes/repos/foo/.venv/lib/python3.12/site-packages/BL_Python/database/migrations/alembic/bl_alembic.py", line 111, in _run_with_config
    self._execute_alembic(argv)
  File "/home/aholmes/repos/foo/.venv/lib/python3.12/site-packages/BL_Python/database/migrations/alembic/bl_alembic.py", line 124, in _execute_alembic
    return alembic_main(argv)
           ^^^^^^^^^^^^^^^^^^
  File "/home/aholmes/repos/foo/.venv/lib/python3.12/site-packages/alembic/config.py", line 636, in main
    CommandLine(prog=prog).main(argv=argv)
  File "/home/aholmes/repos/foo/.venv/lib/python3.12/site-packages/alembic/config.py", line 626, in main
    self.run_cmd(cfg, options)
  File "/home/aholmes/repos/foo/.venv/lib/python3.12/site-packages/alembic/config.py", line 603, in run_cmd
    fn(
  File "/home/aholmes/repos/foo/.venv/lib/python3.12/site-packages/alembic/command.py", line 406, in upgrade
    script.run_env()
  File "/home/aholmes/repos/foo/.venv/lib/python3.12/site-packages/alembic/script/base.py", line 582, in run_env
    util.load_python_file(self.dir, "env.py")
  File "/home/aholmes/repos/foo/.venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 95, in load_python_file
    module = load_module_py(module_id, path)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/aholmes/repos/foo/.venv/lib/python3.12/site-packages/alembic/util/pyfiles.py", line 113, in load_module_py
    spec.loader.exec_module(module)  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/home/aholmes/repos/foo/migrations/env.py", line 3, in <module>
    from BL_Python.database.migrations.alembic.env import run_migrations
  File "/home/aholmes/repos/foo/.venv/lib/python3.12/site-packages/BL_Python/database/migrations/alembic/env.py", line 9, in <module>
    from BL_Python.AWS.ssm import SSMParameters
ModuleNotFoundError: No module named 'BL_Python.AWS'