Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
154 commits
Select commit Hold shift + click to select a range
7d8fca1
Update storage tools with last changes from `storage` branch.
fressi-elastic Jul 16, 2025
a5dd993
Add `storage.max_workers` otpion to `types` module.
fressi-elastic Jul 16, 2025
6a43ab4
It adds TrasferManager class.
fressi-elastic Jul 16, 2025
9bab2cb
Add test case for TransferManager.get method.
fressi-elastic Jul 16, 2025
757f634
It adds missing options keys to `èsrally.types` module.
fressi-elastic Jul 17, 2025
eda1435
Merge branch 'master' of github.com:elastic/rally into storage.manager
fressi-elastic Jul 17, 2025
d9ec8a3
Merge branch 'master' of github.com:elastic/rally into storage.transfer
fressi-elastic Jul 17, 2025
1057cd9
Add documentation for `storage.max_workers` configuration key.
fressi-elastic Jul 17, 2025
f73efca
Merge branch 'storage.transfer' into storage.manager
fressi-elastic Jul 17, 2025
68e9cc1
Add documentation for new `storage.*` configuration keys.
fressi-elastic Jul 17, 2025
0f0fc44
It enables the new multipart tranfer manager inside track downloader.
fressi-elastic Jul 17, 2025
03617d2
Update configuration documentation.
fressi-elastic Jul 17, 2025
2f42d1f
Use legacy downloader in case the transfer manager fails.
fressi-elastic Jul 17, 2025
2b6f42b
Enable the multipart downloader to test in in CI
fressi-elastic Jul 17, 2025
9178a6a
Writing tests for Downloader class
fressi-elastic Jul 17, 2025
d3cb691
Improve loader and test using transfer manager.
fressi-elastic Jul 18, 2025
468f27d
Backport changes from track loader integration branch.
fressi-elastic Jul 18, 2025
c194eda
Merge branch 'storage.transfer' into storage.manager
fressi-elastic Jul 18, 2025
d1e64ff
Merge branch 'storage.manager' into track.loader
fressi-elastic Jul 18, 2025
2ec02bc
Remove unused adapter methods.
fressi-elastic Jul 18, 2025
6f4d116
Merge branch 'storage.transfer' into storage.manager
fressi-elastic Jul 18, 2025
b3a07b0
Merge branch 'storage.manager' into track.loader
fressi-elastic Jul 18, 2025
f61845a
WIP making Downloader serializable.
fressi-elastic Jul 21, 2025
6c19dfa
Merge branch 'master' of github.com:elastic/rally into storage.transfer
fressi-elastic Jul 21, 2025
ed0b386
Skip 'url' field and use 'all()' function in 'Head.check' method.
fressi-elastic Jul 21, 2025
ef65a10
Skip 'url' field and use 'all()' function in 'Head.check' method.
fressi-elastic Jul 21, 2025
8700efb
Merge branch 'storage.transfer' of github.com:fressi-elastic/rally in…
fressi-elastic Jul 21, 2025
ab6ae8e
Remove unused property
fressi-elastic Jul 21, 2025
3c925be
Add a comment to remind to implement Data header in the http adapter.
fressi-elastic Jul 21, 2025
a69678a
It Raises an NotImplementedError for unsupported multi-range feature …
fressi-elastic Jul 21, 2025
f6d7943
Adapter.match_url now returns a bool once again.
fressi-elastic Jul 21, 2025
50dfe95
Merge branch 'master' of github.com:elastic/rally into storage.transfer
fressi-elastic Jul 21, 2025
eee450c
Merge branch 'storage.transfer' into storage.manager
fressi-elastic Jul 21, 2025
e6b9f19
Merge branch 'storage.manager' into track.loader
fressi-elastic Jul 21, 2025
1eed7e7
Remove unnecessary match_url method overriding.
fressi-elastic Jul 21, 2025
b2cc421
Merge branch 'master' of github.com:elastic/rally into storage.transfer
fressi-elastic Jul 22, 2025
ea9eaa0
Merge branch 'storage.transfer' into storage.manager
fressi-elastic Jul 22, 2025
e4fd57e
It adds support to AWS/S3 client adapter.
fressi-elastic Jul 22, 2025
f6f2e88
Testing the new AWS/S3 client adapter.
fressi-elastic Jul 22, 2025
79b7873
Testing the new AWS/S3 client adapter.
fressi-elastic Jul 22, 2025
dc6aea1
Remove Head.create method.
fressi-elastic Jul 22, 2025
66a3817
Update HTTPAdapter to make easier to reuse its head to headers methods.
fressi-elastic Jul 22, 2025
c1b6d2b
It adds tests for AWS/S3 client adapter.
fressi-elastic Jul 22, 2025
5c1c649
Fix S3Adapter.put object
fressi-elastic Jul 23, 2025
6b7ca58
Merge branch 'master' of github.com:elastic/rally into storage.manager
fressi-elastic Jul 23, 2025
98dd83d
Merge branch 'storage.manager' into track.loader
fressi-elastic Jul 23, 2025
959fd39
Downloader class now uses a global storage manager instance.
fressi-elastic Jul 23, 2025
a27cd1e
Backport changes from track.loader branch.
fressi-elastic Jul 23, 2025
26f67a5
Merge branch 'storage.manager' into track.loader
fressi-elastic Jul 23, 2025
6ea3fca
Use global LOG reference instead of self.logger.
fressi-elastic Jul 24, 2025
e54d4c3
Use `Self` as return type for `Adapter.from_config` methods.
fressi-elastic Jul 24, 2025
2bfd1ef
Use `Self` as return type for `Adapter.from_config` methods.
fressi-elastic Jul 24, 2025
6a27931
Use `Self` as return type for `Adapter.from_config` methods.
fressi-elastic Jul 24, 2025
98ce831
Add comment to explain client limitation.
fressi-elastic Jul 24, 2025
04e535d
Add missing typing for boto3 library.
fressi-elastic Jul 24, 2025
2333aaa
Add missing typing for boto3 library.
fressi-elastic Jul 24, 2025
c2a8d32
Import `Self` from typing_extensions
fressi-elastic Jul 25, 2025
d57320c
Merge branch 'master' of github.com:elastic/rally into storage.manager
fressi-elastic Jul 25, 2025
8770e6d
Remove list and put methods from storage Adapter interface
fressi-elastic Jul 25, 2025
db3c73b
Merge branch 'storage.manager' into track.loader
fressi-elastic Jul 25, 2025
8279215
Update documentation after introducing S3 adapter.
fressi-elastic Jul 28, 2025
039112f
Merge branch 'storage.manager' into track.loader
fressi-elastic Jul 28, 2025
2814a0e
Fix configuration documentation.
fressi-elastic Jul 28, 2025
71cbce3
Write logs lines for when using transfer manager a single transfer do…
fressi-elastic Jul 28, 2025
f752155
Force using transfer manager
fressi-elastic Jul 28, 2025
d40b73a
Revert "Force using transfer manager"
fressi-elastic Jul 28, 2025
7557449
Merge branch 'master' of github.com:elastic/rally into track.loader
fressi-elastic Jul 30, 2025
8359a57
Get improvements from storage branch.
fressi-elastic Jul 30, 2025
0fb0d6e
Disable the use of the new transfer manager by default.
fressi-elastic Aug 1, 2025
66b91d5
Send storage configuration toghether with the Downloader object.
fressi-elastic Aug 13, 2025
f213196
Merge branch 'master' of github.com:elastic/rally into actor
fressi-elastic Aug 13, 2025
b5ad390
Update test_types and launcher.py
fressi-elastic Aug 14, 2025
168f7ea
Revert changes of mechanic launcher.
fressi-elastic Aug 14, 2025
0a5cb40
Ask Thespian to spawn actors subprocess instead of using fork
fressi-elastic Aug 14, 2025
3c00838
Correct actor initialization procedure.
fressi-elastic Aug 14, 2025
903e4d1
revert changes to rally.py
fressi-elastic Aug 14, 2025
b8a8822
Revert unrelated changes.
fressi-elastic Aug 18, 2025
544b157
Revert unrelated changes.
fressi-elastic Aug 18, 2025
0e23b15
Revert unrelated changes.
fressi-elastic Aug 18, 2025
7dae951
Revert unrelated changes.
fressi-elastic Aug 18, 2025
a9fb89a
Merge branch 'actor' of github.com:fressi-elastic/rally into actor
fressi-elastic Aug 18, 2025
b3dd751
Add test case for actor.bootstrap_actor_system
fressi-elastic Aug 18, 2025
a85135d
Add test case for actor.actor_system_already_running
fressi-elastic Aug 18, 2025
a9db7f3
Test setting process_startup_method when bootstrapping actor system.
fressi-elastic Aug 18, 2025
5286cdf
It allows configuring actor process startup method.
fressi-elastic Aug 18, 2025
42b6bc4
Test behaviour when joining actor system offline.
fressi-elastic Aug 18, 2025
e3103fd
actor_system_already_running returns `None` for unsupported system base.
fressi-elastic Aug 18, 2025
48a11c0
It joins the remote actor system with the requested IP and port.
fressi-elastic Aug 18, 2025
e8008e9
It wraps actor_system_already_running to keep the old behavior.
fressi-elastic Aug 18, 2025
b22ad2f
Merge branch 'actor' into track.loader
fressi-elastic Aug 18, 2025
3000678
Fix actor_test.py
fressi-elastic Aug 18, 2025
16e2da1
Merge branch 'actor' into track.loader
fressi-elastic Aug 18, 2025
d3a078d
Mock log.load_configuration in test_actor.py
fressi-elastic Aug 18, 2025
ac7a301
Merge branch 'actor' into track.loader
fressi-elastic Aug 18, 2025
02b4ffa
Fix manager_test.py
fressi-elastic Aug 18, 2025
9d0c148
Update configuration documentation.
fressi-elastic Aug 18, 2025
09d0f93
Update configuration documentation.
fressi-elastic Aug 18, 2025
93ffb39
Merge branch 'actor' into track.loader
fressi-elastic Aug 18, 2025
75b6711
Fix/refactor bootstrap_actor_system function.
fressi-elastic Aug 19, 2025
f6d75d9
Merge branch 'actor' into track.loader
fressi-elastic Aug 19, 2025
d3d98a3
Remove wrappers for actor_system_already_running method.
fressi-elastic Aug 19, 2025
bb605b1
Fix actor_test.py
fressi-elastic Aug 19, 2025
45159a6
Merge branch 'actor' into track.loader
fressi-elastic Aug 19, 2025
055061f
Merge branch 'master' of github.com:elastic/rally into track.loader
fressi-elastic Aug 20, 2025
f4cee02
Revert unnecessary changes from rally.py
fressi-elastic Aug 20, 2025
49234fe
Revert unnecessary changes in types_test.py
fressi-elastic Aug 20, 2025
6310247
Simplyfy trasfer manager interface.
fressi-elastic Aug 20, 2025
8881058
Simplyfy trasfer manager interface.
fressi-elastic Aug 20, 2025
fd50af5
Make default client TTLs configurable.
fressi-elastic Aug 20, 2025
c83c956
Merge branch 'master' of github.com:elastic/rally into track.loader
fressi-elastic Oct 13, 2025
e745779
Backport changes from other PRs
fressi-elastic Oct 14, 2025
05aa104
Fix transfer manager.
fressi-elastic Oct 14, 2025
151da50
Fix make install to restore the old behavior.
fressi-elastic Oct 14, 2025
7827c49
Rename function after last day refactoring.
fressi-elastic Oct 14, 2025
b0b4b00
Remove files added by mistake.
fressi-elastic Oct 14, 2025
e135e48
Remove unnecessary lines.
fressi-elastic Oct 14, 2025
346f8b3
Update configuration documentation.
fressi-elastic Oct 14, 2025
47152f0
Fix Makefile -> make docs
fressi-elastic Oct 14, 2025
981fce9
It adds http and s3 adapters to the main package module.
fressi-elastic Oct 15, 2025
8bfa04b
Update configuration document style.
fressi-elastic Oct 15, 2025
95d591b
Remove file added by mistake.
fressi-elastic Oct 15, 2025
2cc497b
Remove [track] section platform issue mention from configuration docu…
fressi-elastic Oct 15, 2025
6a64709
Merge branch 'master' into track.loader
elasticmachine Oct 15, 2025
4413f0b
Recover all known loggers by copying __dict__ reference from new to o…
fressi-elastic Oct 15, 2025
4e628e8
Some further iteration with all loggers recovered and actor using the…
fressi-elastic Oct 16, 2025
559da2a
Refactor typing annotations and improve code readability.
fressi-elastic Oct 16, 2025
16e4567
Merge branch 'log' into track.loader
fressi-elastic Oct 16, 2025
8d9de3c
Merge branch 'track.loader' of github.com:fressi-elastic/rally into t…
fressi-elastic Oct 16, 2025
3b47362
Use `uv sync` in `make install` goal.
fressi-elastic Oct 16, 2025
fae4c00
Fix link to storage section in configuration.rst
fressi-elastic Oct 16, 2025
7ae1bdb
Fix docstring in _adapter.py
fressi-elastic Oct 16, 2025
57b3cc2
Explain how an why the CachedHeadException is being created.
fressi-elastic Oct 16, 2025
b463a7d
Update esrally/storage/_manager.py
fressi-elastic Oct 16, 2025
22e87f7
Remove unused attribute.
fressi-elastic Oct 16, 2025
90ee9b7
Remove from __future__ import annotations.
fressi-elastic Oct 16, 2025
51eed90
Update make *docs rules to use `uv run`.
fressi-elastic Oct 16, 2025
65fe996
Create local directory only before starting download to the final des…
fressi-elastic Oct 16, 2025
546d2b3
Some other additional cleanup for readibility to help identify integr…
fressi-elastic Oct 16, 2025
3a59cf7
It updates logging configuration after actor creation.
fressi-elastic Oct 17, 2025
e00cf8c
Silence eslastic.log logger.
fressi-elastic Oct 17, 2025
c40812b
Backport changes from branch track.loader
fressi-elastic Oct 17, 2025
71754b1
Remove unnecessary checks.
fressi-elastic Oct 17, 2025
b6702e8
Merge branch 'log' into track.loader
fressi-elastic Oct 17, 2025
f297744
Remove unrelated changes.
fressi-elastic Oct 17, 2025
1704a8f
Merge branch 'log' into track.loader
fressi-elastic Oct 17, 2025
5d323cd
Merge branch 'master' of github.com:elastic/rally into track.loader
fressi-elastic Oct 17, 2025
80dd747
Merge branch 'master' of github.com:elastic/rally into log
fressi-elastic Oct 17, 2025
13dbe36
Merge branch 'log' into track.loader
fressi-elastic Oct 17, 2025
9a1dbeb
Merge branch 'master' of github.com:elastic/rally into track.loader
fressi-elastic Oct 17, 2025
c77d3f6
Make S3 adapter optional (once again).
fressi-elastic Oct 21, 2025
014d6aa
Cache missing adapter error to avoid spamming the logging with errors…
fressi-elastic Oct 21, 2025
b0685dc
Rename http package and make it used from its final implementation mo…
fressi-elastic Oct 21, 2025
374a8be
Correct configuration documentation.
fressi-elastic Oct 21, 2025
487f818
Relax test_execute_schedule_throughput_throttled test case requirements.
fressi-elastic Oct 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 42 additions & 14 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ Define a secure connection to an Elastic Cloud Serverless project::
storage
~~~~~~~

