fugue.extensions.outputter

fugue.extensions.outputter.convert

fugue.extensions.outputter.convert.outputter(**validation_rules)[source]

Decorator for outputters

Please read Outputter Tutorial

Parameters:

validation_rules (Any) –

Return type:

Callable[[Any], _FuncAsOutputter]

fugue.extensions.outputter.convert.register_outputter(alias, obj, on_dup=0)[source]

Register outputter with an alias.

Parameters:
Return type:

None

Tip

Registering an extension with an alias is particularly useful for projects such as libraries. This is because by using alias, users don’t have to import the specific extension, or provide the full path of the extension. It can make user’s code less dependent and easy to understand.

New Since

0.6.0

See also

Please read Outputter Tutorial

Examples

Here is an example how you setup your project so your users can benefit from this feature. Assume your project name is pn

The processor implementation in file pn/pn/outputters.py

from fugue import DataFrame

def my_outputter(df:DataFrame) -> None:
    print(df)

Then in pn/pn/__init__.py

from .outputters import my_outputter
from fugue import register_outputter

def register_extensions():
    register_outputter("mo", my_outputter)
    # ... register more extensions

register_extensions()

In users code:

import pn  # register_extensions will be called
from fugue import FugueWorkflow

dag = FugueWorkflow()
# use my_outputter by alias
dag.df([[0]],"a:int").output("mo")
dag.run()

fugue.extensions.outputter.outputter

class fugue.extensions.outputter.outputter.Outputter[source]

Bases: ExtensionContext, ABC

The interface to process one or multiple incoming dataframes without returning anything. For example printing or saving dataframes should be a type of Outputter. Outputter is task level extension, running on driver, and execution engine aware.

To implement this class, you should not have __init__, please directly implement the interface functions.

Note

Before implementing this class, do you really need to implement this interface? Do you know the interfaceless feature of Fugue? Implementing Outputter is commonly unnecessary. You can choose the interfaceless approach which may decouple your code from Fugue.

See also

Please read Outputter Tutorial

abstract process(dfs)[source]

Process the collection of dataframes on driver side

Note

  • It runs on driver side

  • The dataframes are not necessarily local, for example a SparkDataFrame

  • It is engine aware, you can put platform dependent code in it (for example native pyspark code) but by doing so your code may not be portable. If you only use the functions of the general ExecutionEngine, it’s still portable.

Parameters:

dfs (DataFrames) – dataframe collection to process

Return type:

None