def _action_(self, action: usage.UsageAction, input_opts: dict, output_opts: dict): action_f, action_sig = action.get_action() self._update_imports(action_f) t = self._template_action(action_f, input_opts, output_opts) self._recorder.append(t) return output_opts
def feature_table_merge_example(use): feature_table1 = use.init_data('feature_table1', ft1_factory) feature_table2 = use.init_data('feature_table2', ft2_factory) use.action( UsageAction(plugin_id='feature_table', action_id='merge'), UsageInputs(tables=[feature_table1, feature_table2]), UsageOutputNames(merged_table='merged_table'), )
def feature_table_merge_three_tables_example(use): feature_table1 = use.init_data('feature_table1', ft1_factory) feature_table2 = use.init_data('feature_table2', ft2_factory) feature_table3 = use.init_data('feature_table3', ft3_factory) use.action( UsageAction(plugin_id='feature_table', action_id='merge'), UsageInputs(tables=[feature_table1, feature_table2, feature_table3], overlap_method='sum'), UsageOutputNames(merged_table='merged_table'), )
def _action_(self, action: usage.UsageAction, input_opts: dict, output_opts: dict): action_f, action_sig = action.get_action() self._update_imports(action_f) new_output_opts = {k: k for k in output_opts.keys()} t = self._template_action(action_f, input_opts, new_output_opts) self._recorder.append(t) return new_output_opts
def test_get_action_if_plugin_present_plugin_missing(self): fake_action = UsageAction('imaginary', 'action') with self.assertRaisesRegex( MissingPluginError, "(?s)missing one or more plugins.*library"): _get_action_if_plugin_present(fake_action)
def test_get_action_if_plugin_present_plugin_present(self): real_action = UsageAction('diversity', 'core_metrics') action = _get_action_if_plugin_present(real_action) self.assertEqual('diversity', action.plugin_id) self.assertEqual('core_metrics', action.id)