This command allows you to run a piece of Python code with the application configuration loaded similarly to baseplate-serve. The command is baseplate-script.

Command Line

There are two required arguments on the command line: the path to an INI-format configuration file, and the fully qualified name of a Python function to run.

The function should be specified as a module path, a colon, and a function name. For example, my_service.models:create_schema. The function should take a single argument which will be the application’s configuration as a dictionary. This is the same as the application factory used by the server.

Just like with baseplate-serve, the app:main section will be loaded by default. This can be overridden with the --app-name option.


Given a configuration file, printer.ini:

message = Hello!

message = !olleH

and a small script,

def run(app_config, args):
    parser = argparse.ArgumentParser()
    args = parser.parse_args(args)

    print(f"{app_config['message']} {}")

You can run the script with various configurations:

$ baseplate-script printer.ini printer:run Goodbye.
Hello! Goodbye.

$ baseplate-script printer.ini --app-name=bizarro printer:run Goodbye.
!olleH Goodbye.