This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dask import delayed | |
# won't be evaluated until we call .compute() | |
fast_predict_over_time = delayed(fast_predict_over_time) | |
## using the same numpy arrays from above... | |
%%timeit -n 100 | |
_ = fast_predict_over_time(x, y, z, False, res).compute() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@delayed | |
def predict_another_thing(x, y, z): | |
# model scoring code goes here | |
pass | |
@delayed | |
def complicated_feature_b(x, y): | |
# lets imagine this feature is *very* expensive to create | |
# and takes a full minute to process |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%timeit -n 100 | |
_, _ = dask.compute(results['w_overlay'], | |
results['predict_another_thing']) | |
# 100 loops, best of 3: 1.61 ms per loop |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
from google.cloud.firestore import Client | |
import os | |
import random | |
import requests | |
def get_standup_date(): | |
""" | |
Returns the current date, formatted, which maps |
- import os
...
+ import prefect
+ from prefect import Flow, Parameter, task
+ from prefect.client import Secret
+ from prefect.schedules import CronSchedule
+ @task
def get_standup_date():
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from prefect.environments import DockerEnvironment | |
env = DockerEnvironment( | |
base_image="python:3.6", | |
registry_url="XXXXXXXX", | |
python_dependencies=["google-cloud-firestore"], | |
files={"~/google-creds.json": "/root/google-creds.json"}, | |
env_vars={"GOOGLE_APPLICATION_CREDENTIALS": "/root/google-creds.json"}, | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@task | |
def get_collection_name(): | |
""" | |
Returns the current date, formatted, which maps | |
to a Google Firestore collection name. | |
""" | |
date_format = "%Y-%m-%d" | |
now = prefect.context["scheduled_start_time"] | |
return now.strftime(date_format) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
reminder_flag = is_reminder_needed.map(get_team, unmapped(updates)) | |
res = send_reminder.map(reminder_flag) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
from google.cloud.firestore import Client | |
import random | |
import requests | |
import prefect | |
from prefect import Flow, Parameter, task | |
from prefect.client import Secret | |
from prefect.schedules import CronSchedule |