Skip to content

Commit

Permalink
Rename concurrency->pool_size
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeny-stakewise committed Sep 11, 2023
1 parent 9d8b2e9 commit e479ce7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
18 changes: 9 additions & 9 deletions src/commands/create_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
callback=validate_eth_address,
)
@click.option(
'--concurrency',
'--pool-size',
help='Number of processes in a pool.',
# do not prompt
type=int,
Expand All @@ -60,7 +60,7 @@ def create_keys(
vault: HexAddress,
data_dir: str,
per_keystore_password: bool,
concurrency: int | None,
pool_size: int | None,
) -> None:
config = VaultConfig(vault, Path(data_dir))
config.load(mnemonic)
Expand All @@ -75,18 +75,18 @@ def create_keys(
mnemonic=mnemonic,
count=count,
start_index=config.mnemonic_next_index,
concurrency=concurrency,
pool_size=pool_size,
)
deposit_data = _export_deposit_data_json(
credentials=credentials, filename=str(deposit_data_file), concurrency=concurrency
credentials=credentials, filename=str(deposit_data_file), pool_size=pool_size
)

_export_keystores(
credentials=credentials,
keystores_dir=str(keystores_dir),
password_file=str(password_file),
per_keystore_password=per_keystore_password,
concurrency=concurrency,
pool_size=pool_size,
)

config.increment_mnemonic_index(count)
Expand All @@ -99,14 +99,14 @@ def create_keys(


def _export_deposit_data_json(
credentials: list[Credential], filename: str, concurrency: int | None = None
credentials: list[Credential], filename: str, pool_size: int | None = None
) -> str:
with click.progressbar(
length=len(credentials),
label='Generating deposit data JSON\t\t',
show_percent=False,
show_pos=True,
) as progress_bar, Pool(processes=concurrency) as pool:
) as progress_bar, Pool(processes=pool_size) as pool:
results = [
pool.apply_async(
cred.deposit_datum_dict,
Expand All @@ -129,7 +129,7 @@ def _export_keystores(
keystores_dir: str,
password_file: str,
per_keystore_password: bool,
concurrency: int | None = None,
pool_size: int | None = None,
) -> None:
makedirs(path.abspath(keystores_dir), exist_ok=True)
if not per_keystore_password:
Expand All @@ -139,7 +139,7 @@ def _export_keystores(
label='Exporting validator keystores\t\t',
show_percent=False,
show_pos=True,
) as progress_bar, Pool(processes=concurrency) as pool:
) as progress_bar, Pool(processes=pool_size) as pool:
results = [
pool.apply_async(
cred.save_signing_keystore,
Expand Down
4 changes: 2 additions & 2 deletions src/common/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,15 @@ def generate_credentials(
mnemonic: str,
count: int,
start_index: int,
concurrency: int | None = None,
pool_size: int | None = None,
) -> list[Credential]:
credentials: list[Credential] = []
with click.progressbar(
length=count,
label='Creating validator keys:\t\t',
show_percent=False,
show_pos=True,
) as progress_bar, Pool(processes=concurrency) as pool:
) as progress_bar, Pool(processes=pool_size) as pool:

def bar_updated(result):
progress_bar.update(len(result))
Expand Down
6 changes: 3 additions & 3 deletions src/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Settings(metaclass=Singleton):
ipfs_fetch_endpoints: list[str]
validators_fetch_chunk_size: int
sentry_dsn: str
load_keystores_concurrency: int | None
pool_size: int | None

# pylint: disable-next=too-many-arguments,too-many-locals
def set(
Expand Down Expand Up @@ -122,8 +122,8 @@ def set(
'VALIDATORS_FETCH_CHUNK_SIZE', default=100, cast=int
)
self.sentry_dsn = decouple_config('SENTRY_DSN', default='')
self.load_keystores_concurrency = decouple_config(
'LOAD_KEYSTORES_CONCURRENCY', default=None, cast=lambda x: int(x) if x else None
self.pool_size = decouple_config(
'POOL_SIZE', default=None, cast=lambda x: int(x) if x else None
)

@property
Expand Down
2 changes: 1 addition & 1 deletion src/validators/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def load_keystores() -> Keystores | None:

keystore_files = list_keystore_files()
logger.info('Loading keystores from %s...', settings.keystores_dir)
with Pool(processes=settings.load_keystores_concurrency) as pool:
with Pool(processes=settings.pool_size) as pool:
# pylint: disable-next=unused-argument
def _stop_pool(*args, **kwargs):
pool.close()
Expand Down

0 comments on commit e479ce7

Please sign in to comment.