Wrapper API¶
The following are wrappers around common Orion data types that allow for simplified testing of workfloes.
Utilities¶
- wrappers.using_orion() bool ¶
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() None ¶
Cancels a running workfloe, only useful when running a job as non-blocking in Orion.
- classmethod get_workfloe(workfloe_path: str, run_timeout: int = 600, queue_timeout: int = 600, upload: bool = False, package=None) artemis.wrappers.WorkFloeWrapper ¶
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
- property identifier: Union[int, str]¶
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: Generator[None, None, Any]¶
Returns an iterator of bytes that makes up the Job Logs
Locally raises an ArtemisError :rtype: iter
- property reason: str¶
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: Dict, name: str = '', block: bool = True) None ¶
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: str¶
The state of the Workfloe as it is right now
Locally always returns complete :rtype: string
- property status: Dict¶
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: int = 600) None ¶
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
- 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
- property identifier: Union[int, str]¶
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
- 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
- property identifier: Union[int, str]¶
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, v2=False)¶
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: orionclient.types.shards.ShardCollection) artemis.wrappers.CollectionWrapper ¶
Provide a preconstructed collection as input. Allows for automatic clean up collections as a part of Artemis cleanup.
- classmethod from_file(file_path: str, as_records: bool = True, num_shards: int = 10, v2: bool = False) artemis.wrappers.CollectionWrapper ¶
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 (int item per shard if unable to pack in the requested number of shards.) – Number of shards to create from file, defaults to 1
- property identifier: int¶
Returns the id of the collection
- Returns
Collection id
- Return type
int
- property metadata: Dict¶
Returns the metadata of the collection
- Returns
Collection metadata
- Return type
dict
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: int¶
Return the number of records in a dataset
- Returns
Number of records in dataset
- Return type
int
- property identifier: str¶
Provides the output name of the Dataset, this is a random file name
- Returns
Name of the output dataset
- Return type
string
- property path: str¶
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() Generator[openeye.oechem.OEMolRecord, None, None] ¶
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: str¶
Provides the output name of the file, this is a random file name
- Returns
Name of the output file
- Return type
string
- property path: str¶
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: int¶
Size of the output file.
- Returns
Size of the output file
- Return type
int
OutputCollectionWrapper¶
- class artemis.wrappers.OutputCollectionWrapper(name=None, resource=None, v2=False)¶
- get() orionclient.types.shards.ShardCollection ¶
Returns the collection that was output
- Returns
Output shard collection
- Return type
- property identifier: str¶
Returns the randomly generated name of the output collection