Skip to content

Commit

Permalink
test(sdk): delete tune testing code in run-e2e-experiment.
Browse files Browse the repository at this point in the history
Signed-off-by: Electronic-Waste <[email protected]>
  • Loading branch information
Electronic-Waste committed Jul 30, 2024
1 parent b43f603 commit 6235a39
Showing 1 changed file with 0 additions and 62 deletions.
62 changes: 0 additions & 62 deletions test/e2e/v1beta1/scripts/gh-actions/run-e2e-experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from kubeflow.katib import ApiClient
from kubeflow.katib import KatibClient
from kubeflow.katib import models
from kubeflow.katib import search
from kubeflow.katib.constants import constants
from kubeflow.katib.utils.utils import FakeResponse
from kubernetes import client
Expand Down Expand Up @@ -74,50 +73,6 @@ def run_e2e_experiment(
logging.debug(katib_client.get_suggestion(exp_name, exp_namespace))


def run_e2e_experiment_create_by_tune(
katib_client: KatibClient,
exp_name: str,
exp_namespace: str,
):
# Create Katib Experiment and wait until it is finished.
logging.debug("Creating Experiment: {}/{}".format(exp_namespace, exp_name))

# Use the test case from get-started tutorial.
# https://www.kubeflow.org/docs/components/katib/getting-started/#getting-started-with-katib-python-sdk
# [1] Create an objective function.
def objective(parameters):
result = 4 * int(parameters["a"]) - float(parameters["b"]) ** 2
print(f"result={result}")

# [2] Create hyperparameter search space.
parameters = {
"a": search.int(min=10, max=20),
"b": search.double(min=0.1, max=0.2)
}

# [3] Create Katib Experiment with 4 Trials and 2 CPUs per Trial.
# And Wait until Experiment reaches Succeeded condition.
katib_client.tune(
name=exp_name,
namespace=exp_namespace,
objective=objective,
parameters=parameters,
objective_metric_name="result",
max_trial_count=4,
resources_per_trial={"cpu": "2"},
)
experiment = katib_client.wait_for_experiment_condition(
exp_name, exp_namespace, timeout=EXPERIMENT_TIMEOUT
)

# Verify the Experiment results.
verify_experiment_results(katib_client, experiment, exp_name, exp_namespace)

# Print the Experiment and Suggestion.
logging.debug(katib_client.get_experiment(exp_name, exp_namespace))
logging.debug(katib_client.get_suggestion(exp_name, exp_namespace))


if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
Expand Down Expand Up @@ -194,7 +149,6 @@ def objective(parameters):
namespace_labels['katib.kubeflow.org/metrics-collector-injection'] = 'enabled'
client.CoreV1Api().patch_namespace(args.namespace, {'metadata': {'labels': namespace_labels}})

# Test with run_e2e_experiment
try:
run_e2e_experiment(katib_client, experiment, exp_name, exp_namespace)
logging.info("---------------------------------------------------------------")
Expand All @@ -208,19 +162,3 @@ def objective(parameters):
logging.info("---------------------------------------------------------------")
logging.info("---------------------------------------------------------------")
katib_client.delete_experiment(exp_name, exp_namespace)

# Test with run_e2e_experiment_create_by_tune
tune_exp_name = exp_name + "-by-tune"
try:
run_e2e_experiment_create_by_tune(katib_client, tune_exp_name, exp_namespace)
logging.info("---------------------------------------------------------------")
logging.info(f"E2E is succeeded for Experiment created by tune: {exp_namespace}/{tune_exp_name}")
except Exception as e:
logging.info("---------------------------------------------------------------")
logging.info(f"E2E is failed for Experiment created by tune: {exp_namespace}/{tune_exp_name}")
raise e
finally:
# Delete the Experiment.
logging.info("---------------------------------------------------------------")
logging.info("---------------------------------------------------------------")
katib_client.delete_experiment(tune_exp_name, exp_namespace)

0 comments on commit 6235a39

Please sign in to comment.