Skip to content

Commit

Permalink
Merge pull request #152 from openstates/cloud-archive-log-message
Browse files Browse the repository at this point in the history
Add context to cloud archive log message output
  • Loading branch information
jessemortenson authored Nov 7, 2024
2 parents 7585789 + c82ecac commit a569a86
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 6.20.10 - Nov 7, 2024

* Add additional log info re: archiving scrape files to cloud storage

## 6.20.9 - Nov 4, 2024

* Fix bug with import caused by newish "extras" field on scraper
Expand Down
7 changes: 4 additions & 3 deletions openstates/cli/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,19 +223,20 @@ def archive_to_cloud_storage(
cloud_storage_client = storage.Client(project=GCP_PROJECT)
bucket = cloud_storage_client.bucket(BUCKET_NAME)
jurisdiction_id = juris.jurisdiction_id.replace("ocd-jurisdiction/", "")
destination_prefx = (
destination_prefix = (
f"{SCRAPE_LAKE_PREFIX}/{jurisdiction_id}/{last_scrape_end_datetime.isoformat()}"
)

# read files in directory and upload
files_count = 0
for file_path in glob.glob(datadir + "/*.json"):
files_count += 1
blob_name = os.path.join(destination_prefx, os.path.basename(file_path))
blob_name = os.path.join(destination_prefix, os.path.basename(file_path))
blob = bucket.blob(blob_name)
blob.upload_from_filename(file_path)

logger.info(f"Completed archive to Google Cloud Storage, {files_count} files were uploaded.")
logger.info(f"Completed archive to Google Cloud Storage, {files_count} files "
f"were uploaded to {destination_prefix}.")

except Exception as e:
logger.warning(f"An error occurred during the attempt to archive files to Google Cloud Storage: {e}")
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.20.9"
version = "6.20.10"
description = "core infrastructure for the openstates project"
authors = ["James Turk <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit a569a86

Please sign in to comment.