Orion Platform Parameters

class orionplatform.parameters.BooleanFieldParameter(name: Optional[str] = None, field_meta: Optional[openeye.oechem.OEFieldMeta] = None, title: Optional[str] = None, default=None, required: bool = False, read_only: bool = False, help_text: str = '', description: str = '', **kwargs)

Convenience class for creating a boolean field parameter.

class orionplatform.parameters.CollectionInputParameter(name: Optional[str] = None, title: Optional[str] = None, default=None, null: bool = False, help_text: str = '', promoted: bool = False, promoted_name: Optional[str] = None, required: bool = False, hidden: bool = False, value=None, static: bool = False, max_value=None, min_value=None, max_length=None, choices=None, level='basic', description: str = '', many: bool = False, order: Optional[int] = None)

Bases: floe.api.parameters.BaseParameter

CollectionInputParameter can be a single collection IDENTIFIER, or a dictionary. Collections refer to data in Orion, using Collections will require an authenticated OrionSession.

IDENTIFIER

or

{SOURCE: [{"id": IDENTIFIER, "shards": [IDENTIFIER]}]}
IDENTIFIER

an integer

SOURCE

“collections”

Example:

{
  "collections": [
    {
      "id": 9,
    },
    {
      "id": 10,
      "shards": [1, 5, 7]
    },
  ]
}
Returns

orionplatform.parameters.CollectionStream

CollectionStream can be used as an iterator to get the collections or shards specified by the parameter.

Accessing Collections

from floe.api import SourceCube
from orionplatform.ports import CollectionOutputPort
from orionplatform.parameters import CollectionInputParameter


class ExampleCube(SourceCube):

    success = CollectionOutputPort("success")

    collection_source = CollectionInputParameter("collection_source")

    def __iter__(self):
        for collection in self.args.collection_source:
            yield collection

Accessing Shards

from floe.api import SourceCube
from orionplatform.ports import ShardOutputPort
from orionplatform.parameters import CollectionInputParameter


class ExampleCube(SourceCube):

    success = ShardOutputPort("success")

    collection_source = CollectionInputParameter("collection_source")

    def __iter__(self):
        for shard in self.args.collection_source.shards():
            yield shard
class orionplatform.parameters.CollectionOutputParameter(name: Optional[str] = None, title: Optional[str] = None, default=None, null: bool = False, help_text: str = '', promoted: bool = False, promoted_name: Optional[str] = None, required: bool = False, hidden: bool = False, value=None, static: bool = False, max_value=None, min_value=None, max_length=None, choices=None, level='basic', description: str = '', many: bool = False, order: Optional[int] = None)

Bases: floe.api.parameters.BaseParameter

Parameter used to specify the name of a Collection created within a Cube

class orionplatform.parameters.CollectionStream(obj, session=None, required=False)

Iterate over collections and shards described by CollectionInputParameter.

By default, CollectionStream iterates over the shards in the SHARD_READY state in a list of collections.

CollectionStream is tightly coupled to CollectionInputParameter and is not intended to be used separately.

collections()

Iterate over a list of collections

shards(state='ready')

Iterate over the shards in a list of collections. By default, only shards in the orionplatform.constants.SHARD_READY state are emitted. Valid orionplatform.constants.SHARD_STATES include: orionplatform.constants.SHARD_READY, orionplatform.constants.SHARD_ERROR, orionplatform.constants.SHARD_OPEN, orionplatform.constants.SHARD_TEMPORARY

class orionplatform.parameters.DatasetInputParameter(name: Optional[str] = None, title: Optional[str] = None, default=None, null: bool = False, help_text: str = '', promoted: bool = False, promoted_name: Optional[str] = None, required: bool = False, hidden: bool = False, value=None, static: bool = False, max_value=None, min_value=None, max_length=None, choices=None, level='basic', description: str = '', many: bool = False, order: Optional[int] = None)

Bases: floe.api.parameters.BaseParameter

DatasetInputParameter can be a single dataset IDENTIFIER, or a dictionary.

IDENTIFIER

or

{SOURCE: [{ID_TYPE: IDENTIFIER, "records": [IDENTIFIER]}]}
IDENTIFIER

an integer, or a path for a local file

SOURCE

“datasets”

ID_TYPE

