https://github.com/catalyst-cooperative/pudl-zenodo-storage

Tools for creating versioned archives of raw data on Zenodo using Frictionless data packages.

https://github.com/catalyst-cooperative/pudl-zenodo-storage

Science Score: 20.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
    1 of 8 committers (12.5%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (17.1%) to scientific vocabulary

Keywords

api archiver census-data dataset doi eia electricity energy epa ferc frictionless-data metadata natural-gas open-data public-data pudl python zenodo

Keywords from Contributors

archival policies emissions climate climate-change webscraping environmental-data ghg reproducibility energy-data
Last synced: 5 months ago · JSON representation

Repository

Tools for creating versioned archives of raw data on Zenodo using Frictionless data packages.

Basic Info
  • Host: GitHub
  • Owner: catalyst-cooperative
  • License: mit
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 236 KB
Statistics
  • Stars: 2
  • Watchers: 4
  • Forks: 2
  • Open Issues: 0
  • Releases: 0
Archived
Topics
api archiver census-data dataset doi eia electricity energy epa ferc frictionless-data metadata natural-gas open-data public-data pudl python zenodo
Created about 6 years ago · Last pushed about 3 years ago
Metadata Files
Readme License

README.md

PUDL Utils for Zenodo storage and packaging

Deprecated

This repo has been replaced by the new pudl-archiver repo, which combines both the scraping andd archiving process.

Background on Zenodo

Zenodo is an open repository maintained by CERN that allows users to archive research-related digital artifacts for free. Catalyst uses Zenodo to archive raw datasets scraped from the likes of FERC, EIA, and the EPA to ensure reliable, versioned access to the data PUDL depends on. Take a look at our archives here. In the event that any of the publishers change the format or contents of their data, remove old years, or simply cease to exist, we will have a permanent record of the data. All data uploaded to Zenodo is assigned a DOI for streamlined access and citing.

Whenever the historical data changes substantially or new years are added, we make new Zenodo archives and build out new versions of PUDL that are compatible. Paring specific Zenodo archives with PUDL releases ensures a functioning ETL for users and developers.

Once created, Zenodo archives cannot be deleted. This is, in fact, their purpose! It also means that one ought to be sparing with the information uploaded. We don't want wade through tons of test uploads when looking for the most recent version of data. Luckily Zenodo has created a sandbox environment for testing API integration. Unlike the regular environment, the sandbox can be wiped clean at any time. When testing uploads, you'll want to upload to the sandbox first. Because we want to keep our Zenodo as clean as possible, we keep the upload tokens internal to Catalyst. If there's data you want to see integrated, and you're not part of the team, send us an email at hello@catalyst.coop.

One last thing-- Zenodo archives for particular datasets are referred to as "depositions". Each dataset is it's own deposition that gets created when the dataset is first uploaded to Zenodo and versioned as the source releases new data that gets uploaded to Zenodo.

Installation

We recommend using mamba to create and manage your environment.

In your terminal, run:

bash $ mamba env create -f environment.yml $ mamba activate pudl-zenodo-storage

Adding a New Data Source

When you're adding an entirely new dataset to the PUDL, your first course of action is building a scrapy script in the pudl-scrapers repo. Once you've done that, you're ready to archive.

First, you'll need to fill in some metadata in the pudl repo. Start by adding a new key value pair in the SOURCE dict in the pudl/metadata/source.py module. It's best to keep the key (the source name) you choose simple and consistent across all repos that reference the data. Once you've done this, you'll need to install your local version of pudl (rather than the default version from GitHub). Doing this will allow the Zenodo archiver script to process changes you made to the pudl repo.

While in the pudl-zenodo-storage environment, navigate to the pudl repo and run:

bash $ pip install -e ./

You don't need to worry about the fields.py module until you're ready to transform the data in pudl.

Now, come back to this repo and create a module for the dataset in the frictionless directory. Give it the same name as the key you made for the data in the SOURCE dict. Use the existing modules as a model for your new one. The main function is called datapackager() and it serves to produce a json for the Zenodo archival collection.

Lastly, you need to:

  • Add archive metadata for the new dataset in the zs/metadata.py module. This includes creating a UUID (universally unique identifier) for the data. UUIDs are used to uniquely distinguish the archive prior to the creation of a DOI. You can do this using the uuid.uuid4() function that is part of the Python standard library.
  • Add the chosen deposition name to this list of acceptable names output with the zenodo_store --help flag. See parse_main() in zs.cli.py.
  • Add specifications for your new deposition in the archive_selection() function also in zs.cli.py.

Updating an Existing Data Source

If updating an existing data source -- say, one that as released a new year's worth of data -- you don't need to add any new metadata to the pudl repo. Simply run the scraper for the data and then run the Zenodo script as described below. The code was built to detect any changes in the data and automatically create a new version of the same deposition when uploaded.

Running the Zenodo Archiver Script

Before you can archive data, you'll need to run the scrapy script you just created in the pudl-scrapers repo. Once you've scraped the data, then you can come back and run the archiver. This script, zenodo_store gets defined as an entry point in setup.py.

Next, you'll need to define ZENODO_SANDBOX_TOKEN_UPLOAD and ZENODO_TOKEN_UPLOAD environment variables on your local machine. As mentioned above, we keep these values internal to Catalyst so as to maintain a clean and reliable archive.

The zenodo_store script requires you to include the name of the Zenodo deposition as an argument. This is a string value that indicates which dataset you're going to upload. Use the --help flag to see a list of supported strings. You can also find a list of the deposition names in the archive_selection() function in the cli.py module.

When you're testing an archive, you'll want to make sure you use the Zenodo sandbox rather than the official Zenodo archive (see above for more info about the sandbox). Adding the --verbose flag will print out logging messages that are helpful for debugging. Adding the --noop flag will show you whether your the data you scraped is any different from the data you already have uploaded to Zenodo without uploading anything (so long as there is an existing upload to compare it to).

If the dataset is brand new, you'll also need to add the --initialize flag so that it knows to create a new deposition for the data.

Make sure a new deposition knows where to grab scraped data:

bash $ zenodo_store newdata --noop --verbose

txt Archive would contain: path/to/scraped/data

Compare a newly scraped deposition to the currently archived deposition of the same dataset. If you get the output depicted below then the archive data is the same as the scraped data, and you don't need to make a new version!

bash $ zenodo_store newdata --noop

json { "create": {}, "delete": {}, "update": {} }

Test run a new deposition in the sandbox (the output link is fake!):

bash $ zenodo_store newdata --sandbox --verbose --initialize

txt Uploaded path/to/scraped/data Your new deposition archive is ready for review at https://sandbox.zenodo.org/deposit/number

Once you're confident with your upload, you can go ahead and run the script without any flags.

bash $ zenodo_store newdata

Repo Contents

zs

The zs.ZenodoStorage class provides an interface to create archives and upload files to Zenodo.

frictionless

Package metadata in dict formats, as necessary to support the frictionless datapackage specification.

Owner

  • Name: Catalyst Cooperative
  • Login: catalyst-cooperative
  • Kind: organization
  • Email: hello@catalyst.coop
  • Location: United States of America

Catalyst is a small data engineering cooperative working on electricity regulation and climate change.

GitHub Events

Total
Last Year

Committers

Last synced: about 2 years ago

All Time
  • Total Commits: 143
  • Total Committers: 8
  • Avg Commits per committer: 17.875
  • Development Distribution Score (DDS): 0.664
Past Year
  • Commits: 6
  • Committers: 2
  • Avg Commits per committer: 3.0
  • Development Distribution Score (DDS): 0.167
Top Committers
Name Email Commits
Zane Selvans z****s@c****p 48
Pablo Virgo m****x@p****m 42
Austen Sharpe a****e@g****m 16
zschira z****a@c****p 14
dependabot[bot] 4****] 8
pre-commit-ci[bot] 6****] 6
bendnorman b****9@c****u 6
Christina Gosnell c****l@c****p 3
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: about 2 years ago

