INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
Start to run a strategy | def run(**kwargs):
"""
Start to run a strategy
"""
config_path = kwargs.get('config_path', None)
if config_path is not None:
config_path = os.path.abspath(config_path)
kwargs.pop('config_path')
if not kwargs.get('base__securities', None):
kwargs.pop('base__securities', No... |
Generate example strategies to target folder | def examples(directory):
"""
Generate example strategies to target folder
"""
source_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "examples")
try:
shutil.copytree(source_dir, os.path.join(directory, "examples"))
except OSError as e:
if e.errno == errno.EEXIST:... |
Generate default config file | def generate_config(directory):
"""
Generate default config file
"""
default_config = os.path.join(os.path.dirname(os.path.realpath(__file__)), "config.yml")
target_config_path = os.path.abspath(os.path.join(directory, 'config.yml'))
shutil.copy(default_config, target_config_path)
six.print_... |
Mod management command | def mod(cmd, params):
"""
Mod management command
rqalpha mod list \n
rqalpha mod install xxx \n
rqalpha mod uninstall xxx \n
rqalpha mod enable xxx \n
rqalpha mod disable xxx \n
"""
def list(params):
"""
List all mod configuration
"""
from tabulate i... |
[ sys_analyser ] draw result DataFrame | def plot(result_pickle_file_path, show, plot_save_file):
"""
[sys_analyser] draw result DataFrame
"""
import pandas as pd
from .plot import plot_result
result_dict = pd.read_pickle(result_pickle_file_path)
plot_result(result_dict, show, plot_save_file) |
[ sys_analyser ] Generate report from backtest output file | def report(result_pickle_file_path, target_report_csv_path):
"""
[sys_analyser] Generate report from backtest output file
"""
import pandas as pd
result_dict = pd.read_pickle(result_pickle_file_path)
from .report import generate_report
generate_report(result_dict, target_report_csv_path) |
[ float ] 总保证金 | def margin(self):
"""
[float] 总保证金
"""
return sum(position.margin for position in six.itervalues(self._positions)) |
[ float ] 买方向保证金 | def buy_margin(self):
"""
[float] 买方向保证金
"""
return sum(position.buy_margin for position in six.itervalues(self._positions)) |
[ float ] 卖方向保证金 | def sell_margin(self):
"""
[float] 卖方向保证金
"""
return sum(position.sell_margin for position in six.itervalues(self._positions)) |
[ float ] 浮动盈亏 | def holding_pnl(self):
"""
[float] 浮动盈亏
"""
return sum(position.holding_pnl for position in six.itervalues(self._positions)) |
[ float ] 平仓盈亏 | def realized_pnl(self):
"""
[float] 平仓盈亏
"""
return sum(position.realized_pnl for position in six.itervalues(self._positions)) |
全品种通用智能调仓函数 | def order(order_book_id, quantity, price=None, style=None):
"""
全品种通用智能调仓函数
如果不指定 price, 则相当于下 MarketOrder
如果 order_book_id 是股票,等同于调用 order_shares
如果 order_book_id 是期货,则进行智能下单:
* quantity 表示调仓量
* 如果 quantity 为正数,则先平 Sell 方向仓位,再开 Buy 方向仓位
* 如果 quantity 为负数,则先平 Buy 反向... |
<Clear SQL cursor > _ | def clear_cursor(self, body, params=None):
"""
`<Clear SQL cursor>`_
:arg body: Specify the cursor value in the `cursor` element to clean the
cursor.
"""
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")
... |
<Execute SQL > _ | def query(self, body, params=None):
"""
`<Execute SQL>`_
:arg body: Use the `query` element to start a query. Use the `cursor`
element to continue a query.
:arg format: a short version of the Accept header, e.g. json, yaml
"""
if body in SKIP_IN_PATH:
... |
<Translate SQL into Elasticsearch queries > _ | def translate(self, body, params=None):
"""
`<Translate SQL into Elasticsearch queries>`_
:arg body: Specify the query in the `query` element.
"""
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")
return self.tran... |
Log a successful API call. | def log_request_success(self, method, full_url, path, body, status_code, response, duration):
""" Log a successful API call. """
# TODO: optionally pass in params instead of full_url and do urlencode only when needed
# body has already been serialized to utf-8, deserialize it for logging
... |
Log an unsuccessful API call. | def log_request_fail(self, method, full_url, path, body, duration, status_code=None, response=None, exception=None):
""" Log an unsuccessful API call. """
# do not log 404s on HEAD requests
if method == 'HEAD' and status_code == 404:
return
logger.warning(
'%s %s... |
Locate appropriate exception and raise it. | def _raise_error(self, status_code, raw_data):
""" Locate appropriate exception and raise it. """
error_message = raw_data
additional_info = None
try:
if raw_data:
additional_info = json.loads(raw_data)
error_message = additional_info.get('erro... |
Helper function to transform hosts argument to: class: ~elasticsearch. Elasticsearch to a list of dicts. | def _normalize_hosts(hosts):
"""
Helper function to transform hosts argument to
:class:`~elasticsearch.Elasticsearch` to a list of dicts.
"""
# if hosts are empty, just defer to defaults down the line
if hosts is None:
return [{}]
# passed in just one string
if isinstance(hosts,... |
Returns True if the cluster is up False otherwise. <http:// www. elastic. co/ guide/ > _ | def ping(self, params=None):
"""
Returns True if the cluster is up, False otherwise.
`<http://www.elastic.co/guide/>`_
"""
try:
return self.transport.perform_request("HEAD", "/", params=params)
except TransportError:
return False |
Get multiple documents based on an index type ( optional ) and ids. <http:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ docs - multi - get. html > _ | def mget(self, body, doc_type=None, index=None, params=None):
"""
Get multiple documents based on an index, type (optional) and ids.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.html>`_
:arg body: Document identifiers; can be either `docs` (containing ... |
Update a document based on a script or partial data provided. <http:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ docs - update. html > _ | def update(self, index, id, doc_type="_doc", body=None, params=None):
"""
Update a document based on a script or partial data provided.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html>`_
:arg index: The name of the index
:arg id: Document ID
... |
Execute a search query and get back search hits that match the query. <http:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ search - search. html > _ | def search(self, index=None, body=None, params=None):
"""
Execute a search query and get back search hits that match the query.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html>`_
:arg index: A list of index names to search, or a string containing a
... |
Reindex all documents from one index to another. <https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ docs - reindex. html > _ | def reindex(self, body, params=None):
"""
Reindex all documents from one index to another.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html>`_
:arg body: The search definition using the Query DSL and the prototype
for the index request.
... |
Change the value of requests_per_second of a running reindex task. <https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ docs - reindex. html > _ | def reindex_rethrottle(self, task_id=None, params=None):
"""
Change the value of ``requests_per_second`` of a running ``reindex`` task.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html>`_
:arg task_id: The task id to rethrottle
:arg requests_pe... |
The search shards api returns the indices and shards that a search request would be executed against. This can give useful feedback for working out issues or planning optimizations with routing and shard preferences. <http:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ search - shards. html > _ | def search_shards(self, index=None, params=None):
"""
The search shards api returns the indices and shards that a search
request would be executed against. This can give useful feedback for working
out issues or planning optimizations with routing and shard preferences.
`<http://... |
A query that accepts a query template and a map of key/ value pairs to fill in template parameters. <http:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ search - template. html > _ | def search_template(self, index=None, body=None, params=None):
"""
A query that accepts a query template and a map of key/value pairs to
fill in template parameters.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html>`_
:arg index: A list of in... |
Scroll a search request created by specifying the scroll parameter. <http:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ search - request - scroll. html > _ | def scroll(self, scroll_id=None, body=None, params=None):
"""
Scroll a search request created by specifying the scroll parameter.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html>`_
:arg scroll_id: The scroll ID
:arg body: The scroll ID... |
Multi termvectors API allows to get multiple termvectors based on an index type and id. <http:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ docs - multi - termvectors. html > _ | def mtermvectors(self, doc_type=None, index=None, body=None, params=None):
"""
Multi termvectors API allows to get multiple termvectors based on an
index, type and id.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-termvectors.html>`_
:arg index: The... |
Create a script in given language with specified ID. <http:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ modules - scripting. html > _ | def put_script(self, id, body, context=None, params=None):
"""
Create a script in given language with specified ID.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html>`_
:arg id: Script ID
:arg body: The document
"""
for param... |
<http:// www. elasticsearch. org/ guide/ en/ elasticsearch/ reference/ current/ search - template. html > _ | def render_search_template(self, id=None, body=None, params=None):
"""
`<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-template.html>`_
:arg id: The id of the stored search template
:arg body: The search definition template and its params
"""
... |
The/ _search/ template endpoint allows to use the mustache language to pre render search requests before they are executed and fill existing templates with template parameters. <http:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ search - template. html > _ | def msearch_template(self, body, index=None, params=None):
"""
The /_search/template endpoint allows to use the mustache language to
pre render search requests, before they are executed and fill existing
templates with template parameters.
`<http://www.elastic.co/guide/en/elastic... |
The field capabilities API allows to retrieve the capabilities of fields among multiple indices. <http:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ search - field - caps. html > _ | def field_caps(self, index=None, body=None, params=None):
"""
The field capabilities API allows to retrieve the capabilities of fields among multiple indices.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/search-field-caps.html>`_
:arg index: A list of index names, or... |
<http:// www. elastic. co/ guide/ en/ monitoring/ current/ appendix - api - bulk. html > _ | def bulk(self, body, doc_type=None, params=None):
"""
`<http://www.elastic.co/guide/en/monitoring/current/appendix-api-bulk.html>`_
:arg body: The operation definition and data (action-data pairs),
separated by newlines
:arg doc_type: Default document type for items which do... |
Create a new: class: ~elasticsearch. Connection instance and add it to the pool. | def add_connection(self, host):
"""
Create a new :class:`~elasticsearch.Connection` instance and add it to the pool.
:arg host: kwargs that will be used to create the instance
"""
self.hosts.append(host)
self.set_connections(self.hosts) |
Retreive a: class: ~elasticsearch. Connection instance from the: class: ~elasticsearch. ConnectionPool instance. | def get_connection(self):
"""
Retreive a :class:`~elasticsearch.Connection` instance from the
:class:`~elasticsearch.ConnectionPool` instance.
"""
if self.sniffer_timeout:
if time.time() >= self.last_sniff + self.sniffer_timeout:
self.sniff_hosts()
... |
Obtain a list of nodes from the cluster and create a new connection pool using the information retrieved. | def sniff_hosts(self, initial=False):
"""
Obtain a list of nodes from the cluster and create a new connection
pool using the information retrieved.
To extract the node connection parameters use the ``nodes_to_host_callback``.
:arg initial: flag indicating if this is during star... |
Mark a connection as dead ( failed ) in the connection pool. If sniffing on failure is enabled this will initiate the sniffing process. | def mark_dead(self, connection):
"""
Mark a connection as dead (failed) in the connection pool. If sniffing
on failure is enabled this will initiate the sniffing process.
:arg connection: instance of :class:`~elasticsearch.Connection` that failed
"""
# mark as dead even ... |
Perform the actual request. Retrieve a connection from the connection pool pass all the information to it s perform_request method and return the data. | def perform_request(self, method, url, headers=None, params=None, body=None):
"""
Perform the actual request. Retrieve a connection from the connection
pool, pass all the information to it's perform_request method and
return the data.
If an exception was raised, mark the connect... |
<https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ security - api - change - password. html > _ | def change_password(self, body, username=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-change-password.html>`_
:arg body: the new password for the user
:arg username: The username of the user to change the password for
:ar... |
<https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ security - api - clear - cache. html > _ | def clear_cached_realms(self, realms, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-cache.html>`_
:arg realms: Comma-separated list of realms to clear
:arg usernames: Comma-separated list of usernames to clear from the
... |
<https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ security - api - clear - role - cache. html > _ | def clear_cached_roles(self, name, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-role-cache.html>`_
:arg name: Role name
"""
if name in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument... |
<https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ security - api - create - api - key. html > _ | def create_api_key(self, body, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html>`_
:arg body: The api key request to create an API key
:arg refresh: If `true` (the default) then refresh the affected shards
t... |
<TODO > _ | def delete_privileges(self, application, name, params=None):
"""
`<TODO>`_
:arg application: Application name
:arg name: Privilege name
:arg refresh: If `true` (the default) then refresh the affected shards
to make this operation visible to search, if `wait_for` then... |
<https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ security - api - delete - user. html > _ | def delete_user(self, username, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-user.html>`_
:arg username: username
:arg refresh: If `true` (the default) then refresh the affected shards
to make this operation visible ... |
<TODO > _ | def get_privileges(self, application=None, name=None, params=None):
"""
`<TODO>`_
:arg application: Application name
:arg name: Privilege name
"""
return self.transport.perform_request(
"GET",
_make_path("_security", "privilege", application, name... |
<https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ security - api - get - role. html > _ | def get_role(self, name=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role.html>`_
:arg name: Role name
"""
return self.transport.perform_request(
"GET", _make_path("_security", "role", name), params=params... |
<https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ security - api - get - role - mapping. html > _ | def get_role_mapping(self, name=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role-mapping.html>`_
:arg name: Role-Mapping name
"""
return self.transport.perform_request(
"GET", _make_path("_security", "rol... |
<https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ security - api - get - token. html > _ | def get_token(self, body, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-token.html>`_
:arg body: The token request to get
"""
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument ... |
<https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ security - api - get - user. html > _ | def get_user(self, username=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user.html>`_
:arg username: A comma-separated list of usernames
"""
return self.transport.perform_request(
"GET", _make_path("_secur... |
<https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ security - api - has - privileges. html > _ | def has_privileges(self, body, user=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html>`_
:arg body: The privileges to test
:arg user: Username
"""
if body in SKIP_IN_PATH:
raise ValueErr... |
<https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ security - api - invalidate - api - key. html > _ | def invalidate_api_key(self, body, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-api-key.html>`_
:arg body: The api key request to invalidate API key(s)
"""
if body in SKIP_IN_PATH:
raise ValueError("Empty... |
<https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ security - api - invalidate - token. html > _ | def invalidate_token(self, body, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-token.html>`_
:arg body: The token to invalidate
"""
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a requi... |
<TODO > _ | def put_privileges(self, body, params=None):
"""
`<TODO>`_
:arg body: The privilege(s) to add
:arg refresh: If `true` (the default) then refresh the affected shards
to make this operation visible to search, if `wait_for` then wait
for a refresh to make this opera... |
<https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ security - api - put - user. html > _ | def put_user(self, username, body, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-user.html>`_
:arg username: The username of the User
:arg body: The user to add
:arg refresh: If `true` (the default) then refresh the affected... |
<https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ ilm - delete - lifecycle. html > _ | def delete_lifecycle(self, policy=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-delete-lifecycle.html>`_
:arg policy: The name of the index lifecycle policy
"""
return self.transport.perform_request(
"DELETE", _make_pat... |
<https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ ilm - explain - lifecycle. html > _ | def explain_lifecycle(self, index=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-explain-lifecycle.html>`_
:arg index: The name of the index to explain
"""
return self.transport.perform_request(
"GET", _make_path(index, ... |
<https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ ilm - get - lifecycle. html > _ | def get_lifecycle(self, policy=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-lifecycle.html>`_
:arg policy: The name of the index lifecycle policy
"""
return self.transport.perform_request(
"GET", _make_path("_ilm",... |
<https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ ilm - move - to - step. html > _ | def move_to_step(self, index=None, body=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-move-to-step.html>`_
:arg index: The name of the index whose lifecycle step is to change
:arg body: The new lifecycle step to move to
"""
... |
<https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ ilm - put - lifecycle. html > _ | def put_lifecycle(self, policy=None, body=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-put-lifecycle.html>`_
:arg policy: The name of the index lifecycle policy
:arg body: The lifecycle policy definition to register
"""
re... |
<https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ ilm - remove - policy. html > _ | def remove_policy(self, index=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-remove-policy.html>`_
:arg index: The name of the index to remove policy on
"""
return self.transport.perform_request(
"POST", _make_path(index... |
<https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ ilm - retry - policy. html > _ | def retry(self, index=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-retry-policy.html>`_
:arg index: The name of the indices (comma-separated) whose failed
lifecycle step is to be retry
"""
return self.transport.perform... |
<https:// www. elastic. co/ guide/ en/ x - pack/ current/ license - management. html > _ | def post(self, body=None, params=None):
"""
`<https://www.elastic.co/guide/en/x-pack/current/license-management.html>`_
:arg body: licenses to be installed
:arg acknowledge: whether the user has acknowledged acknowledge messages
(default: false)
"""
return se... |
Go through the git repository log and generate a document per commit containing all the metadata. | def parse_commits(head, name):
"""
Go through the git repository log and generate a document per commit
containing all the metadata.
"""
for commit in head.traverse():
yield {
'_id': commit.hexsha,
'repository': name,
'committed_date': datetime.fromtimesta... |
Parse a git repository with all it s commits and load it into elasticsearch using client. If the index doesn t exist it will be created. | def load_repo(client, path=None, index='git'):
"""
Parse a git repository with all it's commits and load it into elasticsearch
using `client`. If the index doesn't exist it will be created.
"""
path = dirname(dirname(abspath(__file__))) if path is None else path
repo_name = basename(path)
re... |
< > _ | def get_jobs(self, id=None, params=None):
"""
`<>`_
:arg id: The ID of the job(s) to fetch. Accepts glob patterns, or left
blank for all jobs
"""
return self.transport.perform_request(
"GET", _make_path("_rollup", "job", id), params=params
) |
< > _ | def get_rollup_caps(self, id=None, params=None):
"""
`<>`_
:arg id: The ID of the index to check rollup capabilities on, or left
blank for all jobs
"""
return self.transport.perform_request(
"GET", _make_path("_rollup", "data", id), params=params
... |
< > _ | def put_job(self, id, body, params=None):
"""
`<>`_
:arg id: The ID of the job to create
:arg body: The job configuration
"""
for param in (id, body):
if param in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument.")
... |
<http:// www. elastic. co/ guide/ en/ migration/ current/ migration - api - deprecation. html > _ | def info(self, index=None, params=None):
"""
`<http://www.elastic.co/guide/en/migration/current/migration-api-deprecation.html>`_
:arg index: Index pattern
"""
return self.transport.perform_request(
"GET",
_make_path(index, "_xpack", "migration", "depreca... |
The cluster nodes info API allows to retrieve one or more ( or all ) of the cluster nodes information. <https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ cluster - nodes - info. html > _ | def info(self, node_id=None, metric=None, params=None):
"""
The cluster nodes info API allows to retrieve one or more (or all) of
the cluster nodes information.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-info.html>`_
:arg node_id: A comma-sep... |
The cluster nodes stats API allows to retrieve one or more ( or all ) of the cluster nodes statistics. <https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ cluster - nodes - stats. html > _ | def stats(self, node_id=None, metric=None, index_metric=None, params=None):
"""
The cluster nodes stats API allows to retrieve one or more (or all) of
the cluster nodes statistics.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-stats.html>`_
:arg... |
An API allowing to get the current hot threads on each node in the cluster. <https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ cluster - nodes - hot - threads. html > _ | def hot_threads(self, node_id=None, params=None):
"""
An API allowing to get the current hot threads on each node in the cluster.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-hot-threads.html>`_
:arg node_id: A comma-separated list of node IDs or names... |
The cluster nodes usage API allows to retrieve information on the usage of features for each node. <http:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ master/ cluster - nodes - usage. html > _ | def usage(self, node_id=None, metric=None, params=None):
"""
The cluster nodes usage API allows to retrieve information on the usage
of features for each node.
`<http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-usage.html>`_
:arg node_id: A comma-separ... |
Split actions into chunks by number or size serialize them into strings in the process. | def _chunk_actions(actions, chunk_size, max_chunk_bytes, serializer):
"""
Split actions into chunks by number or size, serialize them into strings in
the process.
"""
bulk_actions, bulk_data = [], []
size, action_count = 0, 0
for action, data in actions:
raw_data, raw_action = data, ... |
Send a bulk request to elasticsearch and process the output. | def _process_bulk_chunk(
client,
bulk_actions,
bulk_data,
raise_on_exception=True,
raise_on_error=True,
*args,
**kwargs
):
"""
Send a bulk request to elasticsearch and process the output.
"""
# if raise on error is set, we need to collect errors per chunk before raising them
... |
Streaming bulk consumes actions from the iterable passed in and yields results per action. For non - streaming usecases use: func: ~elasticsearch. helpers. bulk which is a wrapper around streaming bulk that returns summary information about the bulk operation once the entire input is consumed and sent. | def streaming_bulk(
client,
actions,
chunk_size=500,
max_chunk_bytes=100 * 1024 * 1024,
raise_on_error=True,
expand_action_callback=expand_action,
raise_on_exception=True,
max_retries=0,
initial_backoff=2,
max_backoff=600,
yield_ok=True,
*args,
**kwargs
):
"""
... |
Parallel version of the bulk helper run in multiple threads at once. | def parallel_bulk(
client,
actions,
thread_count=4,
chunk_size=500,
max_chunk_bytes=100 * 1024 * 1024,
queue_size=4,
expand_action_callback=expand_action,
*args,
**kwargs
):
"""
Parallel version of the bulk helper run in multiple threads at once.
:arg client: instance of... |
Simple abstraction on top of the: meth: ~elasticsearch. Elasticsearch. scroll api - a simple iterator that yields all hits as returned by underlining scroll requests. | def scan(
client,
query=None,
scroll="5m",
raise_on_error=True,
preserve_order=False,
size=1000,
request_timeout=None,
clear_scroll=True,
scroll_kwargs=None,
**kwargs
):
"""
Simple abstraction on top of the
:meth:`~elasticsearch.Elasticsearch.scroll` api - a simple it... |
Reindex all documents from one index that satisfy a given query to another potentially ( if target_client is specified ) on a different cluster. If you don t specify the query you will reindex all the documents. | def reindex(
client,
source_index,
target_index,
query=None,
target_client=None,
chunk_size=500,
scroll="5m",
scan_kwargs={},
bulk_kwargs={},
):
"""
Reindex all documents from one index that satisfy a given query
to another, potentially (if `target_client` is specified) ... |
<https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ get - data - frame - transform. html > _ | def get_data_frame_transform(self, transform_id=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/get-data-frame-transform.html>`_
:arg transform_id: The id or comma delimited list of id expressions of
the transforms to get, '_all' or '*' impl... |
<https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ get - data - frame - transform - stats. html > _ | def get_data_frame_transform_stats(self, transform_id=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/get-data-frame-transform-stats.html>`_
:arg transform_id: The id of the transform for which to get stats.
'_all' or '*' implies all transfo... |
<https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ preview - data - frame - transform. html > _ | def preview_data_frame_transform(self, body, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/preview-data-frame-transform.html>`_
:arg body: The definition for the data_frame transform to preview
"""
if body in SKIP_IN_PATH:
raise ... |
<https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ put - data - frame - transform. html > _ | def put_data_frame_transform(self, transform_id, body, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/put-data-frame-transform.html>`_
:arg transform_id: The id of the new transform.
:arg body: The data frame transform definition
"""
... |
<https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ stop - data - frame - transform. html > _ | def stop_data_frame_transform(self, transform_id, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/stop-data-frame-transform.html>`_
:arg transform_id: The id of the transform to stop
:arg timeout: Controls the time to wait until the transform has stop... |
Allocation provides a snapshot of how shards have located around the cluster and the state of disk usage. <https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ cat - allocation. html > _ | def allocation(self, node_id=None, params=None):
"""
Allocation provides a snapshot of how shards have located around the
cluster and the state of disk usage.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-allocation.html>`_
:arg node_id: A comma-separated... |
Count provides quick access to the document count of the entire cluster or individual indices. <https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ cat - count. html > _ | def count(self, index=None, params=None):
"""
Count provides quick access to the document count of the entire cluster,
or individual indices.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-count.html>`_
:arg index: A comma-separated list of index names to ... |
The indices command provides a cross - section of each index. <https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ cat - indices. html > _ | def indices(self, index=None, params=None):
"""
The indices command provides a cross-section of each index.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-indices.html>`_
:arg index: A comma-separated list of index names to limit the returned
informati... |
recovery is a view of shard replication. <https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ cat - recovery. html > _ | def recovery(self, index=None, params=None):
"""
recovery is a view of shard replication.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-recovery.html>`_
:arg index: A comma-separated list of index names to limit the returned
information
:arg b... |
The shards command is the detailed view of what nodes contain which shards. <https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ cat - shards. html > _ | def shards(self, index=None, params=None):
"""
The shards command is the detailed view of what nodes contain which shards.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-shards.html>`_
:arg index: A comma-separated list of index names to limit the returned
... |
The segments command is the detailed view of Lucene segments per index. <https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ cat - segments. html > _ | def segments(self, index=None, params=None):
"""
The segments command is the detailed view of Lucene segments per index.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-segments.html>`_
:arg index: A comma-separated list of index names to limit the returned
... |
Get information about thread pools. <https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ cat - thread - pool. html > _ | def thread_pool(self, thread_pool_patterns=None, params=None):
"""
Get information about thread pools.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-thread-pool.html>`_
:arg thread_pool_patterns: A comma-separated list of regular-expressions
to filter... |
Shows information about currently loaded fielddata on a per - node basis. <https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ cat - fielddata. html > _ | def fielddata(self, fields=None, params=None):
"""
Shows information about currently loaded fielddata on a per-node basis.
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-fielddata.html>`_
:arg fields: A comma-separated list of fields to return the fielddata
... |
<https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ cat - templates. html > _ | def templates(self, name=None, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-templates.html>`_
:arg name: A pattern that returned template names must match
:arg format: a short version of the Accept header, e.g. json, yaml
:arg h: Comma-... |
<http:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ watcher - api - ack - watch. html > _ | def ack_watch(self, watch_id, action_id=None, params=None):
"""
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-ack-watch.html>`_
:arg watch_id: Watch ID
:arg action_id: A comma-separated list of the action ids to be acked
"""
if watch_id in ... |
<https:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ watcher - api - activate - watch. html > _ | def activate_watch(self, watch_id, params=None):
"""
`<https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-activate-watch.html>`_
:arg watch_id: Watch ID
"""
if watch_id in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argu... |
<http:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ watcher - api - delete - watch. html > _ | def delete_watch(self, id, params=None):
"""
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-delete-watch.html>`_
:arg id: Watch ID
"""
if id in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'id'.")
re... |
<http:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ watcher - api - execute - watch. html > _ | def execute_watch(self, id=None, body=None, params=None):
"""
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-execute-watch.html>`_
:arg id: Watch ID
:arg body: Execution control
:arg debug: indicates whether the watch should execute in debug mode
... |
<http:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ watcher - api - put - watch. html > _ | def put_watch(self, id, body=None, params=None):
"""
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-put-watch.html>`_
:arg id: Watch ID
:arg body: The watch
:arg active: Specify whether the watch is in/active by default
:arg if_primary_term:... |
Get a very simple status on the health of the cluster. <http:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ cluster - health. html > _ | def health(self, index=None, params=None):
"""
Get a very simple status on the health of the cluster.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html>`_
:arg index: Limit the information returned to a specific index
:arg level: Specify the le... |
Get a comprehensive state information of the whole cluster. <http:// www. elastic. co/ guide/ en/ elasticsearch/ reference/ current/ cluster - state. html > _ | def state(self, metric=None, index=None, params=None):
"""
Get a comprehensive state information of the whole cluster.
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-state.html>`_
:arg metric: Limit the information returned to the specified metrics
:arg... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.