-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathartifacts.py
More file actions
155 lines (125 loc) · 4.56 KB
/
artifacts.py
File metadata and controls
155 lines (125 loc) · 4.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
from prefect import flow, task
from prefect.artifacts import create_markdown_artifact, create_link_artifact, create_table_artifact
@task
def my_first_link_task():
create_link_artifact(
key="variable-data-link",
link="https://nyc3.digitaloceanspaces.com/my-bucket-name/highly_variable_data_.csv",
description="## Highly variable data",
link_text="Highly variable data",
)
@task
def my_second_link_task():
create_link_artifact(
key="variable-data-link",
link="https://nyc3.digitaloceanspaces.com/my-bucket-name/low_pred_data_.csv",
description="# Low prediction accuracy data",
)
@task
def my_table_task():
highest_churn_possibility = [
{'customer_id':'12345', 'name': 'John Smith', 'churn_probability': 0.85 },
{'customer_id':'56789', 'name': 'Jane Jones', 'churn_probability': 0.65 }
]
create_table_artifact(
key="personalized-reachout",
table=highest_churn_possibility,
description= "# Marvin, please reach out to these customers today!"
)
@task
def markdown_task():
na_revenue = 500000
markdown_report = f"""# Sales Report
## Summary
In the past quarter, our company saw a significant increase in sales, with a total revenue of $1,000,000. This represents a 20% increase over the same period last year.
## Sales by Region
| Region | Revenue |
|:--------------|-------:|
| North America | ${na_revenue:,} |
| Europe | $250,000 |
| Asia | $150,000 |
| South America | $75,000 |
| Africa | $25,000 |
## Top Products
1. Product A - $300,000 in revenue
2. Product B - $200,000 in revenue
3. Product C - $150,000 in revenue
## Conclusion
Overall, these results are very encouraging and demonstrate the success of our sales team in increasing revenue across all regions. However, we still have room for improvement and should focus on further increasing sales in the coming quarter.
"""
create_markdown_artifact(
key="gtm-markdown-report",
markdown=markdown_report,
description="Quarterly Sales Report",
)
@flow()
def artifacts_flow():
'''Flow that creates markdown, link and table artifacts
## Flow code
```python
from prefect import flow, task
from prefect.artifacts import create_markdown_artifact, create_link_artifact, create_table_artifact
@task
def my_first_link_task():
create_link_artifact(
key="variable-data-link",
link="https://nyc3.digitaloceanspaces.com/my-bucket-name/highly_variable_data_.csv",
description="## Highly variable data",
link_text="Highly variable data",
)
@task
def my_second_link_task():
create_link_artifact(
key="variable-data-link",
link="https://nyc3.digitaloceanspaces.com/my-bucket-name/low_pred_data_.csv",
description="# Low prediction accuracy data",
)
@task
def my_table_task():
highest_churn_possibility = [
{'customer_id':'12345', 'name': 'John Smith', 'churn_probability': 0.85 },
{'customer_id':'56789', 'name': 'Jane Jones', 'churn_probability': 0.65 }
]
create_table_artifact(
key="personalized-reachout",
table=highest_churn_possibility,
description= "# Marvin, please reach out to these customers today!"
)
@task
def markdown_task():
na_revenue = 500000
markdown_report = f"""# Sales Report
## Summary
In the past quarter, our company saw a significant increase in sales, with a total revenue of $1,000,000. This represents a 20% increase over the same period last year.
## Sales by Region
| Region | Revenue |
|:--------------|-------:|
| North America | ${na_revenue:,} |
| Europe | $250,000 |
| Asia | $150,000 |
| South America | $75,000 |
| Africa | $25,000 |
## Top Products
1. Product A - $300,000 in revenue
2. Product B - $200,000 in revenue
3. Product C - $150,000 in revenue
## Conclusion
Overall, these results are very encouraging and demonstrate the success of our sales team in increasing revenue across all regions. However, we still have room for improvement and should focus on further increasing sales in the coming quarter.
"""
create_markdown_artifact(
key="gtm-markdown-report",
markdown=markdown_report,
description="Quarterly Sales Report",
)
@flow()
def artifacts_flow():
markdown_task()
my_first_link_task()
my_second_link_task()
my_table_task()
```
'''
markdown_task()
my_first_link_task()
my_second_link_task()
my_table_task()