Operators
The Python CollectionComposer exposes the map, flat_map and filter operators. Each operator takes a step
name and a function, which can be a lambda, a function or a method.
from asgarde import CollectionComposerresult = (CollectionComposer.of(input_teams) .map('Map with country', lambda name: TeamInfo(name=name, country=team_countries[name], city='')) .map('Map with city', to_team_with_city))flat_map
Section titled “flat_map”The function returns an iterable:
result = (CollectionComposer.of(teams) .flat_map('To players', lambda team: team.players))filter
Section titled “filter”The function returns a boolean:
result = (CollectionComposer.of(teams_info) .filter('Filter french teams', lambda info: info.country == 'France'))Result
Section titled “Result”outputs: PCollection[TeamInfo] = result.outputs # Output of the last stepfailures: PCollection[Failure] = result.failures # Failures of all the stepsOnly Exception subclasses are caught: KeyboardInterrupt, SystemExit and MemoryError are raised to the
runner.
