aiida.restapi.translator.nodes package#

Subpackages#

Submodules#

Translator for node

class aiida.restapi.translator.nodes.node.NodeTranslator(**kwargs)[源代码]#

基类:BaseTranslator

Translator relative to resource ‘nodes’ and aiida class Node

__annotations__ = {}#
__init__(**kwargs)[源代码]#

Initialise the parameters. Create the basic query_help

__label__ = 'nodes'#
__module__ = 'aiida.restapi.translator.nodes.node'#
_aiida_class#

Node 的别名

_aiida_type = 'node.Node'#
_attributes_filter = None#
_content_type = None#
_download = None#
_download_format = None#
_extras_filter = None#
_filename = None#
_get_content()[源代码]#

Used by get_results() in case of endpoint include “content” option :return: data: a dictionary containing the results obtained by running the query

_get_subclasses(parent=None, parent_class=None, recursive=True)[源代码]#

Import all submodules of the package containing the present class. Includes subpackages recursively, if specified.

参数:
  • parent – package/class. If package looks for the classes in submodules. If class, first looks for the package where it is contained

  • parent_class – class of which to look for subclasses

  • recursive – True/False (go recursively into submodules)

_has_uuid = True#
_result_type = 'nodes'#
static get_all_download_formats(full_type=None)[源代码]#

Returns dict of possible node formats for all available node types

static get_comments(node)[源代码]#
参数:

node – node object

返回:

node comments

get_derived_properties(node)[源代码]#

Generic function to get the derived properties of the node. Actual definition is in child classes as the content to be returned depends on the plugin specific to the resource

参数:

node – node object that has to be visualized

返回:

derived properties of the node

If this method is called by Node resource it will look for the type of object and invoke the correct method in the lowest-compatible subclass

static get_downloadable_data(node, download_format=None)[源代码]#

Generic function to download file in specified format. Actual definition is in child classes as the content to be returned and its format depends on the download plugin specific to the resource

参数:
  • node – node object

  • download_format – file extension format

返回:

data in selected format to download

If this method is called for a Data node resource it will invoke the get_downloadable_data method in the Data transaltor. Otherwise it raises RestFeatureNotAvailable exception

static get_file_content(node, file_name)[源代码]#

It reads the file from directory and returns its content.

Instead of using “send_from_directory” from flask, this method is written because in next aiida releases the file can be stored locally or in object storage.

参数:
  • node – aiida folderData node which contains file

  • file_name – name of the file to return its contents

返回:

get_formatted_result(label)[源代码]#

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_io_tree(uuid_pattern, tree_in_limit, tree_out_limit)[源代码]#

Json data to display nodes in tree format :param uuid_pattern: main node uuid :return: json data to display node tree

static get_namespace(user_pk=None, count_nodes=False)[源代码]#

Return full_types of the nodes

get_projectable_properties()[源代码]#

Get projectable properties specific for Node :return: dict of projectable properties and column_order list

static get_repo_contents(node, filename='')[源代码]#

Every node in AiiDA is having repo folder. This function returns the metadata using get_object() method :param node: node object :param filename: folder or file name (optional) :return: file content in bytes to download

static get_repo_list(node, filename='')[源代码]#

Every node in AiiDA is having repo folder. This function returns the metadata using list_objects() method :param node: node object :param filename: folder name (optional) :return: folder list

get_results()[源代码]#

Returns either a list of nodes or details of single node from database

返回:

either a list of nodes or the details of single node from the database

get_statistics(user_pk=None)[源代码]#

Return statistics for a given node

set_query(filters=None, orders=None, projections=None, query_type=None, node_id=None, download_format=None, download=None, filename=None, attributes=None, attributes_filter=None, extras=None, extras_filter=None, full_type=None)[源代码]#

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

  • download_format – file format to download e.g. cif, xyz

  • filename – name of the file to return its content

  • attributes – flag to show attributes for nodes

  • attributes_filter – list of attributes to query

  • extras – flag to show extras for nodes

  • extras_filter – list of extras to query

set_query_type(query_type, attributes_filter=None, extras_filter=None, download_format=None, download=None, filename=None)[源代码]#

Sets one of the mutually exclusive values for self._result_type and self._content_type.

:param query_type:(string) the value assigned to either variable.