This section defines how client is configured to transfer corpus files. The main
advantages of this downloader implementation are:
This section defines how client is configured to transfer corpus files. The main advantages of this downloader
implementation are:

* It supports configuring multiple mirror URLs. The client will load balance between these URLs giving priority to
those with the lower latency. In case of failures the client will download files from the original URL.
Expand All @@ -166,11 +166,17 @@ Configuration options are:
Here is an example of valid value for http(s) adapter::

[storage]
storage.adapters = esrally.storage._http:HTTPAdapter
storage.adapters = esrally.storage.http:HTTPAdapter,esrally.storage.aws:S3Adapter

At this point in time ``esrally.storage.http:HTTPAdapter`` and ``esrally.storage.aws:S3Adapter`` are the only
known ``Adapter`` implementations intended for public use and they are both enabled by default. So it is required
to edit this option for special customizations (like for example remove one of them or adding a new
custom implementation for accessing a special infrastructure server).

At this point in time `esrally.storage._http:HTTPAdapter` is the only existing `Adapter` implementations intended
for public use and that is already the default one. So it is required to edit this option for special customizations.
* ``storage.cache_ttl`` indicates the default time to live in seconds replies from head requests has to be considered
valid. In case this value is zero, the caching mechanism is disabled.

* ``storage.chunk_size`` is used to specify the default size (in bytes) of data chunks to be downloaded using adapters.

