Overview¶
The brain of the Orbiter framework is in it's Rules
and the Rulesets that contain them.
- A
Ruleis a python function that is evaluated and produces something (typically an Object) or nothing - A
Rulesetis a collection ofRulesthat are evaluated in priority order - A
TranslationRulesetis a collection ofRulesets, relating to an Origin andFileType, with atranslate_fnwhich determines how to apply the rulesets.
Different Rules are applied in different scenarios, such as:
- converting input to an Airflow DAG (
@dag_rule), - converting input to a specific Airflow Operator (
@task_rule), - filtering entries from the input data
(
@dag_filter_rule,@task_filter_rule).
Tip
To map the following input
to an Airflow
BashOperator,
a Rule could parse it as follows:
@task_rule
def my_rule(val):
if 'command' in val:
return OrbiterBashOperator(task_id=val['id'], bash_command=val['command'])
else:
return None
This returns a
OrbiterBashOperator, which will become an Airflow
BashOperator
when the translation completes.
orbiter.default_translation.translate ¶
translate(
translation_ruleset, input_dir: Path
) -> OrbiterProject
Orbiter expects a folder containing text files which may have a structure like:
However, the files may be in any format, and the structure may be different.The standard translation function performs the following steps:

- Find all files with the expected
TranslationRuleset.file_type(.json,.xml,.yaml, etc.) in the input folder.- Load each file and turn it into a Python Dictionary.
- For each file: Apply the
TranslationRuleset.dag_filter_rulesetto filter down to entries that can translate to a DAG, in priority order. The file name is added under a__filekey to both input and output dictionaries for the DAG Filter rule.- For each dictionary: Apply the
TranslationRuleset.dag_ruleset, to convert the object to anOrbiterDAG, in priority-order, stopping when the first rule returns a match. If no rule returns a match, the entry is filtered.
- For each dictionary: Apply the
- Apply the
TranslationRuleset.task_filter_rulesetto filter down to entries in the DAG that can translate to a Task, in priority-order.- For each: Apply the
TranslationRuleset.task_ruleset, to convert the object to a specific Task, in priority-order, stopping when the first rule returns a match. If no rule returns a match, the entry is filtered.
- For each: Apply the
- After the DAG and Tasks are mapped, the
TranslationRuleset.task_dependency_rulesetis applied in priority-order, stopping when the first rule returns a match, to create a list ofOrbiterTaskDependency, which are then added to each task in theOrbiterDAG - Apply the
TranslationRuleset.post_processing_ruleset, against theOrbiterProject, which can make modifications after all other rules have been applied. - After translation - the
OrbiterProjectis rendered to the output folder.
Source code in orbiter/default_translation.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 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |