This is a simple support for an interactive shell with Esmerald. This directive simply loads some
of the defaults such as
settings and some others by
default (like Pydantic
FieldInfo...) saving you time every time you need to use an
interactive shell to test some ad-hoc processes.
Esmerald gives you that possibility completely out of the box and ready to use with your application.
Before reading this section, you should get familiar with the ways Esmerald handles the discovery of the applications.
How does it work¶
Esmerald ecosystem is complex internally but simpler to the user. Esnerald will use the application discovery to understand some of your defaults and events and start the shell.
To run any of the available shells you will need
ptpython or both installed.
$ pip install ipython
$ pip install esmerald[ipython]
$ pip install ptpython
$ pip install esmerald[ptpyton]
How to call it¶
With auto discovery¶
$ esmerald shell
$ esmerald shell --kernel ptpython
$ esmerald --app myproject.main:app shell
$ export ESMERALD_DEFAULT_APP=--app myproject.main:app $ esmerald shell --kernel ptpython
If you want to use your custom EsmeraldSettings¶
$ export ESMERALD_SETTINGS_MODULE=MyCustomSettings $ export ESMERALD_DEFAULT_APP=--app myproject.main:app $ esmerald shell # default $ esmerald shell --kernel ptpython # start with ptpython
How does it look like¶
Esmerald doesn't want to load all python globals and locals for you. Instead loads all the essentials and and some python packages automatically for you but you can still import others.
It looks like this:
Of course the
are replaced automatically by the version you are using.
Pretty cool, right? Then it is a normal python shell where you can import whatever you want and need as per normal python shell interaction.