* ``storage.local_dir`` indicates the default directory where to store local files when no path has been specified.

Expand Down Expand Up @@ -208,17 +214,17 @@ Configuration options are:
The mirroring of the files on mirrors servers has to be provided by the infrastructure. The esrally client will look
for the files on the destination mirror endpoints URLs or use the original source endpoint URL in case the files
are not mirrored or they have a different size from the source one. The client will prefer endpoints with the lower
latency fetching the head of the file.
latency measured by fetching the headers of the file.

* ``storage.monitor_interval`` represents the time interval (in seconds) `TransferManager` should wait for consecutive
* ``storage.monitor_interval`` represents the time interval (in seconds) ``TransferManager`` should wait for consecutive
monitor operations (log transfer and connections statistics, adjust the maximum number of connections, etc.).

* ``storage.multipart_size`` When the file size measured in bytes is greater than this value the file is split in chunk
of this size plus the last one ()that could be smaller). Each part will be downloaded separately and in parallel using
a dedicated connection by a worker thread and eventually from a different mirror server to load balance the network
traffic between multiple servers. If the resulting number of parts is greater than ``storage.max_workers`` and
``storage.max_connections`` options, then the transfer of those parts exceeding these limits will be performed as
soon as a worker thread gets available or a HTTP connection get released by another thread.
of this size plus the last one. Each part will be downloaded separately and in parallel using a dedicated connection
by a worker thread and eventually from a different mirror server to load balance the network traffic between multiple
servers. If the resulting number of parts is greater than ``storage.max_workers`` and ``storage.max_connections``
options, then the transfer of those parts exceeding these limits will be performed as soon as a worker thread gets
available or a HTTP connection get released by another thread.

