custom_assets module¶
Custom asset classes.
class_abbr_config HybridConfig¶
Config for class name (part) abbreviations.
HybridConfig(
Accessor={
'acc'
},
Array={
'arr'
},
ArrayWrapper={
'wrapper'
},
Benchmark={
'bm'
},
Cacheable={
'ca'
},
Chunkable={
'ch'
},
Drawdowns={
'dd'
},
Jitable={
'jit'
},
Figure={
'fig'
},
MappedArray={
'ma'
},
NumPy={
'np'
},
Numba={
'nb'
},
Optimizer={
'opt'
},
Pandas={
'pd'
},
Portfolio={
'pf'
},
ProgressBar={
'pbar'
},
Registry={
'reg'
},
Returns_={
'ret'
},
Returns={
'rets'
},
QuantStats={
'qs'
},
Signals_={
'sig'
}
)
chat function¶
chat(
query,
chat_history=None,
*,
cache_documents=True,
cache_key=None,
asset_cache_manager=None,
asset_cache_manager_kwargs=None,
aggregate_messages='threads',
aggregate_messages_kwargs=None,
find_assets_kwargs=None,
rank=True,
top_k='elbow',
min_top_k=20,
max_top_k=100,
cutoff=None,
return_chunks=True,
rank_kwargs=None,
wrap_documents=True,
silence_warnings=False,
**kwargs
)
Chat about a query.
By default, uses API, documentation, and messages.
Uses find_assets with obj_or_query=None, as_query=True, and combine=True, and RankContextable.chat. Keyword arguments are distributed among these two methods automatically, unless some keys cannot be found in both signatures. In such a case, the key will be used for chatting. If this is not wanted, specify the find_assets- related arguments explicitly with find_assets_kwargs.
Metadata when aggregating messages will be minimized by default.
If cache_documents is True, will use an asset cache manager to store the generated text documents in a local and/or disk cache after conversion. Running the same method again will use the cached documents.
chat_about function¶
chat_about(
obj,
message,
chat_history=None,
*,
asset_names='examples',
latest_messages_first=True,
shuffle_messages=None,
shuffle=None,
find_assets_kwargs=None,
**kwargs
)
Chat about object(s).
By default, uses examples only.
Uses find_assets with combine=True and RankContextable.chat. Keyword arguments are distributed among these two methods automatically, unless some keys cannot be found in both signatures. In such a case, the key will be used for chatting. If this is not wanted, specify the find_assets-related arguments explicitly with find_assets_kwargs.
If shuffle is True, shuffles the combined asset. By default, shuffles only messages (shuffle=False and shuffle_messages=True). If shuffle is False, shuffles neither messages nor combined asset.
find_api function¶
find_api(
obj_or_query=None,
*,
as_query=None,
attr=None,
module=None,
resolve=True,
pages_asset=None,
pull_kwargs=None,
aggregate=False,
aggregate_kwargs=None,
**kwargs
)
Find API pages and headings relevant to object(s) or a query.
If obj_or_query is None, returns all API pages. If it's a reference to an object, uses PagesAsset.find_obj_api. Otherwise, uses VBTAsset.rank.
find_assets function¶
find_assets(
obj_or_query=None,
*,
as_query=None,
attr=None,
module=None,
resolve=True,
asset_names=None,
pages_asset=None,
messages_asset=None,
pull_kwargs=None,
aggregate_pages=False,
aggregate_pages_kwargs=None,
aggregate_messages='messages',
aggregate_messages_kwargs=None,
latest_messages_first=False,
shuffle_messages=False,
api_kwargs=None,
docs_kwargs=None,
messages_kwargs=None,
examples_kwargs=None,
minimize=None,
minimize_pages=None,
minimize_messages=None,
minimize_kwargs=None,
minimize_pages_kwargs=None,
minimize_messages_kwargs=None,
combine=True,
combine_kwargs=None,
**kwargs
)
Find all assets relevant to object(s) or a query.
Argument asset_names can be a list of asset names in any order. It defaults to "api", "docs", and "messages", It can also include ellipsis (...). For example, ["messages", ...] puts "messages" at the beginning and all other assets in their usual order at the end. The following asset names are supported:
- "api": find_api with
api_kwargs - "docs": find_docs with
docs_kwargs - "messages": find_messages with
messages_kwargs - "examples": find_examples with
examples_kwargs - "all": All of the above
Note
Examples usually overlap with other assets, thus they are excluded by default.
Set combine to True to combine all assets into a single asset. Uses KnowledgeAsset.combine with combine_kwargs. If obj_or_query is a query, will rank the combined asset. Otherwise, will rank each individual asset.
Set minimize to True (or minimize_pages for pages and minimize_messages for messages) in order to minimize to remove fields that aren't relevant for chatting. It defaults to True if combine is True, otherwise, it defaults to False. Uses VBTAsset.minimize with minimize_kwargs, VBTAsset.minimize with minimize_pages_kwargs, and VBTAsset.minimize with minimize_messages_kwargs. Arguments minimize_pages_kwargs and minimize_messages_kwargs are merged over minimize_kwargs.
Keyword arguments are passed to all functions (except for find_api when obj_or_query is an object since it doesn't share common arguments with other three functions), unless combine and as_query are both True; in this case they are passed to VBTAsset.rank. Use specialized arguments like api_kwargs to provide keyword arguments to the respective function.
find_docs function¶
find_docs(
obj_or_query=None,
*,
as_query=None,
attr=None,
module=None,
resolve=True,
pages_asset=None,
pull_kwargs=None,
aggregate=False,
aggregate_kwargs=None,
**kwargs
)
Find documentation pages and headings relevant to object(s) or a query.
If obj_or_query is None, returns all documentation pages. If it's a reference to an object, uses PagesAsset.find_obj_docs. Otherwise, uses VBTAsset.rank.
find_examples function¶
find_examples(
obj_or_query=None,
*,
as_query=None,
attr=None,
module=None,
resolve=True,
as_code=True,
return_type='field',
pages_asset=None,
messages_asset=None,
pull_kwargs=None,
aggregate_pages=False,
aggregate_pages_kwargs=None,
aggregate_messages='messages',
aggregate_messages_kwargs=None,
latest_messages_first=False,
shuffle_messages=False,
find_kwargs=None,
**kwargs
)
Find (code) examples relevant to object(s) or a query.
If obj_or_query is None, returns all examples with KnowledgeAsset.find_code or KnowledgeAsset.find. If it's a reference to an object, uses VBTAsset.find_obj_mentions. Otherwise, uses KnowledgeAsset.find_code or KnowledgeAsset.find and then VBTAsset.rank. Keyword arguments are distributed among these methods automatically, unless some keys cannot be found in both signatures. In such a case, the key will be used for ranking. If this is not wanted, specify find_kwargs.
By default, extracts code with text. Use return_type="match" to extract code without text, or, for instance, return_type="item" to also get links.
find_messages function¶
find_messages(
obj_or_query=None,
*,
as_query=None,
attr=None,
module=None,
resolve=True,
messages_asset=None,
pull_kwargs=None,
aggregate='messages',
aggregate_kwargs=None,
latest_first=False,
shuffle=False,
**kwargs
)
Find messages relevant to object(s) or a query.
If obj_or_query is None, returns all messages. If it's a reference to an object, uses MessagesAsset.find_obj_messages. Otherwise, uses VBTAsset.rank.
is_obj_or_query_ref function¶
Return whether obj_or_query is a reference to an object.
search function¶
search(
query,
cache_documents=True,
cache_key=None,
asset_cache_manager=None,
asset_cache_manager_kwargs=None,
aggregate_messages='threads',
aggregate_messages_kwargs=None,
find_assets_kwargs=None,
display=20,
display_kwargs=None,
silence_warnings=False,
**kwargs
)
Search for a query.
By default, uses API, documentation, and messages.
Uses find_assets with combine=True and KnowledgeAsset.rank. Keyword arguments are distributed among these two methods automatically, unless some keys cannot be found in both signatures. In such a case, the key will be used for ranking. If this is not wanted, specify the find_assets-related arguments explicitly with find_assets_kwargs.
If display is True, displays the top results as static HTML pages with VBTAsset.display. Pass an integer to display n top results. Will return the path to the temporary file.
Metadata when aggregating messages will be minimized by default.
If cache_documents is True, will use an asset cache manager to store the generated text documents in a local and/or disk cache after conversion. Running the same method again will use the cached documents.
MessagesAsset class¶
Class for working with Discord messages.
Each message has the following fields:
link: URL of the message, such as "https://discord.com/channels/918629562441695344/919715148896301067/923327319882485851" block: URL of the first message in the block. A block is a bunch of messages of the same author that either reference a message of another author, or don't reference any message at all. thread: URL of the first message in the thread. A thread is a bunch of blocks that reference each other in a chain, such as questions, answers, follow-up questions, etc. reference: URL of the message that the message references. Can be None. replies: List of URLs of the messages that reference the message channel: Channel of the message, such as "support" timestamp: Timestamp of the message, such as "2024-01-01 00:00:00" author: Author of the message, such as "@polakowo" content: String content of the message mentions: List of Discord usernames that this message mentions, such as ["@polakowo"] attachments: List of attachments. Each attachment has two fields: "file_name", such as "some_image.png", and "content" containing the string content extracted from the file. reactions: Total number of reactions that this message has received
For defaults, see assets.messages in knowledge.
Superclasses
- Base
- Cacheable
- Chainable
- Comparable
- Configured
- Contextable
- HasSettings
- KnowledgeAsset
- Pickleable
- Prettified
- RankContextable
- Rankable
- VBTAsset
collections.abc.Collectioncollections.abc.Containercollections.abc.Iterablecollections.abc.MutableSequencecollections.abc.Reversiblecollections.abc.Sequencecollections.abc.Sized
Inherited members
- Base.find_api
- Base.find_assets
- Base.find_docs
- Base.find_examples
- Base.find_messages
- Cacheable.get_ca_setup
- Chainable.chain
- Chainable.pipe
- Configured.copy
- Configured.equals
- Configured.get_writeable_attrs
- Configured.prettify
- Configured.replace
- Configured.resolve_merge_kwargs
- Configured.update_config
- Contextable.count_tokens
- HasSettings.get_path_setting
- HasSettings.get_path_settings
- HasSettings.get_setting
- HasSettings.get_settings
- HasSettings.has_path_setting
- HasSettings.has_path_settings
- HasSettings.has_setting
- HasSettings.has_settings
- HasSettings.reset_settings
- HasSettings.resolve_setting
- HasSettings.resolve_settings_paths
- HasSettings.set_settings
- KnowledgeAsset.append_item
- KnowledgeAsset.apply
- KnowledgeAsset.collect
- KnowledgeAsset.combine
- KnowledgeAsset.delete_items
- KnowledgeAsset.describe
- KnowledgeAsset.describe_lengths
- KnowledgeAsset.dump
- KnowledgeAsset.dump_all
- KnowledgeAsset.extend_items
- KnowledgeAsset.filter
- KnowledgeAsset.find
- KnowledgeAsset.find_code
- KnowledgeAsset.find_remove
- KnowledgeAsset.find_remove_empty
- KnowledgeAsset.find_replace
- KnowledgeAsset.flatten
- KnowledgeAsset.from_json_bytes
- KnowledgeAsset.from_json_file
- KnowledgeAsset.get
- KnowledgeAsset.get_items
- KnowledgeAsset.get_keys_and_groups
- KnowledgeAsset.groupby_reduce
- KnowledgeAsset.insert
- KnowledgeAsset.join
- KnowledgeAsset.merge
- KnowledgeAsset.merge_dicts
- KnowledgeAsset.merge_lists
- KnowledgeAsset.modify_data
- KnowledgeAsset.move
- KnowledgeAsset.print
- KnowledgeAsset.print_sample
- KnowledgeAsset.print_schema
- KnowledgeAsset.query
- KnowledgeAsset.reduce
- KnowledgeAsset.remove
- KnowledgeAsset.remove_empty
- KnowledgeAsset.rename
- KnowledgeAsset.reorder
- KnowledgeAsset.sample
- KnowledgeAsset.select
- KnowledgeAsset.set
- KnowledgeAsset.set_items
- KnowledgeAsset.shuffle
- KnowledgeAsset.sort
- KnowledgeAsset.split_text
- KnowledgeAsset.to_context
- KnowledgeAsset.to_documents
- KnowledgeAsset.unflatten
- KnowledgeAsset.unique
- Pickleable.decode_config
- Pickleable.decode_config_node
- Pickleable.dumps
- Pickleable.encode_config
- Pickleable.encode_config_node
- Pickleable.file_exists
- Pickleable.getsize
- Pickleable.load
- Pickleable.loads
- Pickleable.modify_state
- Pickleable.resolve_file_path
- Pickleable.save
- Prettified.pprint
- VBTAsset.browse
- VBTAsset.chat
- VBTAsset.config
- VBTAsset.create_chat
- VBTAsset.data
- VBTAsset.display
- VBTAsset.embed
- VBTAsset.find_link
- VBTAsset.find_obj_mentions
- VBTAsset.generate_mention_targets
- VBTAsset.generate_refname_targets
- VBTAsset.get_class_abbrs
- VBTAsset.get_top_parent_links
- VBTAsset.links_to_paths
- VBTAsset.merge_mention_targets
- VBTAsset.minimize
- VBTAsset.minimize_link
- VBTAsset.minimize_links
- VBTAsset.prepare_mention_target
- VBTAsset.pull
- VBTAsset.rank
- VBTAsset.rec_state
- VBTAsset.release_name
- VBTAsset.replace_urls_in_html
- VBTAsset.resolve_spec_settings_path
- VBTAsset.save_to_html
- VBTAsset.save_to_markdown
- VBTAsset.select_next
- VBTAsset.select_previous
- VBTAsset.single_item
- VBTAsset.split_class_name
- VBTAsset.to_html
- VBTAsset.to_markdown
- VBTAsset.top_parent_links
aggregate method¶
Aggregate by "message" (attachments), "block", "thread", or "channel".
If by is None, uses MessagesAsset.lowest_aggregate_by.
aggregate_blocks method¶
MessagesAsset.aggregate_blocks(
collect_kwargs=None,
aggregate_fields=None,
parent_links_only=None,
minimize_metadata=None,
minimize_keys=None,
clean_metadata=None,
clean_metadata_kwargs=None,
dump_metadata_kwargs=None,
to_markdown_kwargs=None,
**kwargs
)
Aggregate messages by block.
First, uses KnowledgeAsset.reduce on CollectAssetFunc to collect data items by the field "block". Keyword arguments in collect_kwargs are passed here. Argument uniform_groups is True by default. Then, uses KnowledgeAsset.apply on AggBlockAssetFunc to aggregate each collected data item.
Use aggregate_fields to provide a set of fields to be aggregated rather than used in child metadata. It can be True to aggregate all lists and False to aggregate none.
If parent_links_only is True, doesn't include links in the metadata of each message.
For other keyword arguments, see VBTAsset.to_markdown.
aggregate_channels method¶
MessagesAsset.aggregate_channels(
collect_kwargs=None,
aggregate_fields=None,
parent_links_only=None,
minimize_metadata=None,
minimize_keys=None,
clean_metadata=None,
clean_metadata_kwargs=None,
dump_metadata_kwargs=None,
to_markdown_kwargs=None,
**kwargs
)
Aggregate messages by channel.
Same as MessagesAsset.aggregate_threads but for channels.
Uses AggChannelAssetFunc.
aggregate_messages method¶
MessagesAsset.aggregate_messages(
minimize_metadata=None,
minimize_keys=None,
clean_metadata=None,
clean_metadata_kwargs=None,
dump_metadata_kwargs=None,
to_markdown_kwargs=None,
**kwargs
)
Aggregate attachments by message.
For keyword arguments, see VBTAsset.to_markdown.
Uses KnowledgeAsset.apply on AggMessageAssetFunc.
aggregate_threads method¶
MessagesAsset.aggregate_threads(
collect_kwargs=None,
aggregate_fields=None,
parent_links_only=None,
minimize_metadata=None,
minimize_keys=None,
clean_metadata=None,
clean_metadata_kwargs=None,
dump_metadata_kwargs=None,
to_markdown_kwargs=None,
**kwargs
)
Aggregate messages by thread.
Same as MessagesAsset.aggregate_blocks but for threads.
Uses AggThreadAssetFunc.
find_obj_messages method¶
Find messages relevant to object(s).
Uses VBTAsset.find_obj_mentions.
highest_aggregate_by class property¶
Get the highest level that aggregates all messages.
latest_first method¶
Sort by timestamp in descending order.
lowest_aggregate_by class property¶
Get the lowest level that aggregates all messages.
select_block method¶
Select the messages that belong to the block of a link.
select_channel method¶
Select the messages that belong to the channel of a link.
select_reference method¶
Select the reference message.
select_replies method¶
Select the reply messages.
select_thread method¶
Select the messages that belong to the thread of a link.
MultipleItemsFoundError class¶
Exception raised when multiple data items were found.
Superclasses
builtins.BaseExceptionbuiltins.Exception
NoItemFoundError class¶
Exception raised when no data item was found.
Superclasses
builtins.BaseExceptionbuiltins.Exception
PagesAsset class¶
Class for working with website pages.
Has the following fields:
- link: URL of the page (without fragment), such as "https://vectorbt.pro/features/data/", or URL of the heading (with fragment), such as "https://vectorbt.pro/features/data/#trading-view"
- parent: URL of the parent page or heading. For example, a heading 1 is a parent of a heading 2.
- children: List of URLs of the child pages and/or headings. For example, a heading 2 is a child of a heading 1.
- name: Name of the page or heading. Within the API, the name of the object that the heading represents, such as "Portfolio.from_signals".
- type: Type of the page or heading, such as "page", "heading 1", "heading 2", etc.
- icon: Icon, such as "material-brain"
- tags: List of tags, such as ["portfolio", "records"]
- content: String content of the page or heading. Can be None in pages that solely redirect.
- obj_type: Within the API, the type of the object that the heading represents, such as "property"
- github_link: Within the API, the URL to the source code of the object that the heading represents
For defaults, see assets.pages in knowledge.
Superclasses
- Base
- Cacheable
- Chainable
- Comparable
- Configured
- Contextable
- HasSettings
- KnowledgeAsset
- Pickleable
- Prettified
- RankContextable
- Rankable
- VBTAsset
collections.abc.Collectioncollections.abc.Containercollections.abc.Iterablecollections.abc.MutableSequencecollections.abc.Reversiblecollections.abc.Sequencecollections.abc.Sized
Inherited members
- Base.find_api
- Base.find_assets
- Base.find_docs
- Base.find_examples
- Base.find_messages
- Cacheable.get_ca_setup
- Chainable.chain
- Chainable.pipe
- Configured.copy
- Configured.equals
- Configured.get_writeable_attrs
- Configured.prettify
- Configured.replace
- Configured.resolve_merge_kwargs
- Configured.update_config
- Contextable.count_tokens
- HasSettings.get_path_setting
- HasSettings.get_path_settings
- HasSettings.get_setting
- HasSettings.get_settings
- HasSettings.has_path_setting
- HasSettings.has_path_settings
- HasSettings.has_setting
- HasSettings.has_settings
- HasSettings.reset_settings
- HasSettings.resolve_setting
- HasSettings.resolve_settings_paths
- HasSettings.set_settings
- KnowledgeAsset.append_item
- KnowledgeAsset.apply
- KnowledgeAsset.collect
- KnowledgeAsset.combine
- KnowledgeAsset.delete_items
- KnowledgeAsset.describe
- KnowledgeAsset.describe_lengths
- KnowledgeAsset.dump
- KnowledgeAsset.dump_all
- KnowledgeAsset.extend_items
- KnowledgeAsset.filter
- KnowledgeAsset.find
- KnowledgeAsset.find_code
- KnowledgeAsset.find_remove
- KnowledgeAsset.find_remove_empty
- KnowledgeAsset.find_replace
- KnowledgeAsset.flatten
- KnowledgeAsset.from_json_bytes
- KnowledgeAsset.from_json_file
- KnowledgeAsset.get
- KnowledgeAsset.get_items
- KnowledgeAsset.get_keys_and_groups
- KnowledgeAsset.groupby_reduce
- KnowledgeAsset.insert
- KnowledgeAsset.join
- KnowledgeAsset.merge
- KnowledgeAsset.merge_dicts
- KnowledgeAsset.merge_lists
- KnowledgeAsset.modify_data
- KnowledgeAsset.move
- KnowledgeAsset.print
- KnowledgeAsset.print_sample
- KnowledgeAsset.print_schema
- KnowledgeAsset.query
- KnowledgeAsset.reduce
- KnowledgeAsset.remove
- KnowledgeAsset.remove_empty
- KnowledgeAsset.rename
- KnowledgeAsset.reorder
- KnowledgeAsset.sample
- KnowledgeAsset.select
- KnowledgeAsset.set
- KnowledgeAsset.set_items
- KnowledgeAsset.shuffle
- KnowledgeAsset.sort
- KnowledgeAsset.split_text
- KnowledgeAsset.to_context
- KnowledgeAsset.to_documents
- KnowledgeAsset.unflatten
- KnowledgeAsset.unique
- Pickleable.decode_config
- Pickleable.decode_config_node
- Pickleable.dumps
- Pickleable.encode_config
- Pickleable.encode_config_node
- Pickleable.file_exists
- Pickleable.getsize
- Pickleable.load
- Pickleable.loads
- Pickleable.modify_state
- Pickleable.resolve_file_path
- Pickleable.save
- Prettified.pprint
- VBTAsset.browse
- VBTAsset.chat
- VBTAsset.config
- VBTAsset.create_chat
- VBTAsset.data
- VBTAsset.display
- VBTAsset.embed
- VBTAsset.find_link
- VBTAsset.find_obj_mentions
- VBTAsset.generate_mention_targets
- VBTAsset.generate_refname_targets
- VBTAsset.get_class_abbrs
- VBTAsset.get_top_parent_links
- VBTAsset.links_to_paths
- VBTAsset.merge_mention_targets
- VBTAsset.minimize
- VBTAsset.minimize_link
- VBTAsset.minimize_links
- VBTAsset.prepare_mention_target
- VBTAsset.pull
- VBTAsset.rank
- VBTAsset.rec_state
- VBTAsset.release_name
- VBTAsset.replace_urls_in_html
- VBTAsset.resolve_spec_settings_path
- VBTAsset.save_to_html
- VBTAsset.save_to_markdown
- VBTAsset.select_next
- VBTAsset.select_previous
- VBTAsset.single_item
- VBTAsset.split_class_name
- VBTAsset.to_html
- VBTAsset.to_markdown
- VBTAsset.top_parent_links
aggregate method¶
Aggregate pages.
Content of each heading will be converted into markdown and concatenated into the content of the parent heading or page. Only regular pages and headings without parents will be left.
If append_obj_type is True, will also append object type to the heading name. If append_github_link is True, will also append GitHub link to the heading name.
aggregate_links method¶
Aggregate links by removing redundant ones.
Only headings are aggregated.
descend_links method¶
Descend links by removing redundant ones.
Only headings are descended.
find_obj method¶
Find the page corresponding a single (internal) object or reference name.
Prepares the reference with prepare_refname.
find_obj_api method¶
PagesAsset.find_obj_api(
obj,
*,
attr=None,
module=None,
resolve=True,
use_parent=None,
use_base_parents=None,
use_ref_parents=None,
incl_bases=None,
incl_ancestors=None,
incl_base_ancestors=None,
incl_refs=None,
incl_descendants=None,
incl_ancestor_descendants=None,
incl_ref_descendants=None,
aggregate=None,
aggregate_ancestors=None,
aggregate_refs=None,
aggregate_kwargs=None,
topo_sort=None,
return_refname_graph=False
)
Find API pages and headings relevant to object(s).
Prepares the object reference with prepare_refname.
If incl_bases is True, extends the asset with the base classes/attributes if the object is a class/attribute. For instance, Portfolio has Analyzable as one of its base classes. It can also be an integer indicating the maximum inheritance level. If obj is a module, then bases are sub-modules.
If incl_ancestors is True, extends the asset with the ancestors of the object. For instance, Portfolio has vectorbtpro.portfolio.base as its ancestor. It can also be an integer indicating the maximum inheritance level. Provide incl_base_ancestors to override incl_ancestors for base classes/attributes.
If incl_refs is True, extends the asset with the references found in the content of the object. It can also be an integer indicating the maximum reference level. Defaults to False for modules and classes, and True otherwise. If resolution of reference names is disabled, defaults to False.
If incl_descendants is True, extends the asset page or heading with any descendant headings. Provide incl_ancestor_descendants and incl_ref_descendants to override incl_descendants for ancestors and references respectively.
If aggregate is True, aggregates any descendant headings into pages for this object and all base classes/attributes. Provide aggregate_ancestors and aggregate_refs to override aggregate for ancestors and references respectively.
If topo_sort is True, creates a topological graph from all reference names and sorts pages and headings based on this graph. Use return_refname_graph to True to also return the graph.
find_obj_docs method¶
PagesAsset.find_obj_docs(
obj,
*,
attr=None,
module=None,
resolve=True,
incl_pages=None,
excl_pages=None,
page_find_mode=None,
up_aggregate=None,
up_aggregate_th=None,
up_aggregate_pages=None,
aggregate=None,
aggregate_kwargs=None,
**kwargs
)
Find documentation relevant to object(s).
If a link matches one of the links or link parts in incl_pages, it will be included, otherwise, it will be excluded if incl_pages is not empty. If a link matches one of the links or link parts in excl_pages, it will be excluded, otherwise, it will be included. Matching is done using find with page_find_mode used as mode. For example, using excl_pages=["release-notes"] won't search in release notes.
If up_aggregate is True, will aggregate each set of headings into their parent if their number is greater than some threshold up_aggregate_th, which depends on the total number of headings in the parent. It can be an integer for absolute number or float for relative number. For example, up_aggregate_th=2/3 means this method must find 2 headings out of 3 in order to replace it by the full parent heading/page. If up_aggregate_pages is True, does the same to pages. For example, if 2 tutorial pages out of 3 are matched, the whole tutorial series is used.
If aggregate is True, aggregates any descendant headings into pages for this object and all base classes/attributes using PagesAsset.aggregate_links.
Uses VBTAsset.find_obj_mentions.
find_page method¶
PagesAsset.find_page(
link,
aggregate=False,
aggregate_kwargs=None,
incl_descendants=False,
single_item=True,
**kwargs
)
Find the page(s) corresponding to link(s).
Keyword arguments are passed to VBTAsset.find_link.
find_refname method¶
Find the page corresponding to a reference.
is_link_module class method¶
Return whether a link is a module.
parse_content_links class method¶
Parse all links from a content.
parse_link_refname class method¶
Parse the reference name from a link.
print_site_schema method¶
PagesAsset.print_site_schema(
append_type=False,
append_obj_type=False,
structure_fragments=True,
split_fragments=True,
**dir_tree_kwargs
)
Print site schema.
If structure_fragments is True, builds a hierarchy of fragments. Otherwise, displays them on the same level.
If split_fragments is True, displays fragments as continuation of their parents. Otherwise, displays them in full length.
Keyword arguments are split between KnowledgeAsset.describe and dir_tree_from_paths.
select_ancestors method¶
Select all ancestor pages of a link.
select_branch method¶
Select all descendant pages of a link including the link.
select_children method¶
Select the child pages of a link.
select_descendant_headings method¶
Select descendant headings.
select_descendants method¶
Select all descendant pages of a link.
select_parent method¶
Select the parent page of a link.
select_parent_page method¶
Select parent page.
select_siblings method¶
Select the sibling pages of a link.
VBTAsset class¶
Class for working with VBT content.
For defaults, see assets.vbt in knowledge.
Superclasses
- Base
- Cacheable
- Chainable
- Comparable
- Configured
- Contextable
- HasSettings
- KnowledgeAsset
- Pickleable
- Prettified
- RankContextable
- Rankable
collections.abc.Collectioncollections.abc.Containercollections.abc.Iterablecollections.abc.MutableSequencecollections.abc.Reversiblecollections.abc.Sequencecollections.abc.Sized
Inherited members
- Base.find_api
- Base.find_assets
- Base.find_docs
- Base.find_examples
- Base.find_messages
- Cacheable.get_ca_setup
- Chainable.chain
- Chainable.pipe
- Configured.copy
- Configured.equals
- Configured.get_writeable_attrs
- Configured.prettify
- Configured.replace
- Configured.resolve_merge_kwargs
- Configured.update_config
- Contextable.count_tokens
- Contextable.create_chat
- HasSettings.get_path_setting
- HasSettings.get_path_settings
- HasSettings.get_setting
- HasSettings.get_settings
- HasSettings.has_path_setting
- HasSettings.has_path_settings
- HasSettings.has_setting
- HasSettings.has_settings
- HasSettings.reset_settings
- HasSettings.resolve_setting
- HasSettings.resolve_settings_paths
- HasSettings.set_settings
- KnowledgeAsset.append_item
- KnowledgeAsset.apply
- KnowledgeAsset.collect
- KnowledgeAsset.combine
- KnowledgeAsset.config
- KnowledgeAsset.data
- KnowledgeAsset.delete_items
- KnowledgeAsset.describe
- KnowledgeAsset.describe_lengths
- KnowledgeAsset.dump
- KnowledgeAsset.dump_all
- KnowledgeAsset.embed
- KnowledgeAsset.extend_items
- KnowledgeAsset.filter
- KnowledgeAsset.find
- KnowledgeAsset.find_code
- KnowledgeAsset.find_remove
- KnowledgeAsset.find_remove_empty
- KnowledgeAsset.find_replace
- KnowledgeAsset.flatten
- KnowledgeAsset.from_json_bytes
- KnowledgeAsset.from_json_file
- KnowledgeAsset.get
- KnowledgeAsset.get_items
- KnowledgeAsset.get_keys_and_groups
- KnowledgeAsset.groupby_reduce
- KnowledgeAsset.insert
- KnowledgeAsset.join
- KnowledgeAsset.merge
- KnowledgeAsset.merge_dicts
- KnowledgeAsset.merge_lists
- KnowledgeAsset.modify_data
- KnowledgeAsset.move
- KnowledgeAsset.print
- KnowledgeAsset.print_sample
- KnowledgeAsset.print_schema
- KnowledgeAsset.query
- KnowledgeAsset.rank
- KnowledgeAsset.rec_state
- KnowledgeAsset.reduce
- KnowledgeAsset.remove
- KnowledgeAsset.remove_empty
- KnowledgeAsset.rename
- KnowledgeAsset.reorder
- KnowledgeAsset.sample
- KnowledgeAsset.select
- KnowledgeAsset.set
- KnowledgeAsset.set_items
- KnowledgeAsset.shuffle
- KnowledgeAsset.single_item
- KnowledgeAsset.sort
- KnowledgeAsset.split_text
- KnowledgeAsset.to_context
- KnowledgeAsset.to_documents
- KnowledgeAsset.unflatten
- KnowledgeAsset.unique
- Pickleable.decode_config
- Pickleable.decode_config_node
- Pickleable.dumps
- Pickleable.encode_config
- Pickleable.encode_config_node
- Pickleable.file_exists
- Pickleable.getsize
- Pickleable.load
- Pickleable.loads
- Pickleable.modify_state
- Pickleable.resolve_file_path
- Pickleable.save
- Prettified.pprint
- RankContextable.chat
Subclasses
browse method¶
Browse one or more HTML pages.
Opens the web browser. Also, returns the path of the directory where HTML files are stored.
Use entry_link to specify the link of the page that should be displayed first. If entry_link is None and there are multiple top-level parents, displays them as an index. If it's not None, it will be matched using VBTAsset.find_link and find_kwargs.
Keyword arguments are passed to VBTAsset.save_to_html.
display method¶
VBTAsset.display(
link=None,
find_kwargs=None,
open_browser=None,
html_template=None,
style_extras=None,
head_extras=None,
body_extras=None,
invert_colors=None,
title='',
template_context=None,
**kwargs
)
Display as an HTML page.
If there are multiple HTML pages, shows them as iframes inside a parent HTML page with pagination. For this, uses FormatHTML.
Opens the web browser. Also, returns the path of the temporary HTML file.
Note
The file won't be deleted automatically.
find_link method¶
VBTAsset.find_link(
link,
mode='end',
per_path=False,
single_item=True,
consolidate=True,
allow_empty=False,
**kwargs
)
Find item(s) corresponding to link(s).
find_obj_mentions method¶
VBTAsset.find_obj_mentions(
obj,
*,
attr=None,
module=None,
resolve=True,
incl_shortcuts=None,
incl_shortcut_access=None,
incl_shortcut_call=None,
incl_instances=None,
incl_custom=None,
is_custom_regex=False,
as_code=None,
as_regex=None,
allow_prefix=None,
allow_suffix=None,
merge_targets=None,
per_path=False,
path='content',
return_type='item',
**kwargs
)
Find mentions of a VBT object.
Generates mention targets with VBTAsset.generate_mention_targets.
Provide custom mentions in incl_custom. If regular expressions are provided, set is_custom_regex to True.
If as_code is True, uses KnowledgeAsset.find_code, otherwise, uses KnowledgeAsset.find.
If as_regex is True, search is refined by using regular expressions. For instance, vbt.PF may match vbt.PFO if RegEx is not used.
If merge_targets, uses VBTAsset.merge_mention_targets to reduce the number of targets. Sets as_regex to True if False (but after the targets were generated).
generate_mention_targets method¶
VBTAsset.generate_mention_targets(
obj,
*,
attr=None,
module=None,
resolve=True,
incl_base_attr=None,
incl_shortcuts=None,
incl_shortcut_access=None,
incl_shortcut_call=None,
incl_instances=None,
as_code=None,
as_regex=None,
allow_prefix=None,
allow_suffix=None
)
Generate mention targets.
Prepares the object reference with prepare_refname. If an attribute is provided, checks whether the attribute is defined by the object itself or by one of its base classes. If the latter and incl_base_attr is True, generates reference name targets for both the object attribute and the base class attribute.
Generates reference name targets with VBTAsset.generate_refname_targets.
generate_refname_targets class method¶
VBTAsset.generate_refname_targets(
refname,
resolve=True,
incl_shortcuts=None,
incl_shortcut_access=None,
incl_shortcut_call=None,
incl_instances=None,
as_code=None,
as_regex=None,
allow_prefix=None,
allow_suffix=None
)
Generate reference name targets.
If incl_shortcuts is True, includes shortcuts found in import vectorbtpro as vbt. In addition, if incl_shortcut_access is True and the object is a class or module, includes a version with attribute access, and if incl_shortcut_call is True and the object is callable, includes a version that is being called.
If incl_instances is True, includes typical short names of classes, which include the snake-cased class name and mapped name parts found in class_abbr_config.
Prepares each mention target with VBTAsset.prepare_mention_target.
get_class_abbrs class method¶
Convert a class name to snake case and its abbreviated versions.
get_top_parent_links class method¶
Get links of top parents in data.
links_to_paths class method¶
Convert links to corresponding paths.
merge_mention_targets class method¶
Merge mention targets into a single regular expression.
minimize method¶
Minimize by keeping the most useful information.
If minimize_links is True, replaces redundant URL prefixes by templates that can be easily substituted later.
minimize_link class method¶
Minimize a single link.
minimize_links method¶
Minimize links.
prepare_mention_target class method¶
VBTAsset.prepare_mention_target(
target,
as_code=False,
as_regex=True,
allow_prefix=False,
allow_suffix=False
)
Prepare a mention target.
pull class method¶
VBTAsset.pull(
release_name=None,
asset_name=None,
repo_owner=None,
repo_name=None,
token=None,
token_required=None,
use_pygithub=None,
chunk_size=None,
cache=None,
cache_dir=None,
cache_mkdir_kwargs=None,
clear_cache=None,
show_progress=None,
pbar_kwargs=None,
template_context=None,
**kwargs
)
Build VBTAsset from a JSON asset of a release.
Examples of a release name include None or 'current' for the current release, 'latest' for the latest release, and any other tag name such as 'v2024.12.15'.
An example of an asset file name is 'messages.json.zip'. You can find all asset file names at https://github.com/polakowo/vectorbt.pro/releases/latest
Token must be a valid GitHub token. It doesn't have to be provided if the asset has already been downloaded.
If use_pygithub is True, uses https://github.com/PyGithub/PyGithub (otherwise requests)
Argument chunk_size denotes the number of bytes in each chunk when downloading an asset file.
If cache is True, uses the cache directory (assets_dir in settings). Otherwise, builds the asset instance in memory. If clear_cache is True, deletes any existing directory before creating a new one.
release_name class property¶
Release name.
replace_urls_in_html class method¶
Replace URLs in attributes based on a provided mapping.
resolve_spec_settings_path class method¶
Resolve specialized settings paths.
save_to_html method¶
VBTAsset.save_to_html(
cache=None,
cache_dir=None,
cache_mkdir_kwargs=None,
clear_cache=None,
show_progress=None,
pbar_kwargs=None,
template_context=None,
return_url_map=False,
**kwargs
)
Save to HTML files.
Opens the web browser. Also, returns the path of the directory where HTML files are stored, and if return_url_map is True also returns the link->file map.
In addition, if there are multiple top-level parents, creates an index page.
If cache is True, uses the cache directory (html_dir in settings). Otherwise, creates a temporary directory. If clear_cache is True, deletes any existing directory before creating a new one.
Keyword arguments are passed to ToHTMLAssetFunc.
save_to_markdown method¶
VBTAsset.save_to_markdown(
cache=None,
cache_dir=None,
cache_mkdir_kwargs=None,
clear_cache=None,
show_progress=None,
pbar_kwargs=None,
template_context=None,
**kwargs
)
Save to Markdown files.
If cache is True, uses the cache directory (markdown_dir in settings). Otherwise, creates a temporary directory. If clear_cache is True, deletes any existing directory before creating a new one. Returns the path of the directory where Markdown files are stored.
Keyword arguments are passed to ToMarkdownAssetFunc.
Last keyword arguments in kwargs are passed to to_markdown.
select_next method¶
Select the next data item.
select_previous method¶
Select the previous data item.
split_class_name class method¶
Split a class name constituent parts.
to_html method¶
VBTAsset.to_html(
root_metadata_key=None,
clean_metadata=None,
clean_metadata_kwargs=None,
dump_metadata_kwargs=None,
to_markdown_kwargs=None,
format_html_kwargs=None,
**kwargs
)
Convert to HTML.
Uses KnowledgeAsset.apply on ToHTMLAssetFunc.
Arguments in format_html_kwargs are passed to format_html.
Last keyword arguments in kwargs are passed to to_html.
For other arguments, see VBTAsset.to_markdown.
to_markdown method¶
VBTAsset.to_markdown(
root_metadata_key=None,
clean_metadata=None,
clean_metadata_kwargs=None,
dump_metadata_kwargs=None,
**kwargs
)
Convert to Markdown.
Uses KnowledgeAsset.apply on ToMarkdownAssetFunc.
Use root_metadata_key to provide the root key for the metadata markdown.
If clean_metadata is True, removes empty fields from the metadata. Arguments in clean_metadata_kwargs are passed to FindRemoveAssetFunc, while dump_metadata_kwargs are passed to DumpAssetFunc.
Last keyword arguments in kwargs are passed to to_markdown.
top_parent_links class property¶
Get links of top parents.