Wrapper API

The following are wrappers around common Orion data types that allow for simplified testing of workfloes.

Utilities

wrappers.using_orion()

Method to check whether the tests are being run against Orion

WorkFloe Wrapper

class artemis.wrappers.WorkFloeWrapper(workfloe_path='', upload=False, run_timeout=600, queue_timeout=600, reuse: bool = False, package=None, workfloe_spec=None, orion_job=None, using_orion=NOTHING, last_refresh=None, start_time=None, local_job=NOTHING)
cancel()

Cancels a running workfloe, only useful when running a job as non-blocking in Orion.

classmethod get_workfloe(workfloe_path, run_timeout=600, queue_timeout=600, upload=False, package=None)

Create a WorkFloeWrapper that will be cleaned up at the end of the tests

Parameters
  • workfloe_path (string) – Path to the local workfloe

  • run_timeout (int) – How long to run floe before canceling

  • queue_timeout (int) – How long to wait for the floe to start Only used when testing against Orion

  • upload (bool) – Tries to upload floe to Orion and expects cubes to already be on orion. WARNING: Preliminary API that is fragile

Returns

WorkFloeWrapper

Return type

WorkFloeWrapper

property identifier

Returns either the path of the WorkFloe or the Orion WorkFloe Job Id that specifies the Job

Returns

Workfloe Path or Orion Job Id

property logs

Returns an iterator of bytes that makes up the Job Logs

Locally raises an ArtemisError :rtype: iter

property reason

The reason for why the state is the way it is. If the reason isn’t empty then something went wrong

Locally always returns “” :rtype: string

start(parameters, name='', block=True)

Triggers the Workfloe to be run.

Parameters
  • parameters (dict) – Parameters to run the Floe with, see below

  • name (string) – Optional name to give floe, otherwise it will default to the path name

  • block (bool) – Whether the call to start should block or not, only supported if testing against orion

Raises

WorkFloeException: Something went wrong while running the floe

Returns

None

The parameter dictionary is expected to be structured as follows

{
  "promoted": {
    "promoted_name": "value"
  },
  "cube": {
    "cube_name": {
      "param_name": "value"
    }
  }
}
property state

The state of the Workfloe as it is right now

Locally always returns complete :rtype: string

property status

Retrieves the status of the Workfloe job. The status is the summary of the current job.

Locally raises an ArtemisError :rtype: dict

wait(max_wait=600)

Waits on Workfloe until it is complete

Should only be used if you are running workfloes in a non-blocking manner

Input Wrappers

DatasetWrapper

class artemis.wrappers.DatasetWrapper(dataset_path='', dataset_obj=None)
classmethod from_file(dataset_path: str, reuse: bool = False)artemis.wrappers.DatasetWrapper

Create a DatasetWrapper that will be cleaned up at the end of the tests

Parameters
  • dataset_path (string) – Path to the local dataset (.oedb)

  • reuse (bool) – Whether to cache the dataset for testing

Returns

DatasetWrapper

Return type

DatasetWrapper

classmethod get_dataset(dataset_path: str, reuse: bool = False)artemis.wrappers.DatasetWrapper

Create a DatasetWrapper that will be cleaned up at the end of the tests

Parameters
  • dataset_path (string) – Path to the local dataset (.oedb)

  • reuse (bool) – Whether to cache the dataset for testing

Returns

DatasetWrapper

Return type

DatasetWrapper

property identifier

Provides the File Path or the Orion Dataset Id to the resource that is being used.

Returns

Dataset path or Orion Dataset Id

FileWrapper

class artemis.wrappers.FileWrapper(file_path='', file_obj=None, reuse=True)
classmethod from_file(file_path: str, reuse: bool = False)artemis.wrappers.FileWrapper

Create a FileWrapper that will be cleaned up at the end of the tests

Parameters
  • file_path (string) – Path to the local file

  • reuse (bool) – Whether to cache the file for testing

Returns

FileWrapper

Return type

FileWrapper

classmethod get_file(file_path: str, reuse: bool = False)artemis.wrappers.FileWrapper

Create a FileWrapper that will be cleaned up at the end of the tests

Parameters
  • file_path (string) – Path to the local file

  • reuse (bool) – Whether to cache the file for testing

Returns

FileWrapper

Return type

FileWrapper

property identifier

Provides the File Path or the Orion File Id to the resource that is being used.

Returns

File path or Orion File Id

CollectionWrapper

class artemis.wrappers.CollectionWrapper(resource=None, num_shards: int = 0)

Utility for testing floes that require Collections.

Requires an authenticated Orion Client to perform creation of ShardCollection objects, even if not running tests against orion.

classmethod from_collection(collection)

Provide a preconstructed collection as input. Allows for automatic clean up collections as a part of Artemis cleanup.

classmethod from_file(file_path, as_records=True, num_shards=10)

Convert a file into a collection automatically.

Parameters
  • file_path (string) – Path to file, must be readable by OEChem

  • as_records (bool) – Convert molecular file to records, otherwise writes as oeb.gz

  • num_shards – Number of shards to create from file, defaults to 1

property identifier

Returns the id of the collection

Returns

Collection id

Return type

int

Output Wrappers

OutputDatasetWrapper

class artemis.wrappers.OutputDatasetWrapper(dataset_name='', extension='.oedb', temp=None, orion_resource=None)

A Utility class to be able to retrieve the output values of a dataset

property count

Return the number of records in a dataset

Returns

Number of records in dataset

Return type

int

property identifier

Provides the output name of the Dataset, this is a random file name

Returns

Name of the output dataset

Return type

string

property path

Path to the output Dataset.

This will download the Dataset from Orion when it is requested

Returns

Path to the Dataset

Return type

string

records()

Return the records contained with the output dataset as an iterator of OEMolRecords

Returns

Iterator of OEMolRecords

OutputFileWrapper

class artemis.wrappers.OutputFileWrapper(file_name='', extension='.txt', temp=None)
property identifier

Provides the output name of the file, this is a random file name

Returns

Name of the output file

Return type

string

property path

Path to the output file.

This will download the file from Orion when it is requested

Returns

Path to the Dataset

Return type

string

property size

Size of the output file.

Returns

Size of the output file

Return type

int

OutputCollectionWrapper

class artemis.wrappers.OutputCollectionWrapper(name=None, resource=None)
get()

Returns the collection that was output

Returns

Output shard collection

Return type

ShardCollection

property identifier

Returns the randomly generated name of the output collection