COMPS.Data.QueryCriteria module

class COMPS.Data.QueryCriteria.QueryCriteria

Bases: object

A helper class to control query return-sets by filtering on basic properties and tags, as well as controlling which properties and child-objects to fill for returned objects.

property fields
property children
property filters
property tag_filters
property xparams
select(fields)

Set which basic properties to fill for returned objects.

Parameters

fields – A list of basic properties to fill; e.g. [‘id’,’description’].

Returns

A reference to this object so calls can be chained.

select_children(children)

Set which child objects to fill for returned objects.

Parameters

children – A list of child objects to fill; e.g. [‘tags’,’hpc_jobs’].

Returns

A reference to this object so calls can be chained.

where(filters)

Set filter criteria for basic properties.

For string filter values, ‘~’ is used for the “like”-operator (i.e. string-contains). For numeric filter values, standard arithmetic operators are allowed.

Parameters

filters – A list of basic property filter-criteria; e.g. [‘name~Test’,’state=Failed’].

Returns

A reference to this object so calls can be chained.

where_tag(tag_filters)

Set filter criteria for tags.

For string filter values, ‘~’ is used for the “like”-operator (i.e. string-contains). For numeric filter values, standard arithmetic operators are allowed.

Parameters

tag_filters – A list of tag filter-criteria; e.g. [‘Replicate=3’,’DiseaseType~Malaria’].

Returns

A reference to this object so calls can be chained.

orderby(orderby_field)

Set which basic property to sort returned results-set by.

Parameters

orderby_field – A string containing the basic property name to sort by. By default, ascending-sort is assumed, but descending-sort can be specified by appending a space and ‘desc’ to this argument; e.g. ‘date_created desc’.

Returns

A reference to this object so calls can be chained.

offset(offset_num)

Set the offset within the results-set to start returning results from.

Parameters

offset_num – An int to specify offset within the results-set.

Returns

A reference to this object so calls can be chained.

count(count_num)

Set the maximum number of results to return in the results-set.

Parameters

count_num – An int to specify maximum number of results to return.

Returns

A reference to this object so calls can be chained.

add_extra_params(xp_dict)

Set any parameters that aren’t otherwise explicitly supported. This allows taking advantage of future potential changes to COMPS even if pyCOMPS support is not yet implemented or using an older version of pyCOMPS.

Parameters

xp_dict – A dictionary of additional parameters and values to pass to the COMPS API.

Returns

A reference to this object so calls can be chained.

to_param_dict(ent_type)