catalyst-cooperative / pudl

The Public Utility Data Liberation Project provides analysis-ready energy system data to climate advocates, researchers, policymakers, and journalists.
https://catalyst.coop/pudl
MIT License
476 stars 110 forks source link

Prefect merge discussion #1406

Closed bendnorman closed 2 years ago

bendnorman commented 2 years ago

This issue is to discuss how we want to the work in the Prefect branch #901 in.

Questions

1. What are our top infrastructure issues? Does the Prefect branch get us closer or further to addressing those issues? Some of these issues are being enumerated in #1401.

Here are a couple of our issues and how the prefect branch addresses them:

2. If we are to merge the prefect branch in, what would be the next steps?

zaneselvans commented 2 years ago

Another potential benefit of Prefect is generating an explicit set of dependencies between different products. This could help with debugging and understanding what parts of the overall system are affected by changes. It could also allow us to re-run only those parts of the data processing that need to be re-run to generate new outputs, based on what's been changed.

The pre-database set of dependencies isn't super complex at the moment, but as the data get recombined in more complex ways further downstream it seems hard to keep track of what changes impact which other parts.

zaneselvans commented 2 years ago

Also, as we get more datasets that are unrelated to each other -- at least early on in the pipeline -- being able to process them in parallel should speed things up considerably. There's no reason for the early stages of the EIA 860/861/923/176 or FERC 1/2/EQR or PHMSA data to have to wait on each other. They should all be able to run in parallel until you get to the steps where they're interacting (e.g. entity resolution for EIA data).

bendnorman commented 2 years ago

Good point, Prefect produces very useful visual documentation of dependencies.

The pre-database set of dependencies isn't super complex at the moment, but as the data get recombined in more complex ways further downstream it seems hard to keep track of what changes impact which other parts.

Are you referring to output and analysis tables? If so, using prefect to orchestrate the creation of those tables makes sense.

bendnorman commented 2 years ago

Not to throw a wrench in this decision but I spent some time reading about another python orchestration tool called Dagster. It seems much more data engineering focused where as Prefect tries to be as flexible as possible.

Was Dagster ever considered when we set out to parallelize our ETL? If so, why did we choose Prefect instead?

I’ve highlighted some interesting features that I don’t think Prefect addresses.

Interesting features

Other

zaneselvans commented 2 years ago

Are you referring to output and analysis tables? If so, using prefect to orchestrate the creation of those tables makes sense.

Yes, the MCOE, the Plant Plarts Plist, the fuzzily-merged FERC+EIA data, the utility + balancing authority service territories, the hourly state-level electricity demand, etc -- basically any "stock" analysis that we create that generates a generally useful tabular output should eventually be getting written to a DB, so that anyone can use it without need to run code -- they can just install it using one of the data catalogs.

zaneselvans commented 2 years ago

A good video overview of Dagster.

After spending an hour with the tutorial and video walkthrough it seems really similar to Prefect, but with stronger opinions and more defined structures. But those opinions and structures seem to be pretty directly aimed at our patterns of use.

Another think I liked was how easy they made it seem to swap out local disk, database, or object store persistence, so testing, CI, cloud versions of the same run could all be easily done only swapping out the persistence layer / objects.

I like the focus on typing, enumerating, validating, tracking of the assets that are produced as much as or even more than the DAG itself. They seem more like a necessary glue in Prefect, but not a focus.

The tracking of how assets evolve over time is also attractive -- being able to see how the number of rows in a table has changed, and the schema of the table would be really useful.

What I really want is an opinionated tool for our use case with good opinions since left to our own devices we'll probably come up with bad opinions, since we aren't experts.

Another thing I liked was the ability to swap out different persistence layers so that local testing / CI / deployment can use the same data processing code, with the saving of assets decoupled from the rest of the system.

bendnorman commented 2 years ago

We have decided to move forward with Dagster. See epic #1487 for the full reasoning.