Great experience using Server Console

I just had a great experience using the Server Console (my first time ever) in the Beta interface and thought it would be nice to share some positive feedback…

I was refactoring some code designed to run on a standalone Windows machine and wanted a quick way to port the long config files into an Anvil database. It turned out to be pretty effortless… I created the new data table (‘config’) in the normal way and already had “auto-create columns” enabled. I then just started typing on the command line interpreter/server console and watched my new table pretty much populate itself!

The config file was a Python module mainly comprising nested dictionaries which were imported by other modules. Something like this:

PARAMS = {
    "aida": {
        'top_p': 0.4,
        'top_k': 40,
        'temperature': 0.8,
        'repetition_penalty': 1.1,
        'length': 100,
}

#  The actual file is much longer and more complex, but this gives you an idea

Rather than slavishly convert to CSV and upload, or copy/paste, this was all I needed to type in the Server Console:

from anvil.tables import app_tables

C = app_tables.config

for k,v in config.PARAMS.items():
    if not v:
        continue
    row = C.get(job_name=k) or C.add_row(job_name=k)
    row.update(**v)

In particular something I noticed you can do with the Server Console is enter multi-line snippets like the above AND go back and edit them in place. I’m used to VS-Code where you have to start again if you make a mistake in one of the lines while using the terminal. Tab indentation was also a breeze.

Anyway, I was really happy I didn’t need to create a whole new script and either a temporary web page to run the code, or connect something with the Anvil uplink. Job done, nice and quickly just using the Server Console. Great to have this ability - thanks!

4 Likes