From da040e167de776248c72fa4c1d5f27c6af924a59 Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Wed, 6 Dec 2023 15:18:12 +0000 Subject: [PATCH] Tweak `instantiate_worker_template`, both in name, description and variable names --- docker/configure_workers_and_start.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/docker/configure_workers_and_start.py b/docker/configure_workers_and_start.py index 90ce377d0d..0dba889f96 100755 --- a/docker/configure_workers_and_start.py +++ b/docker/configure_workers_and_start.py @@ -450,21 +450,22 @@ def merge_worker_template_configs( ) -def insert_worker_name_for_worker_config( - existing_template: WorkerTemplate, worker_name: str +def instantiate_worker_template( + template: WorkerTemplate, worker_name: str ) -> Dict[str, Any]: - """Insert a given worker name into the worker's configuration dict. + """Given a worker template, instantiate it into a worker configuration + (which is currently represented as a dictionary). Args: - existing_template: The WorkerTemplate that is imported into shared_config. - worker_name: The name of the worker to insert. - Returns: Copy of the dict with newly inserted worker name + template: The WorkerTemplate to template + worker_name: The name of the worker to use. + Returns: worker configuration dictionary """ - dict_to_edit = dataclasses.asdict(existing_template) - dict_to_edit["shared_extra_conf"] = existing_template.shared_extra_conf(worker_name) - dict_to_edit["endpoint_patterns"] = sorted(existing_template.endpoint_patterns) - dict_to_edit["listener_resources"] = sorted(existing_template.listener_resources) - return dict_to_edit + worker_config_dict = dataclasses.asdict(template) + worker_config_dict["shared_extra_conf"] = template.shared_extra_conf(worker_name) + worker_config_dict["endpoint_patterns"] = sorted(template.endpoint_patterns) + worker_config_dict["listener_resources"] = sorted(template.listener_resources) + return worker_config_dict def apply_requested_multiplier_for_worker(worker_types: List[str]) -> List[str]: @@ -781,7 +782,7 @@ def generate_worker_files( ) # Replace placeholder names in the config template with the actual worker name. - worker_config: Dict[str, Any] = insert_worker_name_for_worker_config( + worker_config: Dict[str, Any] = instantiate_worker_template( worker_template, worker_name )