Skip to content

Refactor repeated code into reusable functions #11

@surajssd

Description

@surajssd

Here is an example of one such code:

LMBench/run-bench.py

Lines 222 to 238 in 9318e41

def setup_infrastructure(config: Dict[str, Any]) -> None:
"""Set up the infrastructure based on the configuration."""
if 'Infrastructure' not in config:
raise ValueError("Infrastructure configuration is missing in bench-spec.yaml")
location = config['Infrastructure'].get('Location')
if not location:
raise ValueError("Infrastructure Location is not specified in bench-spec.yaml")
if location == 'NoBench':
print("Not running any benchmarks!")
sys.exit(0)
elif location == 'LocalMinikube':
minikube_installation(config)
elif location == 'LMCacheGKE':
start_gke_cluster(config)
else:
raise ValueError(f"Unsupported infrastructure location: {location}")

and

LMBench/run-bench.py

Lines 279 to 295 in 9318e41

def setup_infrastructure_from_run_bench_config(infrastructure_config: Dict[str, Any]) -> None:
"""Set up the infrastructure based on the run-bench.yaml configuration."""
location = infrastructure_config.get('Location')
if not location:
raise ValueError("Infrastructure Location is not specified in run-bench.yaml")
if location == 'NoBench':
print("Not running any benchmarks!")
sys.exit(0)
elif location == 'LocalMinikube':
minikube_installation_from_infrastructure_config(infrastructure_config)
elif location == 'LMCacheGKE':
start_gke_cluster_from_infrastructure_config(infrastructure_config)
elif location == 'Local-Flat':
print("Using Local-Flat infrastructure - no setup required")
else:
raise ValueError(f"Unsupported infrastructure location: {location}")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions