pbcommand Models

Core Models

class pbcommand.models.FileType(file_type_id, base_name, ext, mime_type)[source]

Bases: object

Core File Type data model

Parameters:
  • file_type_id – unique file string
  • base_name – default base name of the file (without extension)
  • ext – file extension
  • mime_type – file mimetype
Returns:

default_name

Default name of file alias for base_name

class pbcommand.models.TaskOptionTypes[source]

Bases: object

Core Task Option type id type

classmethod ALL()[source]

Return a set of all Task Option Types

classmethod ALL_CHOICES()[source]

Returns a set of choice task option types

classmethod ALL_SIMPLE()[source]

Returns a set of ‘simple’ task option types (e.g., boolean, string, int, float)

BOOL = 'boolean'
CHOICE_FLOAT = 'choice_float'
CHOICE_INT = 'choice_integer'
CHOICE_STR = 'choice_string'
FLOAT = 'float'
INT = 'integer'
STR = 'string'
classmethod from_choice_str(sx)[source]

Validates and returns a task choice option type or raises ValueError

classmethod from_simple_str(sx)[source]

Validates a string is a validate task option type id or raise ValueError

:raises ValueError

classmethod from_str(sx)[source]

Validates and returns a valid type option type id or raises ValueError,

Note:For legacy reasons, “number” will be mapped to “float”
classmethod is_choice(sx)[source]
class pbcommand.models.DataStore(ds_files, created_at=None)[source]

Bases: object

Parameters:
  • ds_files (list[DataStoreFile]) – list of datastore file instances
  • created_at – Date the datastore was created. if None, will use the current datetime
add(ds_file)[source]
static load_from_d(d, base_path=None)[source]

Load DataStore from a dict

static load_from_json(path)[source]

Load DataStore from a JSON file

to_dict()[source]
version = '0.2.2'
write_json(file_name)[source]
write_update_json(file_name)[source]

Overwrite Datastore with current state

class pbcommand.models.DataStoreFile(uuid, source_id, type_id, path, is_chunked=False, name='', description='')[source]

Bases: object

Parameters:
  • uuid – UUID of the datstore file
  • source_id – source id of the DataStore file
  • type_id – File Type id of
  • path – Absolute path to the datastore file
  • is_chunked – is the datastore file a “chunked” file from a scatter/chunking task
  • name – Display name of datastore file
  • description – Description of the datastore file
file_type
static from_dict(d, base_path=None)[source]
source_id

This is the consistent form that is used in the code base

to_dict()[source]
class pbcommand.models.PipelineChunk(chunk_id, **kwargs)[source]

Bases: object

kwargs is a key-value store. keys that begin “$chunk.” are considered to be semantically understood by workflow and can be “routed” to chunked task inputs.

Values that don’t begin with “$chunk.” are considered metadata.

Parameters:chunk_id (str) – Chunk id
CHUNK_KEY_PREFIX = '$chunk.'
RX_CHUNK_KEY = <_sre.SRE_Pattern object>
chunk_d
chunk_keys
chunk_metadata
set_chunk_key(chunk_key, value)[source]

Overwrite or add a chunk_key => value to the Chunk datum

the chunk-key can be provided with or without the ‘$chunk:’ prefix

set_metadata_key(metadata_key, value)[source]

Set chunk metadata key => value

metadata key must NOT begin with $chunk. format

to_dict()[source]
class pbcommand.models.SymbolTypes[source]

Bases: object

Symbols that are understood during resolving, such as max number of processors, Max Chunks. Used when defining a Tool Contract

MAX_NCHUNKS = '$max_nchunks'
MAX_NPROC = '$max_nproc'
NCHUNKS = '$nchunks'
NPROC = '$nproc'
OPTS = '$opts'
RESOLVED_OPTS = '$ropts'
SCHEMA_OPTS = '$opts_schema'
TASK_TYPE = '$task_type'
class pbcommand.models.ResourceTypes[source]

Bases: object

Resources such as tmp dirs and files, log files. Used when defining a Tool Contract

classmethod ALL()[source]
LOG_FILE = '$logfile'
OUTPUT_DIR = '$outputdir'
TMP_DIR = '$tmpdir'
TMP_FILE = '$tmpfile'
classmethod is_tmp_resource(name)[source]
classmethod is_valid(attr_name)[source]