tugboat.hookspecs package

tugboat.hookspecs manages the hook specifications for Tugboat. It is used to define the hooks that can be implemented by plugins.

The hooks are defined as functions with specific signatures. Tugboat calls these hooks during the linting process.

The Tugboat framework heavily relies on pluggy for hook management. For details on how to implement hooks, please refer to the pluggy’s documentation.

tugboat.hookspecs.core module

This module defines the core hook specifications for Tugboat.

These hooks are used to extend the core functionality of Tugboat. Since the standard Argo Workflows manifest formats are built-in, users may not need to implement these hooks. However, these hooks are available for users who want to extend Tugboat to support custom manifest formats or provide custom diagnoses.

tugboat.hookspecs.core.analyze(manifest: Manifest) Iterable[Diagnosis]

Analyze the manifest and provide diagnoses.

This is the primary hook invoked during the linting process. The handler should examine the manifest and return a list of diagnoses.

For Argo Workflows manifests, you can implement the hooks in the tugboat.hookspecs.workflow module. These hooks are wrapped by tugboat’s built-in handlers, reducing the need to manage the workflow structure.

Parameters:

manifest (Manifest) – The manifest to analyze.

Returns:

The diagnoses reported by the handler.

Return type:

Iterable[Diagnosis]

tugboat.hookspecs.core.parse_manifest(manifest: dict) Manifest | None

Convert a raw manifest into a tugboat.schemas.Manifest instance if the format is recognized by the handler. Returns None if the format is not recognized.

During this hook, the framework captures the pydantic_core.ValidationError raised when parsing the manifest and converts it into a diagnosis. This allows the handler to focus on the manifest structure and content, and leave the validation to Pydantic and the framework.

Parameters:

manifest (dict) – The manifest to parse.

Returns:

The parsed Manifest object if the format is recognized, otherwise None.

Return type:

Manifest

tugboat.hookspecs.workflow module

This module defines the hook specifications for Argo’s workflow and workflow template analysis.

tugboat.hookspecs.workflow.analyze_step(step: Step, template: Template, workflow: Workflow | WorkflowTemplate) Iterable[Diagnosis]

Analyze a workflow step.

For issues reported by this hook, the loc attribute of the diagnosis should start from the step object itself. The framework will manage the outer structure and its location path.

Parameters:
  • step (Step) – The step to analyze.

  • template (Template) – The template that the step is part of.

  • workflow (Workflow | WorkflowTemplate) – The workflow that the template is part of.

tugboat.hookspecs.workflow.analyze_template(template: Template, workflow: Workflow | WorkflowTemplate) Iterable[Diagnosis]

Analyze a template.

This hook is called for each template in a workflow or workflow template, but not including the templateDefaults.

For issues reported by this hook, the loc attribute of the diagnosis should start from the template object itself. The framework will manage the outer structure and its location path.

Parameters:
tugboat.hookspecs.workflow.analyze_workflow(workflow: Workflow) Iterable[Diagnosis]

Analyze a workflow.

Parameters:

workflow (Workflow) – The workflow to analyze.

tugboat.hookspecs.workflow.analyze_workflow_template(workflow_template: WorkflowTemplate) Iterable[Diagnosis]

Analyze a workflow template.

Parameters:

workflow_template (WorkflowTemplate) – The workflow template to analyze.