Ryan Peden
03/02/2023, 7:23 PMKubernetesClusterConfig
, graceful SIGTERM handling in Prefect Server, and much more.
See the release notes for a complete list of changes and bug fixes.
And for Google Cloud users, we also released a new version of the prefect-gcp collection!Jenny
03/08/2023, 7:42 PMNate
03/08/2023, 9:04 PMFlows
tab of your Prefect Cloud UI, you should notice a new button Add from Collections
.
When you click it, you'll see a variety of different flows that we've defined in our collections ecosystem. For each flow, you'll see an example of how that flow can be used and a link to its docs.
Each example is taken directly from the docstring of that flow, so for example if you click on run-dbt-cloud-job
, you'll find a nice markdown render of this docstring.
The nice thing about this is that if you've developed a nice way of a using a flow from a given collection, you can open a PR to that collection to add your example to the flow's docstring - and after we review and merge your PR, it will appear here in the UI!
π£οΈ If you have any feedback, questions, or if you want to learn more about how you can include a flow of yours here... reach out in #prefect-integrations or #prefect-contributors and we'll help you along
marvin Happy Engineering!Ryan Peden
03/10/2023, 2:35 AMChris Reuter
03/14/2023, 2:49 PMChris Reuter
03/14/2023, 4:25 PMlangchain-prefect
, a plugin for building with LLMs at scale.
Read more here or check it out on GitHub.
If you have any questions come join us at #prefect-ai!Ryan Peden
03/17/2023, 12:02 AMprefect.runtime
namespace:
from prefect.runtime import flow_run
from prefect import flow
from prefect_dask.task_runners import DaskTaskRunner
@flow(task_runner=DaskTaskRunner(client_kwargs = {"name": flow_run.id}))
def my_flow():
...
This will create a Dask client whose name mirrors the flow run ID. Similarly, you can use prefect.runtime
to access parameters that were passed to this deployment run via prefect.runtime.deployment.parameters
. Note that all of these attributes will be empty if they are not available.
See #8790 for details.
A few other key enhancements and fixes:
Enhancements
β’ Add deployment ID support to run_deployment
πͺͺ β #7958
β’ Disable Postgres JIT for performance improvements π β #8804
Fixes
β’ Fix blocking file read in async method Deployment.load_from_yaml
π οΈ β #8798
β’ Allow tasks and flows to make redundant transitions such as RUNNING
-> RUNNING
πββοΈ πββοΈ β #8802
Documentation
β’ Update workspace roles table to emphasize differences between roles β #8787
β’ Add Webhook block docs πͺ β #8773
β’ Update info on Ray's support for hardware and software rayβ #8811
Helm chart
β’ Helm charts are now automatically published on each Prefect release kubernetes β #8776
Contributors
β’ @devanshdoshi9
See the release notes for a full list of changes!Ryan Peden
03/23/2023, 10:55 PMChris Reuter
03/27/2023, 6:19 PM<mailto:help@prefect.io|help@prefect.io>
or meeting with one of our product advocates directly. The price will be a flat fee of $500/mo, billed annually via a separate invoice.
This plan includes:
β’ Access to our Dedicated Support Team
β’ 9a-5p CST SLA
β’ 1 Hour Initial Technical Sync
Our talented Solution Engineering team is looking forward to delivering incredible support for our open source and self-serve developers! To get support for your open source deployment or self-serve Prefect Cloud account, reach out to <mailto:help@prefect.io|help@prefect.io>
today.Ryan Peden
03/30/2023, 7:44 PMcreate_table_artifact()
function:
βββ β
from prefect import task, flow
from prefect.artifacts import create_table_artifact
@task
def my_table_task():
table_data = [
{"id": 0, "name": "Dublin", "lat": 53.3498, "lon": -6.2603,},
{"id": 1, "name": "London", "lat": 51.5074, "lon": -0.1278,},
{"id": 2, "name": "New York", "lat": 40.7128, "lon": -74.0060,},
{"id": 3, "name": "Oslo", "lat": 59.9139, "lon": 10.7522,},
{"id": 4, "name": "Paris", "lat": 48.8566, "lon": 2.3522,},
{"id": 5, "name": "Rome", "lat": 41.9028, "lon": 12.4964,},
{"id": 6, "name": "Tokyo", "lat": 35.6895, "lon": 139.6917,},
{"id": 7, "name": "Vancouver", "lat": 49.2827, "lon": -123.1207,}
]
return create_table_artifact(
key="cities-table",
table=table_data,
description="A table of cities and their coordinates",
)
@flow
def my_flow():
table = my_table_task()
return table
if __name__ == "__main__":
my_flow()
You can view your artifacts in the Artifacts page of the Prefect UI, easily search the data in your new table artifact, and toggle between a rendered and raw version of your data - see the second screenshot attached below.
β’ See the documentation to learn more about Artifacts!
βββ β
Configure result storage keys π
When persisting results, Prefect stores data at a unique, randomly-generated path. While this is convenient for ensuring the result is never overwritten, it limits organization of result files. In this release, weβve added configuration of result storage keys, which gives you control over the result file path. Result storage keys can be dynamically formatted with access to all of the modules in prefect.runtime
and the runβs parameters
.
βββ β
For example, you can name each result to correspond to the flow run that produced it and a parameter it received:
from prefect import flow, task
@flow()
def my_flow():
hello_world()
hello_world(name="foo")
hello_world(name="bar")
@task(
persist_result=True,
result_storage_key="hello__{flow_run.name}__{parameters[name]}.json",
)
def hello_world(name: str = "world"):
return f"hello {name}"
my_flow()
βββ β
Which will persist three result files in the storage directory:
$ ls ~/.prefect/storage | grep "hello__"
hello__rousing-mushroom__bar.json
hello__rousing-mushroom__foo.json
hello__rousing-mushroom__world.json
βββ βββ ββ
See the documentation for more information.
βββ β
βββ β
Expanded prefect.runtime
βββ β
The prefect.runtime
module is now the preferred way to access information about the current run. In this release, weβve added the following attributes:
β’ prefect.runtime.task_run.id
β’ prefect.runtime.task_run.name
β’ prefect.runtime.task_run.task_name
β’ prefect.runtime.task_run.tags
β’ prefect.runtime.task_run.parameters
β’ prefect.runtime.flow_run.name
β’ prefect.runtime.flow_run.flow_name
β’ prefect.runtime.flow_run.parameters
βββ β
See the documentation for more information!
Contributors
We have several first-time contributors in this release. Letβs give them a round of applause! π
βββ β
β’ @andreadistefano made their first contribution in #8942
β’ @knl made their first contribution in #8974
β’ @thomas-te made their first contribution in #8959
Here are a few key enhancements and fixes:
βββ β
Enhancements
β’ π’ Add unique integers to worker thread names for inspection - #8908
β’ π Add support to JSONSerializer
for serialization of exceptions so they are persisted even on failure - #8922
β’ ποΈ Add Gzip middleware to the UI and API FastAPI apps for compressing responses - #8931
β’ π Update the runtime to detect flow run information from task run contexts β #8951
βββ β
Fixes
β’ π οΈ Fix imports in copytree backport for Python 3.7 - #8925
β’ π Retry on sqlite operational errors - #8950
β’ β±οΈ Add 30 second timeout to shutdown of the log worker thread β #8983
ββββββ ββ
See the release notes for full details on the updates in Prefect 2.9.0!Jenny
03/30/2023, 8:48 PMJeremiah
def
of a function you wish you had⦠and then you call it.
π To get this magic, just add Marvinβs @ai_fn
decorator. Hereβs an example:
from marvin import ai_fn
@ai_fn
def spam_rating(email_body: str) -> int:
"""
Returns a number between 0 and 100
that represents how likely the email is spam
"""
spam_rating("Hey, just following up about dinner tomorrow.") # 17
spam_rating("Hi, I'm Nigerian prince and I really need your help.") # 95
βοΈ Obviously, this is cool. But more importantly, it aligns with Prefectβs product mission to eliminate negative engineering and bring engineers as close as possible to their objectives. Give Marvin a star on GitHub and stay tuned β AI functions are just the beginning of what it can do.
π¬ Marvinβs community is forming in Discord. Join us there if building with AI is interesting to you!
π Happy engineering!Chris Reuter
03/31/2023, 12:19 PMmarvin chat
action.
Join directly on our YouTube channel or add to your calendar!Ryan Peden
04/06/2023, 10:06 PMprefect.yaml
file, in which you can specify steps to build the necessary artifacts for a projectβs deployments, push those artifacts, and retrieve them at runtime.
βββ β
Projects are a contract between you and a worker, specifying what you do when you create a deployment, and what the worker will do before it kicks off that deployment. Together, projects and workers bridge your development environment, where your flow code is written, and your execution environment, where your flow code runs. Create your first Prefect project by following this tutorial.
See the new project concept doc for more information.
βββ β
Variables
Variables enable you to store and reuse non-sensitive bits of data, such as configuration information. Variables are named, mutable string values, much like environment variables. They are scoped to a Prefect Server instance or a single workspace in Prefect Cloud. Variables can be created or modified at any time.
βββ β
While variable values are most commonly loaded during flow runtime, they can be loaded in other contexts, at any time, such that they can be used to pass configuration information to Prefect configuration files, such as project steps. You can access any variable via the Python SDK via the .get()
method.
from prefect import variables
# from a synchronous context
answer = variables.get('the_answer')
print(answer)
# 42
# from an asynchronous context
answer = await variables.get('the_answer')
print(answer)
# 42
# without a default value
answer = variables.get('not_the_answer')
print(answer)
# None
# with a default value
answer = variables.get('not_the_answer', default='42')
print(answer)
# 42
See the new variables concept doc for more information or the pull request for implementation details.
βββ βββ β
Events
Continuing the rollout of events as the primary unit of observability in Prefect Cloud, Prefect will now emit events for all block method calls by default.
βββ ββββ β
These events can be viewed in the Event feed, allowing you to analyze the interactions your flows and tasks have with external systems such as storage locations, notification services, and infrastructure. Additionally, you can trigger automations based on these events. For example, you can create an automation that is triggered when a file is uploaded to a storage location.
βββ β
Versioned documentation
Weβre releasing many new features every week and we know not everyone is on the latest version of Prefect. Weβve added versioning to our documentation website to make it easier to find the docs for the version of Prefect that youβre using.
Now, when you visit the Prefect documentation site, youβll see a version selector at the top of the page.
βββ β
Breaking Changes
Thereβs one breaking change to be aware of in this release:
β’ Unused options for sorting logs have been removed from the API β #7873
βββ ββββ β
Contributors
Thanks so much to the external contributors to this release!
β’ @mianos made their first contribution in #9077!
β’ @dominictarro made their first contribution in #8965!
β’ @joelluijmes
β’ @john-jam
βββ β
Enhancements and Fixes
The list of enhancements and fixes this week is long, so check out the 2.10.0 release notes to see them all! We added a quick 2.10.1 release with a fix for projects, but 2.10.0 is the place to read about all the changes.Ryan Peden
04/13/2023, 11:43 PMdeployment.yaml
! Thanks to the changes in #9190, Prefect now uses default values for any required keys missing from your projectβs configuration.
βββ β
π Streamlined cancellation for scheduled flow runs
In response to challenges cancelling scheduled flow runs, #8414 introduces a new flow orchestration rule.
This rule ensures scheduled flow runs that havenβt started and lack an infrastructure PID skip the CANCELLING
state where they previously got stuck and directly transition to CANCELLED
.
βββ β
Other Changes:
βββ β
β¨ Enhancements
β’ Add flow run cancellation support for workers - #9198
βββ β
π¨ Fixes
β’ Fix work_queues
and worker_type
arguments for the prefect worker start
CLI command β #9154
β’ Fix overflow in flow run logger UI β #1342
β’ Fix schema form handling of reference objects β #1332
β’ Improve flow graph UX by suppressing shortcuts when a metakey is active β #1333
βββ β
π§ͺ Experimental
β’ Emit an event when a worker submits a flow run for execution β #9203
βββ β
π Documentation
β’ Fix a broken link by removing an obsolete redirect β #9189
β’ Add polling interval information to worker and agent documentation β #9209
β’ Update documentation badge styling to improve docs usability β #9207
βββ βββ β
Normally, weβd suggest you head over to the release notes to learn more about Prefect 2.10.4. But after the big 2.10.0 release a week ago, then two quick follow-up releases, weβve kept 2.10.4 simple β and youβve already seen everything! πjustabill
nicholas
deployment.yaml
file
ππ enhanced support for recursive flow calls and concurrent runs of the same flow
ππ¨βπ» a new tutorial on developing custom workers π€
Check out the release notes for more info!justabill
on_crashed
hook for flows, allowing you to add client-side hooks that will be called when your flow crashes. This is useful for cases where you want to execute code without involving the Prefect API, and for custom handling on CRASHED
terminal states. This callable hook will receive three arguments: flow
, flow_run
, and state
.
from prefect import flow
def crash_hook(flow, flow_run, state):
print("Don't Panic! But the flow has crashed...")
@flow(on_crashed=[crash_hook])
def my_flow():
# call `crash_hook` if this flow enters a `CRASHED` state
pass
Check out the release notes for more information.Will Raphaelson
05/04/2023, 8:30 PMJeff Hale
05/08/2023, 4:56 PMjustabill
Chris Reuter
05/09/2023, 8:29 PMjustabill
Jenny
05/26/2023, 12:42 PMprefect deploy
command now offers interactive prompts for deployment names and work pool selections. π₯ We've also introduced a work pool creation wizard π§ to simplify the process, guiding you through essentials like basic work pool info, infrastructure type, and configuration.
Additional improvements include support for SQLAlchemy 2, and much more!
See the release notes for more details.Jenny
06/02/2023, 2:05 PMjustabill
pip_install_requirements
and run_shell_script
. Both are new 'utility' deployment steps that can be used to automate portions of your deployment process π§° .
For example, use the pip_install_requirements
step to install Python dependencies before kicking off a flow run:
pull:
* prefect.projects.steps.git_clone_project:
id: clone-step
repository: <https://github.com/org/repo.git>
* prefect.projects.steps.pip_install_requirements:
directory: {{ clone-step.directory }}
requirements_file: requirements.txt
stream_output: False
Use the run_shell_script
step to grab your repository's commit hash and use it to tag your Docker image:
build:
* prefect.projects.steps.run_shell_script:
id: get-commit-hash
script: git rev-parse --short HEAD
stream_output: false
* prefect.projects.steps.build_docker_image:
requires: prefect-docker
image_name: my-image
image_tag: "{{ get-commit-hash.stdout }}"
dockerfile: auto
See the release notes for more information.Chris Reuter
06/14/2023, 9:31 PMJenny
06/16/2023, 2:54 PMprefect cloud webhook create your-webhook-name \
--description "Receives webhooks from your system" \
--template '{ "event": "your.event.name", "resource": { "prefect.resource.id": "your.resource.id" } }'
For more information, see the release notes! πChris Reuter
06/19/2023, 8:44 PMChris Reuter
06/28/2023, 3:38 PMprefect init
!