* ``storage.random_seed`` a string used to initialize the client random number generator. This could be used to make
problems easier to reproduce in continuous integration. In most of the cases it should be left empty.
Expand All @@ -229,10 +235,13 @@ HTTP Adapter

This adapter can be used only to download files from public HTTP or HTTPS servers.

* ``storage.http.chunk_size`` is used to specify the size of the buffer is being used for transferring chunk of files.
It must be listed in the ``storage.adapters`` option::

[storage]
storage.adapters = esrally.storage.http:HTTPAdapter

* ``storage.http.max_retries`` is used to configure the maximum number of retries for making HTTP adapter requests.
it accept a numeric value to simply specify total number of retries. Examples::
It accepts a numeric value to simply specify total number of retries. Examples::

[storage]
storage.http.max_retries = 3
Expand All @@ -256,6 +265,11 @@ It requires `Boto3 Client`_ to be installed and it accepts only URLs with the fo

s3://<bucket-name>/[<object-key-prefix>]

It must be listed in the ``storage.adapters`` option::

[storage]
storage.adapters = esrally.storage.aws:S3Adapter

In the case the boto3 client is not installed, and S3 buckets are publicly readable without authentication, you can use
the HTTP adapter instead, for example by using the following URL format::

Expand Down Expand Up @@ -294,6 +308,20 @@ Configuration options:
.. _Boto3 Client: https://boto3.amazonaws.com/v1/documentation/api/latest/index.html
.. _S3 Service Documentation: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/DownloadDistS3AndCustomOrigins.html#concept_S3Origin


