prefect_fugue.context
FugueEngineContext
The context for Fugue ExecutionEngine.
Attributes:
Name | Type | Description |
---|---|---|
engines |
List[ExecutionEngine]
|
A stack of Fugue ExecutionEngines |
Source code in prefect_fugue/context.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
|
current_fugue_engine
Get the current Fugue ExecutionEngine created by the latest context manager
Returns:
Type | Description |
---|---|
Optional[ExecutionEngine]
|
ExecutionEngine, optional: if within a context, then the latest Fugue |
Optional[ExecutionEngine]
|
ExecutionEngine created by |
Source code in prefect_fugue/context.py
33 34 35 36 37 38 39 40 41 42 43 |
|
fugue_engine
Context manager to create a new Fugue Execution Engine.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
- |
engine (object
|
the object that can be converted to a
Fugue |
required |
- |
conf (object
|
the object that can be converted to a dict of Fugue configs. |
required |
- |
checkpoint (bool
|
for the steps using this engine, whether to enable checkpoint, defaults to False. |
required |
Yields:
Type | Description |
---|---|
ExecutionEngine
|
The current Fugue Execution Engine |
Examples:
from prefect import flow
from prefect_fugue import fugue_engine, fsql
@flow
def my_flow():
with fugue_engine("duckdb"):
res = fsql("CREATE [[0]] SCHEMA a:int YIELD DATAFRAME AS x")
fsql("PRINT x", res)
my_flow()
@flow
def flexible_flow(engine):
with fugue_engine(engine, {"some_config":"hello"}):
res = fsql("CREATE [[0]] SCHEMA a:int YIELD DATAFRAME AS x")
fsql("PRINT x", res)
flexible_flow("duckdb") # using DuckDB backend
flexible_flow("fugue/my_engine_conf") # using a FugueEngine block
Source code in prefect_fugue/context.py
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 |
|
get_current_checkpoint
Get the current checkpoint setting
Parameters:
Name | Type | Description | Default |
---|---|---|---|
- |
checkpoint (bool
|
get the checkpoint setting, defaults to None. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
if |
bool
|
a |
|
bool
|
current engine, else False. |
Source code in prefect_fugue/context.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
|