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
export PREFECT__ENGINE__EXECUTOR__DEFAULT_CLASS="prefect.engine.executors.DaskExecutor" | |
export PREFECT__ENGINE__EXECUTOR__DASK__ADDRESS="tcp://10.0.0.41:8786" |
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
dask-scheduler | |
# Scheduler at: tcp://10.0.0.41:8786 | |
# in different terminal windows | |
dask-worker tcp://10.0.0.41:8786 | |
dask-worker tcp://10.0.0.41:8786 |
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 import task, Parameter, Flow | |
@task | |
def return_param(p): | |
return p | |
with Flow("parameter-example") as flow: | |
p = Parameter("p", default=42) |
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
def puller(**kwargs): | |
ti = kwargs['ti'] | |
# get value_1 | |
v1 = ti.xcom_pull(key=None, task_ids='push') |
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
# run your first Prefect flow from the command line | |
python -c "from prefect import Flow; f = Flow('empty'); f.run()" |
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
airflow test tutorial print_date 2015–06–01 | |
## Output | |
AIRFLOW_CTX_EXECUTION_DATE=2015–06–01T00:00:00+00:00 | |
[2019–04–17 15:54:45,679] {bash_operator.py:110} INFO - Running command: date | |
[2019–04–17 15:54:45,685] {bash_operator.py:119} INFO - Output: | |
[2019–04–17 15:54:45,695] {bash_operator.py:123} INFO - Wed Apr 17 15:54:45 PDT 2019 |
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 import task, Flow | |
@task | |
def create_list(): | |
return [1, 1, 2, 3] | |
@task | |
def add_one(x): | |
return x + 1 |
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.tasks.database.sqlite import SQLiteScript | |
create_script = "CREATE TABLE IF NOT EXISTS SSHATTEMPTS (timestamp TEXT, username TEXT, port INTEGER, city TEXT, country TEXT, latitude REAL, longitude REAL)" | |
create_table = SQLiteScript( | |
db="ssh.db", script=create_script, name="Create Database and Table" | |
) |
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 json | |
import os | |
import urllib.parse | |
import urllib.request | |
print("Loading function") | |
def lambda_handler(event, context): |
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
# if you wish to pass information about the triggering event as a parameter, | |
# simply add that to the inputs dictionary under the parameters key, | |
# whose value should be a dictionary of PARAMETER_NAME -> PARAMETER_VALUE | |
# pass the full event | |
inputs['parameters'] = dict(event=event) | |
# or just the bucket name | |
inputs['parameters'] = dict(bucket_name=event['Records'][0]['s3']['bucket']['name']) |