track
~~~~~

This section specifies how tracks corpora files has to be fetched. Available options are:

* ``track.downloader.multipart_enabled`` if ``true``, it will enable the use the new multipart ``esrally.storage`` package for
downloading corpora files. For more configuration options please have a look to the `storage`_ configuration section.

.. warning::

Transfers manager implementation is experimental and under active development. Enable it only if you actually need it.


tracks
~~~~~~

Expand Down
100 changes: 83 additions & 17 deletions esrally/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,21 @@
# under the License.

import configparser
import contextvars
import logging
import os.path
import shutil
import typing
from enum import Enum
from string import Template

from typing_extensions import Self

from esrally import PROGRAM_NAME, exceptions, paths, types
from esrally.utils import io

LOG = logging.getLogger(__name__)


class Scope(Enum):
# Valid for all benchmarks, typically read from the configuration file
Expand All @@ -40,6 +46,7 @@ class Scope(Enum):


class ConfigFile:

def __init__(self, config_name=None, **kwargs):
self.config_name = config_name

Expand Down Expand Up @@ -124,22 +131,66 @@ def auto_load_local_config(base_config, additional_sections=None, config_file_cl
return cfg


class Config:
EARLIEST_SUPPORTED_VERSION = 17
CONFIG = contextvars.ContextVar[typing.Optional[types.Config]](f"{__name__}.config", default=None)
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the problem this contextvar addresses?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would like to be able to pass a shared configuration object from the very first parent thread (produced after parsing the cmd line), and from actor to actor so we do have global settings always available in the app without having to care to pass them. We should be able to deploy the whole app from it in a deterministic and reproducible way. It would make all the parts far easier to test being a functions of it. Something similar of how I implemented the storage part.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand how contextvars facilitate sharing. Each thread has it's own context.

Example:

import concurrent.futures
import contextvars

VAR: contextvars.ContextVar[str | None] = contextvars.ContextVar('var', default=None)
VAR.set('parent')
print(f"parent thread: {VAR.get()}") # prints 'parent'

def worker() -> None:
    print(f"child thread: {VAR.get()}") # prints 'None'
    VAR.set('child')
    print(f"child thread: {VAR.get()}") # prints 'child'

with concurrent.futures.ThreadPoolExecutor(max_workers=1) as executor:
    future = executor.submit(worker)
    future.result()

print(f"parent thread: {VAR.get()}") # prints 'parent'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should copy the context before when running task and use it in the submitted function. This could be transparently done by the executor itself. Some TODO for later. The nice point with contextvars is you can decide at which point in time you make a copy (fork) of the variables, and later changes will not be considered by other threads. This makes concurrent behavior a bit more predictable.



def get_config() -> types.Config:
cfg = CONFIG.get()
if cfg is None:
raise exceptions.ConfigError("Config not initialized.")
return cfg


def init_config(cfg: types.Config, *, force=False) -> types.Config:
if not force and CONFIG.get():
raise exceptions.ConfigError(f"Config already set: {cfg}")
cfg = Config.from_config(cfg)
CONFIG.set(cfg)
return cfg

CURRENT_CONFIG_VERSION = 17

def clear_config() -> None:
CONFIG.set(None)
Comment on lines +144 to +153
Copy link
Contributor

Choose a reason for hiding this comment

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

These 2 methods are not used it seems.



class Config(types.Config):
"""
Config is the main entry point to retrieve and set benchmark properties. It provides multiple scopes to allow overriding of values on
different levels (e.g. a command line flag can override the same configuration property in the config file). These levels are
transparently resolved when a property is retrieved and the value on the most specific level is returned.
"""

def __init__(self, config_name=None, config_file_class=ConfigFile, **kwargs):
EARLIEST_SUPPORTED_VERSION = 17

CURRENT_CONFIG_VERSION = 17

@classmethod
def from_config(cls, cfg: types.Config | None = None) -> Self:
if cfg is None:
cfg = get_config()
if isinstance(cfg, cls):
return cfg
if isinstance(cfg, types.Config):
return cls(opts_from=cfg)
Comment on lines +173 to +174
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is opts_from defined?

raise TypeError(f"unexpected cfg: got type {type(cfg).__name__}, expected types.Config")

def __init__(self, config_name: str | None = None, config_file_class=ConfigFile, copy_from: types.Config | None = None, **kwargs):
self.name = config_name
self.config_file = config_file_class(config_name, **kwargs)
self._opts = {}
self._clear_config()
if copy_from is not None:
self.update(copy_from)
self._override_config()

def update(self, cfg: types.Config):
if isinstance(cfg, Config):
self.name = cfg.name
self.config_file = cfg.config_file
self._opts.update(cfg._opts) # pylint: disable=protected-access
return
for section in cfg.all_sections():
for name, value in cfg.all_opts(section).items():
self.add(Scope.application, section, name, value)

def add(self, scope, section: types.Section, key: types.Key, value):
"""
Expand Down Expand Up @@ -185,7 +236,10 @@ def opts(self, section: types.Section, key: types.Key, default_value=None, manda
else:
raise exceptions.ConfigError(f"No value for mandatory configuration: section='{section}', key='{key}'")

def all_opts(self, section: types.Section):
def all_sections(self) -> list[types.Section]:
return list(typing.get_args(types.Section))

def all_opts(self, section: types.Section) -> dict[str, typing.Any]:
"""
Finds all options in a section and returns them in a dict.

Expand Down Expand Up @@ -233,21 +287,24 @@ def load_config(self, auto_upgrade=False):
def _do_load_config(self):
config = self.config_file.load()
# It's possible that we just reload the configuration
self._clear_config()
self._opts = {}
self._override_config()
self._fill_from_config_file(config)

def _clear_config(self):
def _override_config(self):
# This map contains default options that we don't want to sprinkle all over the source code but we don't want users to change
# them either
self._opts = {
(Scope.application, "source", "distribution.dir"): "distributions",
(Scope.application, "benchmarks", "track.repository.dir"): "tracks",
(Scope.application, "benchmarks", "track.default.repository"): "default",
(Scope.application, "provisioning", "node.name.prefix"): "rally-node",
(Scope.application, "provisioning", "node.http.port"): 39200,
(Scope.application, "mechanic", "team.repository.dir"): "teams",
(Scope.application, "mechanic", "team.default.repository"): "default",
}
self._opts.update(
{
(Scope.application, "source", "distribution.dir"): "distributions",
(Scope.application, "benchmarks", "track.repository.dir"): "tracks",
(Scope.application, "benchmarks", "track.default.repository"): "default",
(Scope.application, "provisioning", "node.name.prefix"): "rally-node",
(Scope.application, "provisioning", "node.http.port"): 39200,
(Scope.application, "mechanic", "team.repository.dir"): "teams",
(Scope.application, "mechanic", "team.default.repository"): "default",
}
)

def _fill_from_config_file(self, config):
for section in config.sections():
Expand Down Expand Up @@ -279,6 +336,15 @@ def _k(self, scope, section: types.Section, key: types.Key):
else:
return scope, section, key

def __eq__(self, other):
if not isinstance(other, Config):
return False
if other.name != self.name:
return False
if other._opts != self._opts:
return False
return True


def migrate(config_file, current_version, target_version, out=print, i=input):
logger = logging.getLogger(__name__)
Expand Down
11 changes: 5 additions & 6 deletions esrally/storage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from esrally.storage._adapter import AdapterRegistry, Head
from esrally.storage._client import Client
from esrally.storage._executor import Executor, ThreadPoolExecutor
from esrally.storage._http import HTTPAdapter
from esrally.storage._adapter import Adapter, AdapterRegistry, Head
from esrally.storage._config import StorageConfig
from esrally.storage._manager import (
TransferManager,
get_transfer_manager,
init_transfer_manager,
quit_transfer_manager,
transfer_manager,
shutdown_transfer_manager,
)
from esrally.storage._transfer import Transfer
Loading