<@ULVA73B9P> yo what are prefect blocks?
# ask-marvin
n
@Marvin yo what are prefect blocks?
m
Blocks in Prefect are a primitive that enable the storage of configuration and provide an interface for interacting with external systems. With blocks, you can securely store credentials for authenticating with services like AWS, GitHub, Slack, and any other system you'd like to orchestrate with Prefect. Blocks expose methods that provide pre-built functionality for performing actions against an external system. They can be used to download data from or upload data to an S3 bucket, query data from or write data to a database, or send a message to a Slack channel. You may configure blocks through code or via the Prefect Cloud and the Prefect server UI. You can access blocks for both configuring flow deployments and directly from within your flow code. Prefect provides some built-in block types that you can use right out of the box. Additional blocks are available through Prefect Integrations. To use these blocks you can pip install the package, then register the blocks you want to use with Prefect Cloud or a Prefect server. Prefect Cloud and the Prefect server UI display a library of block types available for you to configure blocks that may be used by your flows. Blocks are useful for configuration that needs to be shared across flow runs and between flows. For configuration that will change between flow runs, we recommend using parameters. For more details, you can check out the official documentation.
n
@Marvin what do you know about prefect 2 vs prefect 1?
m
Prefect 2 introduced several new features and changes compared to Prefect 1: - Agents: In Prefect 2, there is only one generic agent type. The agent polls a work pool looking for flow runs. - Flexibility: Prefect 2 offers more flexibility thanks to the elimination of flow pre-registration. It also provides more flexibility for flow deployments, including easier promotion of a flow through development, staging, and production environments. - Async Support: Prefect 2 has native async support. - Validation: Out-of-the-box pydantic validation is available in Prefect 2. - Blocks: Prefect 2 introduced Blocks that allow you to securely store UI-editable, type-checked configuration to external systems and an easy-to-use Key-Value Store. All these components are configurable in one place and provided as part of the open-source Prefect 2 product. In contrast, the concept of Secrets in Prefect 1 was much more narrow and only available in Prefect Cloud. - Notifications: Notifications are available in the open-source Prefect 2 version, as opposed to Cloud-only Automations in Prefect 1. - Subflows: Prefect 2 introduced a first-class subflows concept. Prefect 1 only allowed the flow-of-flows orchestrator pattern. With Prefect 2 subflows, you gain a natural and intuitive way of organizing your flows into modular sub-components. For more details, you can check out the migration guide.