Hi, I am a new comer of rally.
I created a customized track trademark_multi, before I created track.py file, it worked well.
After I created track.py for vary parameter, it cannot work again.
Here are the files I created:
track.json:
{% import "rally.helpers" as rally with context %}
{
"version": 2,
"description": "Tracker-generated track for trademark_multi",
"indices": [
{
"name": "trademark_multi",
"body": "trademark_multi.json",
"types": ["doc"]
}
],
"corpora": [
{
"name": "trademark_multi",
"documents": [
{
"source-file": "trademark_multi-documents.json",
"document-count": 155836,
"uncompressed-bytes": 4008659147
}
]
}
],
"operations": [
{{ rally.collect(parts="operations/*.json") }}
],
"challenges": [
{{ rally.collect(parts="challenges/*.json") }}
]
}
track.py:
import random
import os
import csv
class QueryParamSource:
# We need to stick to the param source API
# noinspection PyUnusedLocal
def __init__(self, track, params, **kwargs):
self._params = params
self.infinite = True
# here we read the queries data file into arrays which we'll then later use randomly.
self.features = []
# be predictably random. The seed has been chosen by a fair dice roll. ;)
random.seed(4)
cwd = os.path.dirname(__file__)
with open(os.path.join(cwd, "q_750.csv"), "r") as ins:
csvreader = csv.reader(ins)
for row in csvreader:
self.features.append(row)
# We need to stick to the param source API
# noinspection PyUnusedLocal
def partition(self, partition_index, total_partitions):
return self
class NestedQueryParamSource(QueryParamSource):
def params(self):
result = {
"body": {
"query": {
"match_all": {}
}
},
"index": None,
"type": None
}
if "cache" in self._params:
result["cache"] = self._params["cache"]
return result
def register(registry):
registry.register_param_source("nested-query-source", NestedQueryParamSource)
trademark_multi.json:
{
"mappings": {
"doc": {
"_all": {
"enabled": false
},
"properties": {
"nested_image_vec": {
"properties": {
"image_vec": {
"bundle": 4,
"cmps_type": "N/A",
"data_type": "float16",
"dim": 2048,
"hash": 500,
"type": "gw_vector"
}
},
"type": "nested"
}
}
}
},
"settings": {
"index": {
"number_of_replicas": "{{number_of_replicas | default(0)}}",
"number_of_shards": "{{number_of_shards | default(5)}}"
}
}
}
And the Error from rally.log:
Traceback (most recent call last):
File "/Users/Chester/Library/Python/3.8/lib/python/site-packages/esrally/track/loader.py", line 1062, in load
root_module.register(self)
AttributeError: module 'trademark_multi.track' has no attribute 'register'
2021-08-22 06:19:05,320 ActorAddr-(T|:60558)/PID:44737 esrally.track.loader ERROR Cannot load track [trademark_multi]
Traceback (most recent call last):
File "/Users/Chester/Library/Python/3.8/lib/python/site-packages/esrally/track/loader.py", line 1062, in load
root_module.register(self)
AttributeError: module 'trademark_multi.track' has no attribute 'register'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/Chester/Library/Python/3.8/lib/python/site-packages/esrally/track/loader.py", line 197, in _load_single_track
has_plugins = load_track_plugins(cfg, track_name, register_track_processor=tpr.register_track_processor)
File "/Users/Chester/Library/Python/3.8/lib/python/site-packages/esrally/track/loader.py", line 235, in load_track_plugins
plugin_reader.load()
File "/Users/Chester/Library/Python/3.8/lib/python/site-packages/esrally/track/loader.py", line 1066, in load
raise exceptions.SystemSetupError(msg)
esrally.exceptions.SystemSetupError: Could not register track plugin at [/Users/Chester/Chester/Code/tools/rally-es/track/trademark_multi]
Please give some advice, thank you so much for the help.
Just tell me when need more information.
Best,
Chester