“id” if in Orion, or “path” if local

Example - multiple Orion datasets with and without records specified:

{
  "datasets": [
    {
      "id": 135,
    },
    {
      "id": 136,
      "records": [123, 45, 645]
    }
  ],
}

Example - multiple local datasets (specifying records in local datasets is not supported):

{
  "datasets": [
    {
      "path": "100.oedb",
    },
    {
      "path": "1000.oedb",
    }
  ],
}

Example - mix of local datasets and orion datasets:

{
  "datasets": [
    {
      "path": "100.oedb",
    },
    {
      "id": 814,
    },
  ]
}
Returns

orionplatform.parameters.DatasetStream

DatasetStream can be used as an iterator to get the records specified by the parameter.

Python Example

from floe.api import SourceCube
from orionplatform.ports import RecordOutputPort
from orionplatform.parameters import DatasetInputParameter


class ExampleCube(SourceCube):

    success = RecordOutputPort("success")

    data_in = DatasetInputParameter("data_in")

    def __iter__(self):
        for dataset in self.args.data_in:
            self.log.info("Outputting records for dataset {}", dataset.identifier)
            for rec in dataset.records():
                yield record
class orionplatform.parameters.DatasetOutputParameter(name: Optional[str] = None, title: Optional[str] = None, default=None, null: bool = False, help_text: str = '', promoted: bool = False, promoted_name: Optional[str] = None, required: bool = False, hidden: bool = False, value=None, static: bool = False, max_value=None, min_value=None, max_length=None, choices=None, level='basic', description: str = '', many: bool = False, order: Optional[int] = None)

Bases: floe.api.parameters.BaseParameter

Parameter used to specify the name of a Dataset created within a Cube

class orionplatform.parameters.DatasetStream(obj, session=None, required=False)

Provides an iterator of wrappers around Datasets that provide the following utility:

  • identifier (property): either the Orion Id or local path

  • is_local (property): true if is reading from local file

  • records (method): returns fully constructed OEMolRecords

  • records_as_bytes (method): returns bytes that represent Records

The Datasets iterated over are defined by DatasetInputParameter.

DatasetStream is tightly coupled to DatasetInputParameter and is not intended to be used separately.

class orionplatform.parameters.DecimalFieldParameter(name: Optional[str] = None, field_meta: Optional[openeye.oechem.OEFieldMeta] = None, title: Optional[str] = None, default=None, required: bool = False, read_only: bool = False, help_text: str = '', description: str = '', **kwargs)

Convenience class for creating a float field parameter.

class orionplatform.parameters.FieldParameter(name: Optional[str] = None, field_type=None, field_meta: Optional[openeye.oechem.OEFieldMeta] = None, title: Optional[str] = None, default=None, required: bool = False, read_only: bool = False, help_text: str = '', description: str = '', **kwargs)

Bases: floe.api.parameters.StringParameter

Parameter that constructs a OEField object for OERecord/OEMolRecord. The user of a cube with a FieldParameter will be able to specify the name of the OEField. The default field name, field type and meta are specified by the cube writer when this parameter is constructed.

Parameters
  • field_type (datarecord.types.ObjectBase or datarecord.types.PODBase) – The type of the field parameter commonly comes from the datarecord.Types namespace

  • field_meta (datarecord.OEFieldMeta) – Metadata for the field

  • read_only (bool) – If True, then passing the field to a record method that changes the record will throw an exception

Warning

FieldParameters are supported as Cube parameters, but not as WorkFloe parameters.

See also

Parameters

class orionplatform.parameters.FieldSelector(name)

Utility class for accessing fields by name from OERecords.

Parameters

name (string) – String to match the field name with

get_field(record)

Retrieve a field with a matching name from an OERecord

Parameters

record (OERecord) – OERecord to find matching field on

Returns

OEField with same name as set on the selector.

Raises

ParameterException – Unable to find field

get_value(record)

Retrieve the value associated with the matching field from the OERecord

Parameters

record (OERecord) – OERecord to find value on

Returns

Value associated with the field

Raises

ParameterException – Unable to find field

