Operation Output

class dffml.operation.output.Associate(parent: OperationImplementation, ctx: BaseInputSetContext, octx: BaseOrchestratorContext)[source]
imp

alias of AssociateImplementation

async run(inputs: Dict[str, Any]) Dict[str, Any][source]

Implementation of the operation goes here. Should take and return a dict with keys matching the input and output parameters of the Operation object associated with this operation implementation context.

class dffml.operation.output.AssociateDefinition(parent: OperationImplementation, ctx: BaseInputSetContext, octx: BaseOrchestratorContext)[source]

Examples

>>> import asyncio
>>> from dffml import *
>>>
>>> feed_def = Definition(name="feed", primitive="string")
>>> dead_def = Definition(name="dead", primitive="string")
>>> output = Definition(name="output", primitive="string")
>>>
>>> feed_input = Input(value="my favorite value", definition=feed_def)
>>> face_input = Input(
...     value="face", definition=output, parents=[feed_input]
... )
>>>
>>> dead_input = Input(
...     value="my second favorite value", definition=dead_def
... )
>>> beef_input = Input(
...     value="beef", definition=output, parents=[dead_input]
... )
>>>
>>> async def main():
...     for value in ["feed", "dead"]:
...         async for ctx, results in MemoryOrchestrator.run(
...             DataFlow.auto(AssociateDefinition),
...             [
...                 feed_input,
...                 face_input,
...                 dead_input,
...                 beef_input,
...                 Input(
...                     value={value: "output"},
...                     definition=AssociateDefinition.op.inputs["spec"],
...                 ),
...             ],
...         ):
...             print(results)
>>>
>>> asyncio.run(main())
{'feed': 'face'}
{'dead': 'beef'}
imp

alias of AssociateDefinitionImplementation

async run(inputs: Dict[str, Any]) Dict[str, Any][source]

Implementation of the operation goes here. Should take and return a dict with keys matching the input and output parameters of the Operation object associated with this operation implementation context.

class dffml.operation.output.GetMulti(parent: OperationImplementation, ctx: BaseInputSetContext, octx: BaseOrchestratorContext)[source]

Output operation to get all Inputs matching given definitions.

Parameters:

spec (list) – List of definition names. Any Inputs with matching definition will be returned.

Returns:

Maps definition names to all the Inputs of that definition

Return type:

dict

Examples

The following shows how to grab all Inputs with the URL definition. If we had we run an operation which output a URL, that output URL would have also been returned to us.

>>> import asyncio
>>> from dffml import *
>>>
>>> URL = Definition(name="URL", primitive="string")
>>>
>>> dataflow = DataFlow.auto(GetMulti)
>>> dataflow.seed.append(
...     Input(
...         value=[URL.name],
...         definition=GetMulti.op.inputs["spec"]
...     )
... )
>>>
>>> async def main():
...     async for ctx, results in MemoryOrchestrator.run(dataflow, [
...         Input(
...             value="https://github.com/intel/dffml",
...             definition=URL
...         ),
...         Input(
...             value="https://github.com/intel/cve-bin-tool",
...             definition=URL
...         )
...     ]):
...         print(results)
...
>>> asyncio.run(main())
{'URL': ['https://github.com/intel/dffml', 'https://github.com/intel/cve-bin-tool']}
imp

alias of GetMultiImplementation

async run(inputs: Dict[str, Any]) Dict[str, Any][source]

Implementation of the operation goes here. Should take and return a dict with keys matching the input and output parameters of the Operation object associated with this operation implementation context.

class dffml.operation.output.GetSingle(parent: OperationImplementation, ctx: BaseInputSetContext, octx: BaseOrchestratorContext)[source]

Output operation to get a single Input for each definition given.

Parameters:

spec (list) – List of definition names. An Input with matching definition will be returned.

Returns:

Maps definition names to an Input of that definition

Return type:

dict

Examples

The following shows how to grab an Inputs with the URL definition. If we had we run an operation which output a URL, that output URL could have also been returned to us.

>>> import asyncio
>>> from dffml import *
>>>
>>> URL = Definition(name="URL", primitive="string")
>>> ORG = Definition(name="ORG", primitive="string")
>>>
>>> dataflow = DataFlow.auto(GetSingle)
>>> dataflow.seed.append(
...     Input(
...         value=[{"Repo Link": URL.name}, ORG.name],
...         definition=GetSingle.op.inputs["spec"]
...     )
... )
>>>
>>> async def main():
...     async for ctx, results in MemoryOrchestrator.run(dataflow, [
...         Input(
...             value="https://github.com/intel/dffml",
...             definition=URL
...         ),
...         Input(
...             value="Intel",
...             definition=ORG
...         )
...     ]):
...         print(results)
...
>>> asyncio.run(main())
{'ORG': 'Intel', 'Repo Link': 'https://github.com/intel/dffml'}
imp

alias of GetSingleImplementation

async run(inputs: Dict[str, Any]) Dict[str, Any][source]

Implementation of the operation goes here. Should take and return a dict with keys matching the input and output parameters of the Operation object associated with this operation implementation context.

class dffml.operation.output.GroupBy(parent: OperationImplementation, ctx: BaseInputSetContext, octx: BaseOrchestratorContext)[source]
imp

alias of GroupByImplementation

async run(inputs: Dict[str, Any]) Dict[str, Any][source]

Implementation of the operation goes here. Should take and return a dict with keys matching the input and output parameters of the Operation object associated with this operation implementation context.

class dffml.operation.output.GroupBySpec(group, by)[source]
property by

Alias for field number 1

property group

Alias for field number 0

class dffml.operation.output.RemapConfig(dataflow)[source]
property dataflow

Alias for field number 0

exception dffml.operation.output.RemapFailure[source]

Raised whem results of a dataflow could not be remapped.