seedcase-project / seedcase-sprout

Upload your research data to formally structure it for better, more reliable, and easier research.
https://sprout.seedcase-project.org/
MIT License
0 stars 0 forks source link

Make sure database (and Django, if relevant) is initialised when accessing Sprout from the command line #502

Open martonvago opened 3 months ago

martonvago commented 3 months ago

We want CLI commands to be accessible directly in the terminal (e.g. > my-command --option 3) when Sprout is installed, so we have to add our commands as entry points in pyproject.toml. This is a more complex setup than using custom admin commands (e.g. > python manage.py my-command --option 3). When the app is accessed directly through a command, so not via manage.py, Django and the database have to be set up manually, including pointing to the settings file, running django.setup() and running the migrations. Ideally (perhaps), these setup commands would be run once in a sort of post-install step, not before every command.

I’m not 100% sure what the best strategy would be for this, some possible options:

Note that even if we can avoid having Django as a dependency of the core app, the database still needs to be initialised before we can run CLI commands that access it.

Related: https://github.com/seedcase-project/seedcase-sprout/issues/479

martonvago commented 3 months ago

If we don't have a database in core and don't depend on Django, then this is not needed. (See this comment.)

lwjohnst86 commented 3 months ago

Wonderful, thanks for this! I think we can keep this as a lower priority, and implement the actual CLI later. But at least make sure to design what ever we build with this in mind 😁