Management commands

The following management commands are available for usage on the datastore.


Creates an admin user:

  • username: demo
  • password: demo-password
  • access token: tokstr

Creates a sample project with the id DEV_SEED_PROJECT with the following traces:


Example usage:

python dev_seed


Creates an admin user with generated password and access token:

  • username: admin
  • password: <generated password>
  • access token: <generated token>

The generated password and access token will be shown in the output:

Admin password: <generated password>
Admin token: <generated token>

Example usage:

python prod_seed


Creates and destroy indexes as part of loading TraceRecords.

Loading raw data is significantly faster if indexes and foreign key constraints are dropped and rebuilt after importing.

This command inspects the current indexes and constraints, dropping all but the primary key indexes.

If new indexes are added, they should be added here (not in model classes) so that they are properly rebuilt during imports.

The results of this command can be inspected through psql:

=> \d datastore_tracerecord

With indexes, the description will look something like this:

    "datastore_tracerecord_pkey" PRIMARY KEY, btree (id)
    "datastore_tracerecord_ffe73c23" btree (trace_id)
Foreign-key constraints:
    FOREIGN KEY (trace_id) REFERENCES datastore_trace(id)

Without indexes, it will look something like this:

    "datastore_tracerecord_pkey" PRIMARY KEY, btree (id)

Example usage:

To destroy trace_records (before ETL):

python trace_record_indexes destroy

To create trace_records (after ETL):

python trace_record_indexes create


Triggers meter runs for specified projects or traces.

Example usage:

python run_meters --all-traces

Optional arguments:

--projects PROJECTS [PROJECTS ...]
                      Project ids to run
--traces TRACES [TRACES ...]
                      Trace ids to run
--all-projects        Run meters for all projects, overrides --projects
--all-traces          Run meters for all traces, overrides --traces
--use-project-id      Use project_id, not id, for any projects to run
--use-trace-id        Use trace_id, not id, for any traces to run
--purge-queue         Purges celery queue before adding meter runs
--detailed-output     Provides more detailed project and trace level output
                      re: meter ids
                      Delete old meter runs associated with these ids


Check progress of one or more meter runs.

Example usage:

python meter_progress --all-meters

Optional arguments:

--meters METERS [METERS ...]
                      Meter ids to check
--all-meters          Check progress for all meters
                      Repeatedly check progress until all meters complete
--poll-interval POLL_INTERVAL
                      Seconds to wait between checks if --poll-until-
--poll-max POLL_MAX   Max number of seconds to poll if --poll-until-complete
                      before exiting


Delete meter runs.

Example usage:

python delete_meters

Optional arguments:

--meters METERS [METERS ...]
                      Meter ids to delete
--traces TRACES [TRACES ...]
                      Trace ids to delete associated meters
--projects PROJECTS [PROJECTS ...]
                      Project ids to delete associated meters


Run aggregations of meter results by group.

Example usage:

python run_aggregations --all-groups

Optional arguments:

--group-names GROUP_NAMES [GROUP_NAMES ...]
                      Groups against which to run aggregations
--all-groups          Run aggregations for all groups; overrides


Create and destroy the data warehouse mart for meter results.

The warehouse table is warehouse_meterresultmart

Example usage:

python meterresultmart create
python meterresultmart destroy


Create and destroy the data warehouse mart for model results.

The warehouse table is warehouse_modelresultmart

Example usage:

python modelresultmart create
python modelresultmart destroy


Create and destroy a data mart for metering results organized by project for a charting frontend.

The warehouse table is warehouse_projectsummarymart

Example usage:

python projectsummarymart create
python projectsummarymart destroy


Create and destroy a data mart that summarizes traces and their records.

The warehouse table is warehouse_tracesummarymart

Example usage:

python tracesummarymart create
python tracesummarymart destroy


Create and destroy two tables for geographical information

The warehouse tables are warehouse_zctainfo and warehouse_countyinfo

Example usage:

python geoinfo create
python geoinfo destroy