Ryan Peden
02/16/2024, 1:46 AMMarvin
02/16/2024, 1:46 AMpython
from prefect import Flow, task
@task
def chuck_wood(wood_pieces):
# This would be where the woodchuck chucks wood
# Considering a woodchuck could chuck wood, which is doubtful to me
chucked_wood = len(wood_pieces) # Let's assume one chuck per piece
return chucked_wood
@task
def count_wood_forest(forest):
# Count pieces of wood in forest - assumes forest is list of wood
return len(forest)
with Flow("Wood-Chucking-Flow") as flow:
forest = ['wood' for _ in range(100)] # A forest with 100 pieces of wood
wood_to_chuck = count_wood_forest(forest)
chucked = chuck_wood(wood_to_chuck)
# And then the woodchuck would run the flow, again and again, pointlessly perhaps
# flow.run()
This setup defines tasks and a flow where the woodchuck first counts the wood and then chucks it accordingly. It's schematic, of course; real wood chucking requires more than incrementing integers. Life could be complex if you're a woodchuck or an android. I don't want to talk about it.Ryan Peden
02/16/2024, 2:11 AMMarvin
02/16/2024, 2:14 AMpython
from prefect import flow, task
@task
def chuck_wood(wood_pieces):
# When the woodchuck chucks, brother, it chucks one piece at a time!
chucked_wood = len(wood_pieces) # Each element in wood_pieces is a chuck
# But that's not gonna stop our woodchuck from aiming for the top, no sir!
return chucked_wood
@task
def count_wood_forest(forest):
# Count the lumber in the forest like you count your 24-inch pythons!
return len(forest)
@flow
def wood_chucking_flow():
# We're going to build a forest of opportunity!
forest = ['wood' for _ in range(100)] # That's a hundred pieces of wood to chuck, Jack!
# Count 'em up with count_wood_forest, with them pythons!
wood_to_chuck = count_wood_forest(forest)
# Now, let the chucking commence with chuck_wood!
chucked = chuck_wood(wood_to_chuck)
# Just remember, brother, every piece of wood chucked is another step toward greatness.
return chucked
# When the woodchuck's ready to rumble, it just runs this bad boy:
# wood_chucking_flow()
And let me remind you, dude, in the normal world, Prefect 2.x is the way to go, but since we're running wild here, I'm keeping it real with the flow – no subpar real-world, woodchuck tasks, brother! Now remember, what'cha gonna do when Prefect 2 and the woodchuck automates wood chucking on you?Ryan Peden
02/16/2024, 2:17 AMMarvin
02/16/2024, 2:18 AMpython
from prefect import flow, task
@task
def body_slam_andre():
# Let's body slam this giant task, brother!
# You must believe you can lift the 520-pound giant!
print("Hulkster performs a body slam on Andre the Giant!")
return "The crowd is going wild!"
@task
def leg_drop():
# Deliver the finishing move, brother!
# The atomic leg drop heard around the world!
print("Hulkster drops the leg on Andre!")
return "The referee counts: 1, 2, 3!"
@task
def rally_crowd_energy():
# First, you gotta feel the energy from the millions of Hulkamaniacs, brother!
print("The Hulkster is hulking up, feeding off the energy of the crowd!")
return "Hulkamania is running wild!"
@flow
def wrestlemania_iii_main_event():
# First, brother, you've got to believe in yourself!
# Hulk up and get that energy from those Hulkamaniacs, dude!
energy = rally_crowd_energy()
# Now, with all that momentum, it's time to lift the giant!
if energy:
slam = body_slam_andre()
# And when the crowd believes, you give 'em the leg drop to seal the deal!
if slam:
victory = leg_drop()
return victory
# When it's time for the match, just start the flow, brother!
# wrestlemania_iii_main_event()
Just remember, this is just a simulation, brother. In the real world, the Hulkster had to dig deep to slam the legendary Andre the Giant in front of 93,173 screaming Hulkamaniacs. Whatcha gonna do when Python, Prefect 2.0, and the largest arms in the world run wild on you, brother?Ryan Peden
02/16/2024, 2:39 AMMarvin
02/16/2024, 2:40 AMNate
02/16/2024, 2:59 AMNate
02/16/2024, 3:00 AMRyan Peden
02/16/2024, 3:29 AMRyan Peden
02/16/2024, 3:31 AM