Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add archive_files to scrape args #129

Merged
merged 5 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 6.19.2 - Jun 7, 2024

* Turn off archiving processed realtime bills by default.

## 6.19.0 - April 5, 2024

* Adds a new CLI tool that can be called to resolve unresolved bill-to-bill relationships in the openstates DB
Expand Down
10 changes: 10 additions & 0 deletions openstates/cli/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def do_scrape(
strict_validation=args.strict,
fastmode=args.fastmode,
realtime=args.realtime,
file_archiving_enabled=args.archive,
)
report["jurisdiction"] = jscraper.do_scrape()
stats.write_stats(
Expand Down Expand Up @@ -120,6 +121,7 @@ def do_scrape(
strict_validation=args.strict,
fastmode=args.fastmode,
realtime=args.realtime,
file_archiving_enabled=args.archive,
)
partial_report = scraper.do_scrape(**scrape_args, session=session)
stats.write_stats(
Expand Down Expand Up @@ -152,6 +154,7 @@ def do_scrape(
strict_validation=args.strict,
fastmode=args.fastmode,
realtime=args.realtime,
file_archiving_enabled=args.archive,
)
report[scraper_name] = scraper.do_scrape(**scrape_args)
session = scrape_args.get("session", "")
Expand Down Expand Up @@ -499,6 +502,13 @@ def parse_args() -> tuple[argparse.Namespace, list[str]]:
# realtime mode
parser.add_argument("--realtime", action="store_true", help="enable realtime mode")

# Archiving realtime processing JSON files
parser.add_argument(
"--archive",
action="store_true",
help="enable archiving of realtime processing JSON files, defaults to false",
)

# process args
return parser.parse_known_args()

Expand Down
5 changes: 4 additions & 1 deletion openstates/scrape/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,15 @@ def __init__(
strict_validation=True,
fastmode=False,
realtime=False,
file_archiving_enabled=False,
):
super(Scraper, self).__init__()

# set options
self.jurisdiction = jurisdiction
self.datadir = datadir
self.realtime = realtime
self.file_archiving_enabled = file_archiving_enabled

# scrapelib setup
self.timeout = settings.SCRAPELIB_TIMEOUT
Expand Down Expand Up @@ -139,6 +141,7 @@ def push_to_queue(self):
"bucket": bucket,
"jurisdiction_id": self.jurisdiction.jurisdiction_id,
"jurisdiction_name": self.jurisdiction.name,
"file_archiving_enabled": self.file_archiving_enabled,
}
)

Expand Down Expand Up @@ -183,7 +186,7 @@ def save_object(self, obj):
# Remove redundant prefix
try:
upload_file_path = file_path[
file_path.index("_data") + len("_data") + 1:
file_path.index("_data") + len("_data") + 1 :
]
except Exception:
upload_file_path = file_path
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "openstates"
version = "6.19.1"
version = "6.19.2"
description = "core infrastructure for the openstates project"
authors = ["James Turk <dev@jamesturk.net>"]
license = "MIT"
Expand Down
Loading