-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make exists_set_param macro available to tracks #1012
Conversation
Frequently it's useful to specify a setting based on the presence of a track parameter. To avoid repetition this commit makes a Jinja2 macro called `exists_set_param()` available for all tracks (if they import the rally helpers).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change looks fine but I left a few comments regarding the docs.
docs/adding_tracks.rst
Outdated
} | ||
} | ||
|
||
Note the lack of a comma after the first setting ``cluster.routing.allocation.node_initial_primaries_recoveries``. This is intentional since the helper with insert it if the parameter exists (this behavior can be changed using ``comma=False``). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: typo: "the helper will insert it"
docs/adding_tracks.rst
Outdated
|
||
Note the lack of a comma after the first setting ``cluster.routing.allocation.node_initial_primaries_recoveries``. This is intentional since the helper with insert it if the parameter exists (this behavior can be changed using ``comma=False``). | ||
|
||
Assuming we pass ``--track-params="es_snapshot_restore_recovery_max_bytes_per_sec:-1"`` the helper will end up rending the operation as:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: "rending" -> "rendering"
docs/adding_tracks.rst
Outdated
* ``rally.exists_set_param(setting_name, value, default_value=None, comma=True)``: a `macro <https://jinja.pocoo.org/docs/dev/templates/#macros>`_ that you can use to set the value of a track parameter without having to check if it exists. | ||
|
||
.. important:: | ||
To use macros you must declare ``{% import "rally.helpers" as rally with context %}`` at the top of your track; see :ref:`the docs<track_collect_helper>` for more details and `the geonames track <https://github.com/elastic/rally-tracks/blob/b2f86df5f0c18461fdb64dd9ee1fe16bd3653b9d/geonames/track.json#L1>`_ for an example. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe we should call the link geonames track
, not the geonames track
.
docs/adding_tracks.rst
Outdated
@@ -723,6 +725,52 @@ You can find an example in the ``http_logs`` track:: | |||
|
|||
The data set that is used in the ``http_logs`` track starts on 26-04-1998 but we want to ignore the first few days for this query, so we start on 15-05-1998. The expression ``{{'15-05-1998' | days_ago(now)}}`` yields the difference in days between now and the fixed start date and allows us to benchmark time range queries relative to now with a predetermined data set. | |||
|
|||
* ``rally.collect(parts)``: a `macro <https://jinja.pocoo.org/docs/dev/templates/#macros>`_ that you can use to join track fragments. An example can be seen :ref:`above<track_collect_helper>`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"An example can be seen" sounds a bit stiff. How about: "You can see an example above" or just "See the example above"?
docs/adding_tracks.rst
Outdated
} | ||
|
||
|
||
The parameter ``default_value`` controls the value to use for the setting if it's undefined. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's -> it is?
docs/adding_tracks.rst
Outdated
|
||
Example: | ||
|
||
Suppose you need an operation that specifies the Elasticsearch transient setting ``indices.recovery.max_bytes_per_sec`` if and only if it's been provided as a track parameter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just git grepped and we have a strong tendency towards "it is" rather than "it's" in our docs. :)
Thanks! Addressed your comments in 58db4ef |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I left one very minor comment but feel free to address this without another review round. LGTM
docs/adding_tracks.rst
Outdated
* ``rally.exists_set_param(setting_name, value, default_value=None, comma=True)``: a `macro <https://jinja.pocoo.org/docs/dev/templates/#macros>`_ that you can use to set the value of a track parameter without having to check if it exists. | ||
|
||
.. important:: | ||
To use macros you must declare ``{% import "rally.helpers" as rally with context %}`` at the top of your track; see :ref:`the docs<track_collect_helper>` for more details and `the geonames track <https://github.com/elastic/rally-tracks/blob/b2f86df5f0c18461fdb64dd9ee1fe16bd3653b9d/geonames/track.json#L1>`_ for an example. | ||
To use macros you must declare ``{% import "rally.helpers" as rally with context %}`` at the top of your track; see :ref:`the docs<track_collect_helper>` for more details and `geonames track <https://github.com/elastic/rally-tracks/blob/b2f86df5f0c18461fdb64dd9ee1fe16bd3653b9d/geonames/track.json#L1>`_ for an example. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the article "the" was ok there, I just felt a little bit odd in the link text. But I'd still include it in the text outside the link.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok (I was wondering if we wanna go for less correct grammar/syntax but less words). Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super small docs nits, tyvm for moving this here.
docs/adding_tracks.rst
Outdated
* ``rally.exists_set_param(setting_name, value, default_value=None, comma=True)``: a `macro <https://jinja.pocoo.org/docs/dev/templates/#macros>`_ that you can use to set the value of a track parameter without having to check if it exists. | ||
|
||
.. important:: | ||
To use macros you must declare ``{% import "rally.helpers" as rally with context %}`` at the top of your track; see :ref:`the docs<track_collect_helper>` for more details and the `geonames track <https://github.com/elastic/rally-tracks/blob/b2f86df5f0c18461fdb64dd9ee1fe16bd3653b9d/geonames/track.json#L1>`_ for an example. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, not sure if it even matters, but the space between text and <>
is missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks fixed in 00a9ed6
docs/adding_tracks.rst
Outdated
} | ||
|
||
|
||
The parameter ``default_value`` controls the value to use for the setting if it is undefined. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean that not setting the default_value
will result in nothing being added? I assume this is the case, as that is sane. Its probably worth clarifying that here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks fixed in 00a9ed6
/jenkins test this |
Frequently it's useful to specify a setting based on the presence of a
track parameter. To avoid repetition this commit makes a Jinja2 macro
called
exists_set_param()
available for all tracks (if they import therally helpers).