def run_filter(filter_class, data=None, ordered_dict=None): """ Creates just a single filter artifact with enough metadata to be able to run a filter. """ with temprun() as runner: artifact = FilterArtifact("key.txt") artifact.input_data = dexy.data.Json("%s" % random.randint(10000,99999), ".txt", runner) artifact.output_data = dexy.data.Json("%s" % random.randint(10000,99999), ".txt", runner) if ordered_dict: artifact.input_data._ordered_dict = ordered_dict elif data: artifact.input_data._data = data else: raise Exception("Must supply either data or ordered_dict") f = filter_class() f.artifact = artifact f.process() yield artifact.output_data
def run_filter(filter_class, data=None, ordered_dict=None): """ Creates just a single filter artifact with enough metadata to be able to run a filter. """ with temprun() as runner: artifact = FilterArtifact("key.txt") artifact.input_data = dexy.data.Json( "%s" % random.randint(10000, 99999), ".txt", runner) artifact.output_data = dexy.data.Json( "%s" % random.randint(10000, 99999), ".txt", runner) if ordered_dict: artifact.input_data._ordered_dict = ordered_dict elif data: artifact.input_data._data = data else: raise Exception("Must supply either data or ordered_dict") f = filter_class() f.artifact = artifact f.process() yield artifact.output_data
def setup_filter_artifact(self, key, filters): artifact = FilterArtifact(key, runner=self.runner) artifact.args = self.args artifact.doc = self artifact.filter_alias = filters[-1] artifact.doc_filepath = self.name artifact.prior = self.artifacts[-1] artifact.created_by_doc = self.created_by_doc try: artifact.filter_class = self.filter_class_for_alias(filters[-1]) except BlankAlias: raise UserFeedback("You have a trailing | or you have 2 | symbols together in your specification for %s" % self.key) if not artifact.filter_class.is_active(): raise InactiveFilter artifact.next_filter_alias = None artifact.next_filter_class = None artifact.next_filter_name = None if len(filters) < len(self.filters): next_filter_alias = self.filters[len(filters)] artifact.next_filter_alias = next_filter_alias artifact.next_filter_class = self.filter_class_for_alias(next_filter_alias) artifact.next_filter_name = artifact.next_filter_class.__name__ self.children.append(artifact) self.artifacts.append(artifact) self.final_artifact = artifact self.metadata = artifact.metadata
def setup_filter_artifact(self, key, filters): artifact = FilterArtifact(key, runner=self.runner) artifact.args = self.args artifact.doc = self artifact.filter_alias = filters[-1] artifact.doc_filepath = self.name artifact.prior = self.artifacts[-1] artifact.created_by_doc = self.created_by_doc try: artifact.filter_class = self.filter_class_for_alias(filters[-1]) except BlankAlias: raise UserFeedback( "You have a trailing | or you have 2 | symbols together in your specification for %s" % self.key) if not artifact.filter_class.is_active(): raise InactiveFilter artifact.next_filter_alias = None artifact.next_filter_class = None artifact.next_filter_name = None if len(filters) < len(self.filters): next_filter_alias = self.filters[len(filters)] artifact.next_filter_alias = next_filter_alias artifact.next_filter_class = self.filter_class_for_alias( next_filter_alias) artifact.next_filter_name = artifact.next_filter_class.__name__ self.children.append(artifact) self.artifacts.append(artifact) self.final_artifact = artifact self.metadata = artifact.metadata