Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Tweak instantiate_worker_template, both in name, description and va…
Browse files Browse the repository at this point in the history
…riable names
  • Loading branch information
reivilibre committed Dec 6, 2023
1 parent 3318722 commit da040e1
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions docker/configure_workers_and_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down Expand Up @@ -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
)

Expand Down

0 comments on commit da040e1

Please sign in to comment.