Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[hotfix]: filter by name of experiment #1920

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 31 additions & 21 deletions sdk/python/v1beta1/kubeflow/katib/api/katib_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ def list_experiments(self, namespace=None):
async_req=True)

katibexp = None
result = []
try:
katibexp = thread.get(constants.APISERVER_TIMEOUT)
result = [
Expand Down Expand Up @@ -339,17 +340,20 @@ def list_trials(self, name=None, namespace=None):
async_req=True)

katibtrial = None
result = []
try:
katibtrial = thread.get(constants.APISERVER_TIMEOUT)
result = [
self.api_client.deserialize(utils.FakeResponse(item), V1beta1Trial)
for item in katibtrial.get("items")
]

for item in katibtrial.get("items"):
if name is not None and item.get("metadata", {}).get("ownerReferences")[0].get("name") != name:
continue

result.append(self.api_client.deserialize(utils.FakeResponse(item), V1beta1Trial))
except multiprocessing.TimeoutError:
raise RuntimeError("Timeout trying to getkatib experiment.")
raise RuntimeError("Timeout trying to get katib experiment.")
except client.rest.ApiException as e:
raise RuntimeError(
"Exception when calling CustomObjectsApi->get_namespaced_custom_object:\
"Exception when calling CustomObjectsApi->list_namespaced_custom_object:\
%s\n" % e)
except Exception as e:
raise RuntimeError(
Expand Down Expand Up @@ -378,32 +382,38 @@ def get_success_trial_details(self, name=None, namespace=None):
async_req=True)

katibtrial = None
result = []
try:
katibtrial = thread.get(constants.APISERVER_TIMEOUT)
result = []
for i in katibtrial.get("items"):

for item in katibtrial.get("items"):
status = item.get("status", {}).get("conditions", [])[-1].get("type")
if status != "Succeeded":
continue

if name is not None and item.get("metadata", {}).get("ownerReferences")[0].get("name") != name:
continue

output = {}
if i.get("metadata", {}).get("ownerReferences")[0].get("name") == name:
status = i.get("status", {}).get("conditions", [])[-1].get("type")
if status == "Succeeded":
output["name"] = i.get("metadata", {}).get("name")
output["hyperparameters"] = i.get("spec", {}).get("parameterAssignments", [])
output["metrics"] = (
i.get("status", {})
.get("observation", {})
.get("metrics", [])
)
result.append(output)
output["name"] = item.get("metadata", {}).get("name")
output["hyperparameters"] = item.get("spec", {}).get("parameterAssignments", [])
output["metrics"] = (
item.get("status", {})
.get("observation", {})
.get("metrics", [])
)
result.append(output)
except multiprocessing.TimeoutError:
raise RuntimeError("Timeout trying to getkatib experiment.")
raise RuntimeError("Timeout trying to get succeeded trials of the katib experiment.")
except client.rest.ApiException as e:
raise RuntimeError(
"Exception when calling CustomObjectsApi->get_namespaced_custom_object:\
"Exception when calling CustomObjectsApi->list_namespaced_custom_object:\
%s\n" % e)
except Exception as e:
raise RuntimeError(
"There was a problem to get experiment {0} in namespace {1}. Exception: \
{2} ".format(name, namespace, e))

return result

def get_optimal_hyperparameters(self, name=None, namespace=None):
Expand Down