flowserv.model.workflow.manifest module

Helper functions to read workflow manifest files.

flowserv.model.workflow.manifest.MANIFEST_FILES = ['flowserv.json', 'flowserv.yaml', 'flowserv.yml']

Regular expression for file includes in markdown.

class flowserv.model.workflow.manifest.WorkflowManifest(basedir, name, workflow_spec, description=None, instructions=None, files=None)

Bases: object

The workflow manifest contains the workflow specification, the workflow metadata (name, description and optional instructions), as well as the list of files that need to be copied when creating a local copy of a workflow template in a repository.

copyfiles(dst: str) List[Tuple[str, str]]

Get list of all template files from the base folder that need to be copied to the template folder of a workflow repository.

The result is a list of tuples specifying the relative file source and target path. The target path for each file is a concatenation of the given destination base directory and the specified target path for the file or folder. If the list of files is undefined in the manifest, the result is a tuple (None, dst) indicating that the full base directory is to be copied to the destination.

Return type

list of (string, string)

static load(basedir, manifestfile=None, name=None, description=None, instructions=None, specfile=None, existing_names={})

Read the workflow manifest from file. By default, an attempt is made to read a file with one the following names in the basedir (in the given order): flowserv.json, flowserv.yaml, flowserv.yml. If the manifest file parameter is given the specified file is being read instead.

The parameters name, description, instructions, and specfile are used to override the respective properties in the manifest file.

Raises a ValueError if no manifest file is found or if no name or workflow specification is present in the resulting manifest object.

Parameters
  • basedir (string) – Path to the base directory containing the workflow files. This directory is used when reading the manifest file (if not given as argument) and the instructions file (if not given as argument).

  • manifestfile (string, default=None) – Path to manifest file. If not given an attempt is made to read one of the default manifest file names in the base directory.

  • name (string) – Unique workflow name

  • description (string) – Optional short description for display in workflow listings

  • instructions (string) – File containing instructions for workflow users.

  • specfile (string) – Path to the workflow template specification file (absolute or relative to the workflow directory)

  • existing_names (set, default=set()) – Set of names for existing projects.

Return type

flowserv.model.workflow.manifest.WorkflowManifest

Raises

IOError, OSError, ValueError, flowserv.error.InvalidManifestError

template()

Get workflow template instance for the workflow specification that is included in the manifest.

Return type

flowserv.model.template.base.Workflowtemplate

flowserv.model.workflow.manifest.getfile(basedir, manifest_value, user_argument)

Get name for a file that is referenced in a workflow manifest. If the user argument is given it overrides the respective value in the manifest. For user arguments we first assume that the path references a file on disk, either as absolute path or as a path relative to the current working directory. If no file exists at the specified location an attempt is made to read the file relative to the base directory. For manifest values, they are always assumed to be relative to the base directory.

Parameters
  • basedir (string)

  • manifest_value (string) – Relative path to the file in the base directory.

  • user_argument (string) – User provided value that overrides the manifest value. This value can be None.

Return type

string

flowserv.model.workflow.manifest.read_instructions(filename: str) str

Read instruction text from a given file. If the filename is None the result will be None as well.

Return type

string

flowserv.model.workflow.manifest.unique_name(name, existing_names)

Ensure that the workflow name in the project metadata is not empty, not longer than 512 character, and unique.

Parameters
  • name (string) – Workflow name in manifest or given by user.

  • existing_names (set) – Set of names for existing projects.

Raises

flowserv.error.ConstraintViolationError