All Time
  • Total issues: 16
  • Total pull requests: 25
  • Average time to close issues: 4 months
  • Average time to close pull requests: 21 days
  • Total issue authors: 4
  • Total pull request authors: 8
  • Average comments per issue: 0.94
  • Average comments per pull request: 1.36
  • Merged pull requests: 19
  • Bot issues: 0
  • Bot pull requests: 9
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • zaneselvans (8)
  • cmgosnell (6)
  • zschira (1)
  • aesharpe (1)
Pull Request Authors
  • dependabot[bot] (9)
  • zaneselvans (4)
  • aesharpe (3)
  • bendnorman (3)
  • ptvirgo (2)
  • zschira (2)
  • karldw (1)
  • cmgosnell (1)
Top Labels
Issue Labels
zenodo (7) xbrl (5) dbf (4) rmi (2) ferc2 (1) ferc6 (1) ferc60 (1) ferc714 (1) csv (1) ferc1 (1) packaging (1)
Pull Request Labels
dependencies (6) github_actions (2) rmi (2) zenodo (2)

Dependencies

environment.yml conda
  • pip >=21.0,<22
  • python >=3.10,<3.11
  • tox >=3.24,<4
setup.py pypi
  • catalystcoop.pudl *
  • datapackage >=1.0,<2.0
  • factory_boy >=2.12,<4
  • pydantic *