Skip to main content

openstates-core

This repository contains the Open States data model and scraper backend.

Release steps

See RELASE.md

Database Migrations

openstates-core data models may occasionally change, requiring changes to the Open States database in production. Here are the steps to create and execute a new migration:

  • Follow the steps in Running a Local Database doc to get a copy of the database running locally with the prior schema. It is important to develop and test your migration locally before executing it on the production DB.
  • In most cases, you will auto-generate a migration by first modifying the model file. Make a change to one or more of the files in openstates/data/models.
  • Test the migration locally:
    • Identify the DB connection URL that is accurate to your local database. In most cases, it should be: postgis://openstates:openstates@localhost:5405/openstatesorg
    • In the repo's root folder, run the os-dbmakemigrations command to generate a migration file based on your changes: DATABASE_URL=postgis://openstates:openstates@localhost:5405/openstatesorg uv run os-dbmakemigrations
    • Look at the generated migration file in openstates/data/migrations and ensure that it looks correct.
    • Execute the migration by running the os-initdb command: DATABASE_URL=postgis://openstates:openstates@localhost:5405/openstatesorg uv run os-initdb
  • Once the migration is verified by local testing, you can execute it against the production DB
    • Identify the DB connection URL that is accurate for the PROD database. This typically should use the same Postgres user that owns the tables you want to change. Contact an admin if you need help.
    • Run the os-initdb command to migrate: DATABASE_URL=postgis://USERNAME_HERE:PASSWORD_HERE@PROD_DB_HOSTNAME_HERE:5432/openstatesorg uv run os-initdb

Debugging openstates-core code

Commands that do not integrate with openstates-scrapers

  • Install uv
  • uv sync (uv installs the python version from .python-version automatically)

Example PyCharm config (for relationships CLI command):

  • Interpeter: the .venv that uv sync just set up
  • Module: openstates.cli.relationships
  • Parameters: --log_level=DEBUG us
  • Env vars: DATABASE_URL=postgres://USERNAME:PASSWORD@DB_HOSTNAME:PORT/openstatesorg

Update command / scrapers

There are instructions on running a scraper here but what if you want to debug the command that wraps around the scraper code? This repository's update CLI module is the code that accepts parameters and actually executes the scraper (from openstates-scrapers). Another wrinkle is that the update command needs to be run inside the context of the openstates-scrapers repository, as it will attempt to load in the relevant scraper for the jurisdiction requested, and that import will fail if you try to run the code here within openstates-core.

Here's a recipe using PyCharm to successfully debug the update command:

Requirements to run the scrape/update code natively (not in docker)

  • You need the gdal library installed on the host system. For me: sudo apt install gdal-bin python3-gdal
  • openstates-core checked out at /home/username/repo/openstates/openstates-core/
  • (let's assume you have made some changes in openstates-core that you want to test)
  • openstates-scrapers checked out /home/username/repo/openstates/openstates-scrapers/
  • Change directory to /home/username/repo/openstates/openstates-scrapers/
  • Install required python version using the pyenv utility
  • pip install poetry (if that python version doesn't already have it)

Debugging the scrape/update code natively

  • If you have previously installed the openstates dependency (eg openstates-core), then you need to run poetry remove openstates to clear that remotely-installed (from pypi) dependency. Each time you make a round of changes to openstates-core, you will need to remove and then re-add the dependency.
  • poetry add ../openstates-core/ will add the openstates dependency from your local filesystem/local checkout
  • poetry install
  • In PyCharm, open the openstates-scrapers folder
  • In PyCharm, set up a new run config:
    • type: python
    • module: openstates.cli.update
    • parameters: vi bills (or whatever you want to run)
    • working directory: /home/username/repo/openstates/openstates-scrapers/scrapers
  • Run the run config in debug mode within PyCharm (eg the one working on openstates-scrapers). You can set breakpoints within both the scraper code AND in the openstates-core code. However you need to open (in PyCharm) the copy of openstates-core that poetry installed, which probably is in a location like: /home/username/.cache/pypoetry/virtualenvs/openstates-scrapers-93BMrPXy-py3.9/lib/python3.9/site-packages/openstates/cli/update.py

Reminder: when further changes are made to the openstates-core package locally, and you want to debug them again, you need to remove/re-add to update files in openstates-scrapers

  • Change directory to /home/username/repo/openstates/openstates-scrapers/
  • poetry remove openstates
  • poetry add ../openstates-core/
  • (you will need to re-establish breakpoints in any openstates-core files)

Metadata

Release files for openstates 7.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openstates 7.0.0
File Size Uploaded Provenance Actions
openstates-7.0.0.tar.gz 440.5 kB Without provenance Details for openstates-7.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for openstates 7.0.0
File Interpreter ABI Platform Actions
openstates-7.0.0-py3-none-any.whl Python 3 none any Details for openstates-7.0.0-py3-none-any.whl

Total release size: 986.7 kB

Release files / openstates-7.0.0.tar.gz

Download URL openstates-7.0.0.tar.gz
Size 440.5 kB
Tags Source
SHA-256 checksum
How to use checksums
bcfe5d62f4d232dede175c4d5430ada251962772fa6f64d541ebb0f2a51d73e1
BLAKE2b-256 checksum
How to use checksums
3d5eb5176f2c42dea4ec56bffdab7cf4b3aabb276c707e080246555e72c8d05a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / openstates-7.0.0-py3-none-any.whl

Download URL openstates-7.0.0-py3-none-any.whl
Size 546.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2f6825189be99c4dc7ba6b2b5ab92107f4c11de11e9a870aa0325a3f3838d307
BLAKE2b-256 checksum
How to use checksums
b0f149b172dcae13975db3c400efdc7f4b9930945cf656d807c7a61156eb4fd5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for openstates 7.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

7.0.0 This release

2 release files No provenance

0.1

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page