Skip to content

Commit

Permalink
Merge upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
jlowin committed Apr 29, 2024
2 parents 0a58633 + 2ea0fcb commit ba2a11d
Show file tree
Hide file tree
Showing 2 changed files with 187 additions and 7 deletions.
15 changes: 9 additions & 6 deletions src/prefect/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ def my_other_flow(name):
@sync_compatible
async def serve(
self,
name: str,
name: Optional[str] = None,
interval: Optional[
Union[
Iterable[Union[int, float, datetime.timedelta]],
Expand Down Expand Up @@ -764,7 +764,7 @@ async def serve(
Creates a deployment for this flow and starts a runner to monitor for scheduled work.
Args:
name: The name to give the created deployment.
name: The name to give the created deployment. Defaults to the name of the flow.
interval: An interval on which to execute the deployment. Accepts a number or a
timedelta object to create a single schedule. If a number is given, it will be
interpreted as seconds. Also accepts an iterable of numbers or timedelta to create
Expand Down Expand Up @@ -827,10 +827,13 @@ def my_flow(name):
"""
from prefect.runner import Runner

# Handling for my_flow.serve(__file__)
# Will set name to name of file where my_flow.serve() without the extension
# Non filepath strings will pass through unchanged
name = Path(name).stem
if not name:
name = self.name
else:
# Handling for my_flow.serve(__file__)
# Will set name to name of file where my_flow.serve() without the extension
# Non filepath strings will pass through unchanged
name = Path(name).stem

runner = Runner(name=name, pause_on_shutdown=pause_on_shutdown, limit=limit)
deployment_id = await runner.add_flow(
Expand Down

0 comments on commit ba2a11d

Please sign in to comment.