Skip to content
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

Add Jinja filters for creating dynamic date ranges based on now() #1884

Merged
merged 5 commits into from
Oct 24, 2024

Conversation

inqueue
Copy link
Member

@inqueue inqueue commented Oct 22, 2024

In serverless, data is considered hot when document timestamps are within the boost window and cold when timestamps are outside the boost window. Tracks using date ranges for corpus generation are limited to static dates, presenting a problem for nightly benchmarks where all ingested data is indexed cold.

This commit adds two custom Jinja filters to the track loader to create dynamic date ranges. These simple functions are most useful in the serverless context for any track utilizing date ranges for corpus generation. Usage:

get_start_date(format)

Pair with the now global template variable to produce a start date:

"start-date": {{ now | get_start_date('%Y-%m-%d') | tojson }}

Result:

"start-date": "2024-10-22"

get_end_date(duration_days, format)

"end-date": {{ now | get_end_date(3, '%Y-%m-%d') | tojson }}

Result:

"end-date": "2024-10-25"

Documentation

Documentation will be added with a subsequent commit to this PR. The documentation on the now global filter does not mention the return value is a float as it is the result of time.time().

@inqueue inqueue requested review from martijnvg and a team October 22, 2024 19:35
Copy link
Member

@martijnvg martijnvg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great 👍 . I think we can use this in several tracks that use data generation. I would say we also want this for stateful benchmark runs, since it just makes a benchmark more realistic.

* Small corrections to now and days_ago()
* Add section on dynamic date ranges for get_start_date() and get_end_date()
@inqueue inqueue marked this pull request as ready for review October 23, 2024 23:21
Copy link
Contributor

@favilo favilo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@inqueue inqueue merged commit 4f40228 into elastic:master Oct 24, 2024
17 checks passed
@favilo favilo added this to the 2.11.1 milestone Nov 6, 2024
@favilo favilo added the enhancement Improves the status quo label Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improves the status quo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants