Base translator class
aiida.restapi.translator.base.
BaseTranslator
Bases: object
object
Generic class for translator. It contains the methods required to build a related QueryBuilder object
__dict__
__init__
Initialise the parameters. Create the basic query_help
keyword Class (default None but becomes this class): is the class from which one takes the initial values of the attributes. By default is this class so that class atributes are translated into object attributes. In case of inheritance one cane use the same constructore but pass the inheriting class to pass its attributes.
__label__
__module__
__repr__
This function is required for the caching system to be able to compare two NodeTranslator objects. Comparison is done on the value returned by __repr__
representation of NodeTranslator objects. Returns nothing because the inputs of self.get_nodes are sufficient to determine the identity of two queries.
__weakref__
list of weak references to the object (if defined)
_aiida_class
_aiida_type
_check_id_validity
Checks whether id corresponds to an object of the expected type, whenever type is a valid column of the database (ex. for nodes, but not for users)
node_id – id (or id starting pattern)
True if node_id valid, False if invalid. If True, sets the id filter attribute correctly
RestValidationError – if no node is found or id pattern does not identify a unique node
_default
_default_projections
_has_uuid
_is_id_query
_is_qb_initialized
_result_type
_total_count
count
Count the number of rows returned by the query and set total_count
get_default_projections
method to get default projections of the node :return: self._default_projections
get_formatted_result
Runs the query and retrieves results tagged as “label”.
label (str) – the tag of the results to be extracted out of the query rows.
a list of the query results
get_projectable_properties
This method is extended in specific translators classes. It returns a dict as follows: dict(fields=projectable_properties, ordering=ordering) where projectable_properties is a dict and ordering is a list
get_query_help
return QB json dictionary
get_results
Returns either list of nodes or details of single node from database.
either list of nodes or details of single node from database
get_total_count
Returns the number of rows of the query.
total_count
init_qb
Initialize query builder object by means of _query_help
set_default_projections
It calls the set_projections() methods internally to add the default projections in query_help
None
set_filters
Add filters in query_help.
filters –
it is a dictionary where keys are the tag names given in the path in query_help and their values are the dictionary of filters want to add for that tag name. Format for the Filters dictionary:
filters = { "tag1" : {k1:v1, k2:v2}, "tag2" : {k1:v1, k2:v2}, }
query_help dict including filters if any.
set_limit_offset
sets limits and offset directly to the query_builder object
limit –
offset –
set_order
Add order_by clause in query_help :param orders: dictionary of orders you want to apply on final results :return: None or exception if any.
set_projections
add the projections in query_help
projections – it is a dictionary where keys are the tag names given in the path in query_help and values are the list of the names you want to project in the final output
updated query_help with projections
set_query
Adds filters, default projections, order specs to the query_help, and initializes the qb object
filters – dictionary with the filters
orders – dictionary with the order for each tag
projections – dictionary with the projection. It is discarded if query_type==’attributes’/’extras’
query_type – (string) specify the result or the content (“attr”)
id – (integer) id of a specific node
filename – name of the file to return its content
attributes – flag to show attributes in nodes endpoint
attributes_filter – list of node attributes to query
extras – flag to show attributes in nodes endpoint
extras_filter – list of node extras to query
Translator for computer
aiida.restapi.translator.computer.
ComputerTranslator
Bases: aiida.restapi.translator.base.BaseTranslator
aiida.restapi.translator.base.BaseTranslator
Translator relative to resource ‘computers’ and aiida class Computer
alias of aiida.orm.computers.Computer
aiida.orm.computers.Computer
Get projectable properties specific for Computer :return: dict of projectable properties and column_order list
Translator for group
aiida.restapi.translator.group.
GroupTranslator
Translator relative to resource ‘groups’ and aiida class Group
alias of aiida.orm.groups.Group
aiida.orm.groups.Group
Get projectable properties specific for Group :return: dict of projectable properties and column_order list
Translator for user
aiida.restapi.translator.user.
UserTranslator
Translator relative to resource ‘users’ and aiida class User
alias of aiida.orm.users.User
aiida.orm.users.User
Get projectable properties specific for User :return: dict of projectable properties and column_order list