class orionplatform.parameters.FieldSelectorParameter(name: Optional[str] = None, title: Optional[str] = None, default=None, null: bool = False, help_text: str = '', promoted: bool = False, promoted_name: Optional[str] = None, required: bool = False, hidden: bool = False, value=None, static: bool = False, max_value=None, min_value=None, max_length=None, choices=None, level='basic', description: str = '', many: bool = False, order: Optional[int] = None)

Bases: floe.api.parameters.StringParameter

Parameter that returns an instance of FieldSelector that can be used to retrieve a field that has the same name as provided to the parameter. The Orion UI will allow you to select a field from those available in a chosen Dataset.

Warning

The fields returned by this object are of any arbitrary type. If different records have fields of different types but with the same name, the user will need to handle that scenario.

Example Usage

class FieldSelectorCube(RecordPortsMixin, ComputeCube):

    selector = FieldSelectorParameter()

def process(self, record, port):
    # If not required, the default value will return a None object
    if self.args.selector is not None:
        field = self.args.selector.get_field(record)
        # Get value using retrieved field
        value = record.get_value(field)
        # Get value using selector
        value = self.args.selector.get_value(record)
class orionplatform.parameters.FileInputParameter(name: Optional[str] = None, title: Optional[str] = None, default=None, null: bool = False, help_text: str = '', promoted: bool = False, promoted_name: Optional[str] = None, required: bool = False, hidden: bool = False, value=None, static: bool = False, max_value=None, min_value=None, max_length=None, choices=None, level='basic', description: str = '', many: bool = False, order: Optional[int] = None)

Bases: floe.api.parameters.BaseParameter

FileInputParameter can be a single file IDENTIFIER, or a dictionary.

IDENTIFIER

or

{"file": INT_ID}

or

{SOURCE: [{ID_TYPE: IDENTIFIER}]}
INT_ID

an integer

IDENTIFIER

an integer, or a path for a local file

SOURCE

“files”

ID_TYPE

“id” if in Orion, or “path” if local

Example - single Orion file:

{
  "file": 135
}

Example - multiple Orion files:

{
  "files": [
    {
      "id": 135,
    },
    {
      "id": 136,
    }
  ],
}

Example - multiple local files:

{
  "files": [
    {
      "path": "100.oedb",
    },
    {
      "path": "1000.oedb",
    }
  ],
}

Example - mix of local files and Orion files:

{
  "files": [
    {
      "path": "100.oedb",
    },
    {
      "id": 814,
    },
  ]
}
Returns

orionplatform.parameters.FileStream

FileStream can be used as an iterator to get the files specified by the parameter. It can also be used to iterate over byte chunks of those files

Python Example Emit Files

from floe.api.cubes import SourceCube
from orionplatform.parameters import FileInputParameter


class ExampleCube(ComputeCube):

    data_in = FileInputParameter("data_in")

    def begin(self):
        for file in self.args.data_in:
            self.log.info("Initialized with file {} {}, is_local={}", file.identifier, file.name, file.is_local)

Python Example Emit Bytes

from floe.api.cubes import SourceCube
from floe.api.ports import BinaryOutputPort
from orionplatform.parameters import FileInputParameter


class ExampleCube(SourceCube):

    success = BinaryOutputPort("success")

    data_in = FileInputParameter("data_in")

    def __iter__(self):
        for chunk in self.args.data_in.chunks():
            self.log.info("Outputting binary chunk")
            yield chunk
class orionplatform.parameters.FileOutputParameter(name: Optional[str] = None, title: Optional[str] = None, default=None, null: bool = False, help_text: str = '', promoted: bool = False, promoted_name: Optional[str] = None, required: bool = False, hidden: bool = False, value=None, static: bool = False, max_value=None, min_value=None, max_length=None, choices=None, level='basic', description: str = '', many: bool = False, order: Optional[int] = None)

Bases: floe.api.parameters.BaseParameter

Parameter used to specify the name of a File created within a Cube

class orionplatform.parameters.FileStream(obj, session=None, required=False)

Provides an iterator of wrappers around Files that provide the following utility:

  • identifier (property): either the Orion Id or local path

  • name (property): base name of the file

  • is_local (property): true if is reading from local file

  • read(): returns bytes of file

  • copy_to(filename): Copy to a local file

FileStream is tightly coupled to FileInputParameter and is not intended to be used separately.

chunks()

Method which yields chunks for all files in the stream.

orionplatform.parameters.FloatFieldParameter

