-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #127 from openstates/cli-relationships-resolve
CLI command to resolve relationships
- Loading branch information
Showing
7 changed files
with
109 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import click | ||
import logging | ||
import logging.config | ||
from openstates.utils import abbr_to_jid | ||
from ..utils.django import init_django | ||
from ..exceptions import InternalError | ||
from .. import settings | ||
|
||
|
||
@click.command(help="Resolve unresolved relationships between entities") | ||
@click.argument("jurisdiction_abbreviation") | ||
@click.option( | ||
"--log_level", | ||
help="Set the level of logging to output.", | ||
default="INFO" | ||
) | ||
def main(jurisdiction_abbreviation: str, log_level: str) -> None: | ||
# set up logging | ||
logger = logging.getLogger("openstates") | ||
handler_level = log_level | ||
settings.LOGGING["handlers"]["default"]["level"] = handler_level # type: ignore | ||
logging.config.dictConfig(settings.LOGGING) | ||
|
||
# set up django for DB access | ||
# has to be done before any importer can be imported (?) | ||
init_django() | ||
from openstates.importers import resolve_related_bills | ||
|
||
logger.info(f"Beginning resolution of bill relationships for {jurisdiction_abbreviation}") | ||
jurisdiction_id = abbr_to_jid(jurisdiction_abbreviation) | ||
try: | ||
resolve_related_bills(jurisdiction_id, logger) | ||
except InternalError as e: | ||
logger.error(f"Error during bill relationship resolution for {jurisdiction_abbreviation}: {e}") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# flake8: noqa | ||
from .jurisdiction import JurisdictionImporter | ||
from .organizations import OrganizationImporter | ||
from .bills import BillImporter | ||
from .bills import BillImporter, resolve_related_bills | ||
from .vote_events import VoteEventImporter | ||
from .events import EventImporter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "openstates" | ||
version = "6.18.5" | ||
version = "6.19.0" | ||
description = "core infrastructure for the openstates project" | ||
authors = ["James Turk <[email protected]>"] | ||
license = "MIT" | ||
|
@@ -13,6 +13,7 @@ os-text-extract = 'openstates.cli.text_extract:main' | |
os-people = 'openstates.cli.people:main' | ||
os-committees = 'openstates.cli.committees:main' | ||
os-us-to-yaml = 'openstates.cli.convert_us:main' | ||
os-relationships = 'openstates.cli.relationships:main' | ||
os-scrape = 'openstates.cli.scrape:main' | ||
os-validate = 'openstates.cli.validate:main' | ||
|
||
|
@@ -34,6 +35,7 @@ PyJWT = "^2.5.0" | |
boto3 = "^1.26.61" | ||
us = "^3.1.1" | ||
influxdb-client = "^1.37.0" | ||
pytz = "^2024.1" | ||
|
||
[tool.poetry.dev-dependencies] | ||
pytest = "^5.4.1" | ||
|