def inspect(wf_spec, st2_ctx, raise_exception=True): # Inspect workflow definition. result = wf_spec.inspect(app_ctx=st2_ctx, raise_exception=False) errors = format_inspection_result(result) # Inspect st2 specific contents. errors += inspect_task_contents(wf_spec) # Sort the list of errors by type and path. errors = sorted(errors, key=lambda e: (e['type'], e['schema_path'])) if errors and raise_exception: raise orquesta_exc.WorkflowInspectionError(errors) return errors
def inspect(self, app_ctx=None, raise_exception=False): if app_ctx and not isinstance(app_ctx, dict): raise TypeError('Application context is not type of dict.') errors = {} app_ctx_metadata = None def sort_errors(e): return (e['schema_path'], e['spec_path']) syntax_errors = sorted(self.inspect_syntax(), key=sort_errors) if syntax_errors: errors['syntax'] = syntax_errors semantic_errors = sorted(self.inspect_semantics(), key=sort_errors) if semantic_errors: errors['semantics'] = semantic_errors expr_errors = sorted(self.inspect_expressions(), key=sort_errors) if expr_errors: errors['expressions'] = expr_errors if app_ctx: app_ctx_metadata = { 'ctx': app_ctx.keys(), 'spec_path': '.', 'schema_path': '.' } ctx_errors, _ = self.inspect_context(parent=app_ctx_metadata) ctx_errors = sorted(ctx_errors, key=sort_errors) if ctx_errors: errors['context'] = ctx_errors if errors and raise_exception: raise exc.WorkflowInspectionError(errors) return errors
def inspect(self, app_ctx=None, raise_exception=False): if app_ctx and not isinstance(app_ctx, dict): raise TypeError("Application context is not type of dict.") errors = {} app_ctx_metadata = None def sort_errors(e): return (e["schema_path"], e["spec_path"]) syntax_errors = sorted(self.inspect_syntax(), key=sort_errors) if syntax_errors: errors["syntax"] = syntax_errors semantic_errors = sorted(self.inspect_semantics(), key=sort_errors) if semantic_errors: errors["semantics"] = semantic_errors expr_errors = sorted(self.inspect_expressions(), key=sort_errors) if expr_errors: errors["expressions"] = expr_errors if app_ctx: app_ctx_metadata = { "ctx": app_ctx.keys(), "spec_path": ".", "schema_path": "." } ctx_errors, _ = self.inspect_context(parent=app_ctx_metadata) ctx_errors = sorted(ctx_errors, key=sort_errors) if ctx_errors: errors["context"] = ctx_errors if errors and raise_exception: raise exc.WorkflowInspectionError(errors) return errors