alias of orionplatform.parameters.DecimalFieldParameter

class orionplatform.parameters.InputMolFieldParameter(name: Optional[str] = None, field_meta: Optional[openeye.oechem.OEFieldMeta] = None, title: Optional[str] = None, default=None, required: bool = False, help_text: str = '', description: str = '', **kwargs)

Convenience class for creating a field parameter that will provide an OEPrimaryField that provides access to a record’s Primary Molecule in read only mode.

class orionplatform.parameters.InputSystemTagParameter(name=None, valid=None, invalid=None)

Bases: floe.api.parameters.JSONParameter

validate(value)

Check that value is a valid value for the parameter. If value is None, validates the parameter’s default value. :param value: The value to be checked :raises: ValueError :return: None

class orionplatform.parameters.IntegerFieldParameter(name: Optional[str] = None, field_meta: Optional[openeye.oechem.OEFieldMeta] = None, title: Optional[str] = None, default=None, required: bool = False, read_only: bool = False, help_text: str = '', description: str = '', **kwargs)

Convenience class for creating an integer field parameter.

class orionplatform.parameters.LinkFieldParameter(name: Optional[str] = None, field_meta: Optional[openeye.oechem.OEFieldMeta] = None, title: Optional[str] = None, default=None, required: bool = False, read_only: bool = False, help_text: str = '', description: str = '', **kwargs)

Convenience class for creating a link field parameter.

class orionplatform.parameters.MolFieldParameter(name: Optional[str] = None, field_meta: Optional[openeye.oechem.OEFieldMeta] = None, title: Optional[str] = None, default=None, required: bool = False, read_only: bool = False, help_text: str = '', description: str = '', **kwargs)

Convenience class for creating a field parameter of type molecule.

class orionplatform.parameters.OutputMolFieldParameter(name: Optional[str] = None, field_meta: Optional[openeye.oechem.OEFieldMeta] = None, title: Optional[str] = None, default=None, required: bool = False, help_text: str = '', description: str = '', **kwargs)

Convenience class for creating a field parameter that will provide an OEPrimaryField that can be used for attaching a molecule to a record.

class orionplatform.parameters.PrimaryMolFieldParameter(name: Optional[str] = None, field_meta: Optional[openeye.oechem.OEFieldMeta] = None, title: Optional[str] = None, default=None, required: bool = False, read_only: bool = False, help_text: str = '', description: str = '', **kwargs)

Convenience class for creating a field parameter that will provide an OEPrimaryField that provides access to a record’s Primary Molecule

If a default value is provided or a new value is provided at runtime this will return a OEField with its type as Types.Chem.Mol. Which can be used for modifying where a molecule is placed on a record at run time.

class orionplatform.parameters.SecretInputParameter(name: Optional[str] = None, title: Optional[str] = None, default=None, null: bool = False, help_text: str = '', promoted: bool = False, promoted_name: Optional[str] = None, required: bool = False, hidden: bool = False, value=None, static: bool = False, max_value=None, min_value=None, max_length=None, choices=None, level='basic', description: str = '', many: bool = False, order: Optional[int] = None)

Bases: floe.api.parameters.BaseParameter

SecretInputParameter can be a single secret IDENTIFIER, or a dictionary. Secrets refer to data in Orion, using Secrets will require an authenticated OrionSession.

IDENTIFIER

or

{SOURCE: [{"id": IDENTIFIER}]}
IDENTIFIER

an integer

SOURCE

“secrets”

Example:

{
  "secrets": [
    {
      "id": 9,
    },
    {
      "id": 10,
    },
  ]
}
Returns

orionplatform.parameters.SecretStream

SecretStream can be used as an iterator to get the secrets specified by the parameter.

class orionplatform.parameters.SecretStream(obj, session=None, required=False)

Provides an iterator of Orion Client Secrets objects.

SecretStream is tightly coupled to SecretInputParameter and is not intended to be used separately.

class orionplatform.parameters.StringFieldParameter(name: Optional[str] = None, field_meta: Optional[openeye.oechem.OEFieldMeta] = None, title: Optional[str] = None, default=None, required: bool = False, read_only: bool = False, help_text: str = '', description: str = '', **kwargs)

Convenience class for creating a field parameter of type string.