nextflow

package
v0.47.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package nextflow contains reusable logic for working with Nextflow-based services:

  • parsing ivcap.yaml / ivcap-tool.yaml from a pipeline archive
  • generating the service description payload
  • upload resume metadata helpers
  • tar archive inspection helpers

It intentionally contains no Cobra / CLI printing. (Note: it may still write small progress/status messages via the provided zap.Logger, consistent with other pkg/* helpers.)

Index

Constants

View Source
const (
	ServiceSchema         = "urn:ivcap:schema.service.2"
	ServiceControllerURN  = "urn:ivcap:schema.service.nextflow.1"
	ServiceDefaultPolicy  = "urn:ivcap:policy:ivcap.open.service"
	ServiceMainScriptName = "main.nf"
)
View Source
const SimpleToolFileName = "ivcap.yaml"

Optional, simplified manifest. If present in the archive, this file is preferred over ivcap-tool.yaml and will be converted to the richer ivcap-tool structure internally.

View Source
const SimpleToolFileNameAlt = "ivcap.yml"
View Source
const ToolFileName = "ivcap-tool.yaml"
View Source
const UploadMetaPrefix = ".ivcap-nextflow-"

Variables

This section is empty.

Functions

func DeleteUploadMeta added in v0.47.5

func DeleteUploadMeta(archivePath string)

func DrainTar

func DrainTar(r io.Reader) ([]string, error)

DrainTar is a helper used in tests/debugging.

func ExtractFileFromTarBytes

func ExtractFileFromTarBytes(archive []byte, fileName string) ([]byte, string, error)

ExtractFileFromTarBytes extracts a file from a tar or tar.gz archive represented as bytes.

func ExtractFileFromTarPath

func ExtractFileFromTarPath(archivePath string, fileName string) (content []byte, foundPath string, err error)

func ExtractFileFromTarReader

func ExtractFileFromTarReader(tr *tar.Reader, targetName string) (content []byte, foundPath string, err error)

func ExtractFromTarAuto

func ExtractFromTarAuto(data []byte, innerPath string) ([]byte, string, error)

ExtractFromTarAuto extracts a file from tar or tar.gz bytes.

func GuessArchiveContentType

func GuessArchiveContentType(p string) string

func IsServiceURN added in v0.47.5

func IsServiceURN(id string) bool

IsServiceURN checks if a string is a valid IVCAP service URN. Valid format: urn:ivcap:service:<uuid>

func ReadUploadMeta

func ReadUploadMeta(archivePath string, size int64, mtimeUnix int64) (artifactID string, ok bool)

func ResolveServiceID added in v0.47.5

func ResolveServiceID(providedID string, tool *ToolHeader) (string, error)

ResolveServiceID resolves the service ID from either the provided ID or the tool header. If providedID is non-empty and is a valid service URN, it's used. Otherwise, the ServiceID from the tool header is used. Returns error if neither is available or if the resolved ID is not a valid service URN.

func SanitizeTarPath

func SanitizeTarPath(p string) (string, error)

SanitizeTarPath validates and normalizes a file path intended to be stored inside a tar archive.

It ensures a stable unix-style relative path, disallows traversal and volume names, and rejects empty/invalid names.

func TarGzFromSources

func TarGzFromSources(
	ctx context.Context,
	sources []Source,
	adpt *a.Adapter,
	logger *log.Logger,
	fetchURLBytes func(context.Context, string) ([]byte, string, error),
	downloadArtifactBytes func(context.Context, string, *a.Adapter) ([]byte, error),
) ([]byte, string, error)

TarGzFromSources assembles a tar.gz from the provided sources and also returns a compact JSON manifest string (suitable for storing in artifact meta).

`fetchURLBytes` and `downloadArtifactBytes` are injected to keep this package independent of cmd/* MCP helpers.

func UploadArchiveAsArtifact

func UploadArchiveAsArtifact(
	ctxt context.Context,
	toolName string,
	archivePath string,
	chunkSize int64,
	adapter *a.Adapter,
	silent bool,
	logger *log.Logger,
) (artifactID string, err error)

UploadArchiveAsArtifact uploads a local archive file as an IVCAP artifact and supports resuming interrupted uploads via local UploadMeta.

Notes:

  • archivePath must be a local path ("-" is not supported)
  • chunkSize should typically be cmd.DEF_CHUNK_SIZE

func UploadMetaPath

func UploadMetaPath(archivePath string) string

func UpsertServiceDescriptionAspect

func UpsertServiceDescriptionAspect(ctxt context.Context, entityServiceID string, svc *ServiceDescription, adapter *a.Adapter, logger *log.Logger) (aspectID string, err error)

UpsertServiceDescriptionAspect publishes a service description as a Data Fabric aspect.

Entity: service ID Schema: svc.Schema

func ValidateFnSchema

func ValidateFnSchema(m map[string]any) error

func WriteUploadMeta

func WriteUploadMeta(archivePath string, size int64, mtimeUnix int64, artifactID string)

Types

type CreateOutput

type CreateOutput struct {
	OK                    bool                `yaml:"ok" json:"ok"`
	ServiceID             string              `yaml:"service-id" json:"service-id"`
	PipelineArtifactURN   string              `yaml:"pipeline" json:"pipeline"`
	ServiceAspectRecordID string              `yaml:"service-aspect" json:"service-aspect"`
	ServiceDescription    *ServiceDescription `yaml:"service" json:"service"`
}

CreateOutput is a convenience struct for callers who want to return an object similar to `ivcap nextflow create`.

type ServiceDescription

type ServiceDescription struct {
	Schema           string `yaml:"$schema" json:"$schema"`
	ID               string `yaml:"$id" json:"$id"`
	Name             string `yaml:"name" json:"name"`
	Description      string `yaml:"description" json:"description"`
	RequestSchema    any    `yaml:"request-schema" json:"request-schema"`
	Contact          any    `yaml:"contact" json:"contact"`
	Policy           string `yaml:"policy" json:"policy"`
	ControllerSchema string `yaml:"controller-schema" json:"controller-schema"`
	Controller       any    `yaml:"controller" json:"controller"`
}

func BuildServiceDescription

func BuildServiceDescription(tool *ToolHeader, serviceID string, pipelineArtifactURN string) *ServiceDescription

type SimpleProperty

type SimpleProperty struct {
	Name        string `yaml:"name" json:"name"`
	Description string `yaml:"description" json:"description"`
	Type        string `yaml:"type" json:"type"`
	Format      string `yaml:"format" json:"format"`
	Optional    bool   `yaml:"optional" json:"optional"`
}

type SimpleToolHeader

type SimpleToolHeader struct {
	Schema      string `yaml:"$schema" json:"$schema"`
	ID          string `yaml:"id" json:"id"`
	Name        string `yaml:"name" json:"name"`
	ServiceID   string `yaml:"service-id" json:"service-id"`
	Description string `yaml:"description" json:"description"`
	Contact     *struct {
		Name  string `yaml:"name" json:"name"`
		Email string `yaml:"email" json:"email"`
	} `yaml:"contact" json:"contact"`
	Parameters []SimpleProperty `yaml:"parameters" json:"parameters"`
	Samples    []SimpleProperty `yaml:"samples" json:"samples"`
	Example    map[string]any   `yaml:"example" json:"example"`
}

type Source

type Source struct {
	// Path inside the assembled archive.
	Path string `json:"path"`
	// One of: text, base64, url, artifact
	Type string `json:"type"`
	// For text
	Text string `json:"text,omitempty"`
	// For base64
	Base64 string `json:"base64,omitempty"`
	// For url
	URL string `json:"url,omitempty"`
	// For artifact
	ArtifactID   string `json:"artifact_id,omitempty"`
	ArtifactPath string `json:"artifact_path,omitempty"`
	// Optional mime type for manifest.
	MediaType string `json:"media_type,omitempty"`
}

Source describes a file which should become a file at `Path` inside an assembled Nextflow pipeline tar.gz.

type ToolHeader

type ToolHeader struct {
	Schema      string `yaml:"$schema" json:"$schema"`
	ID          string `yaml:"id" json:"id"`
	Name        string `yaml:"name" json:"name"`
	ServiceID   string `yaml:"service-id" json:"service-id"`
	Description string `yaml:"description" json:"description"`
	Contact     *struct {
		Name  string `yaml:"name" json:"name"`
		Email string `yaml:"email" json:"email"`
	} `yaml:"contact" json:"contact"`
	FnSchema map[string]any `yaml:"fn-schema" json:"fn-schema"`
}

func ConvertSimpleToolToToolHeader

func ConvertSimpleToolToToolHeader(simple *SimpleToolHeader) (*ToolHeader, error)

func LoadToolHeaderFromArchiveBytes

func LoadToolHeaderFromArchiveBytes(archive []byte) (*ToolHeader, string, error)

LoadToolHeaderFromArchiveBytes reads ivcap.yaml or ivcap-tool.yaml from a tar/tar.gz archive provided as bytes.

Returns:

  • tool header (or nil if not found)
  • found path in archive

func LoadToolHeaderFromArchivePath

func LoadToolHeaderFromArchivePath(archivePath string) (*ToolHeader, string, error)

type UploadMeta

type UploadMeta struct {
	Size       int64
	MTimeUnix  int64
	ArtifactID string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL