Skip to content

Commit 2079c19

Browse files
committed
Refactor deployment function; enhance deployment logic and update command-line interface
1 parent a6e752f commit 2079c19

1 file changed

Lines changed: 42 additions & 6 deletions

File tree

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,54 @@
11
"""
2-
Prefect flow for desk lifter control.
2+
Prefect flow deployment for desk lifter control.
33
4-
Simple flow execution - just call the decorated function directly.
4+
Imports the Prefect-decorated move_to_height flow from desk_controller and provides deployment utilities.
55
"""
66

77
from progressive_automations_python.desk_controller import move_to_height
88

9+
10+
# =============================================================================
11+
# DEPLOYMENT FUNCTION
12+
# =============================================================================
13+
14+
def deploy_move_desk_flow(deployment_name: str = "move-desk"):
15+
"""Deploy the move desk flow for Prefect Cloud execution.
16+
17+
Args:
18+
deployment_name: Name for the deployment in Prefect Cloud
19+
20+
Returns:
21+
str: The deployment name for reference
22+
"""
23+
24+
# Create deployment using the correct API
25+
deployment = move_to_height.to_deployment(
26+
name=deployment_name,
27+
work_pool_name="desk-lifter-pool"
28+
)
29+
30+
# Deploy it
31+
deployment_id = deployment.apply()
32+
33+
print(f"✅ Deployment '{deployment_name}' created with ID: {deployment_id}")
34+
print(f"Work pool: desk-lifter-pool")
35+
print(f"To run: prefect deployment run 'move-to-height/{deployment_name}' --param target_height=30")
36+
print(f"Parameter: target_height (float, in inches)")
37+
38+
return deployment_name
39+
40+
941
if __name__ == "__main__":
1042
import argparse
1143

1244
parser = argparse.ArgumentParser()
13-
parser.add_argument("--target-height", type=float, required=True, help="Target height in inches")
45+
parser.add_argument("--deploy", action="store_true", help="Create deployment")
1446
args = parser.parse_args()
1547

16-
print(f"Running Prefect flow: move_to_height({args.target_height})")
17-
result = move_to_height(args.target_height)
18-
print(f"Flow result: {result}")
48+
if args.deploy:
49+
deploy_move_desk_flow()
50+
else:
51+
# Default: just test the flow directly
52+
print("Testing flow directly with target height 30...")
53+
result = move_to_height(30.0)
54+
print(f"Result: {result}")

0 commit comments

Comments
 (0)