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

Python SDK for katib #1177

Merged
merged 20 commits into from
Jun 4, 2020
Merged

Python SDK for katib #1177

merged 20 commits into from
Jun 4, 2020

Conversation

prem0912
Copy link
Contributor

@prem0912 prem0912 commented May 5, 2020

1, Added Python SDK for katib
2. Added Documents and Readme

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

Review Jupyter notebook visual diffs & provide feedback on notebooks.


Powered by ReviewNB

@kubeflow-bot
Copy link

This change is Reviewable

@k8s-ci-robot
Copy link

Hi @prem0912. Thanks for your PR.

I'm waiting for a kubeflow member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@prem0912 prem0912 changed the title Python katib SDK Python SDK for katib deployment May 5, 2020
@prem0912 prem0912 changed the title Python SDK for katib deployment Python SDK for katib May 5, 2020
@prem0912
Copy link
Contributor Author

prem0912 commented May 5, 2020

/assign @johnugeorge

Copy link
Member

@andreyvelich andreyvelich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prem0912 Thank you for doing this!
I left comments.

Install via [Setuptools](http://pypi.python.org/pypi/setuptools).

```sh
python setup.py install --user
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to move Katib SDK to pip @johnugeorge ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to recommend pip way of installation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok .. working on it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added pip way installation and updated Readme.md

sdk/python/README.md Outdated Show resolved Hide resolved
[KatibClient](docs/KatibClient.md) | [get_optimal_hyperparmeters](docs/KatibClient.md#get_optimal_hyperparmeters) | Get status, currentOptimalTrial with paramaterAssignments of an Experiment|


## Documentation For Models
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add script to update models?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will add it in next PR

"metadata": {},
"outputs": [],
"source": [
"! python setup.py install"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure that we need this setup script in Example, since we already mentioned how to install SDK in README.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed from examples

sdk/python/examples/bayesianoptimization-katib-sdk.ipynb Outdated Show resolved Hide resolved
sdk/python/examples/bayesianoptimization-katib-sdk.ipynb Outdated Show resolved Hide resolved
sdk/python/examples/bayesianoptimization-katib-sdk.ipynb Outdated Show resolved Hide resolved
" )\n",
"\n",
"# Metric Collector\n",
"collector = V1alpha3CollectorSpec(kind = \"TensorFlowEvent\")\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For BO I think you can delete this Metrics Collector.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deleted metrics Collector


katibexp = self.get_experiment(name, namespace=namespace)
result = {}
result["status"] = katibexp.get("status", {}).get("conditions", [])[-1].get("type")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to return Experiment status here? Since we have get_experiment_status API ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is needed because we are able to get optimized hyperparameter even only some of the trials are completed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, maybe users should handle this situation? For example, if get_optimal_hyperparmeters return [] run list_trials to check Trial statuses.
How experiment status can help user with it?
Experiment status can be running, but some Trials can be finished.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok will remove status from optimized hyperparameter API

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed status from optimized hyperparameter API

sdk/python/OWNERS Outdated Show resolved Hide resolved
@johnugeorge
Copy link
Member

@prem0912 Looks like you cannot be added to owners without being added to Kubeflow org. Can we add owners in a separate PR then?

@@ -0,0 +1,92 @@
# Kubeflow Katib SDK
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also link this SDK page from the main Katib Readme file?

Copy link
Contributor Author

@prem0912 prem0912 May 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated main Readme file

def create_experiment(self, name, namespace=None):
"""
Create the katib experiment
:param name: experiment object
Copy link
Member

@sperlingxx sperlingxx May 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think body (or object) is more appropriate than name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes updated


self.api_instance = client.CustomObjectsApi()

def _is_ipython(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unifying indents to 4 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@k8s-ci-robot
Copy link

The following users are mentioned in OWNERS file(s) but are not members of the kubeflow org.

Once all users have been added as members of the org, you can trigger verification by writing /verify-owners in a comment.

  • prem0912
    • sdk/python/OWNERS

@prem0912
Copy link
Contributor Author

prem0912 commented May 8, 2020

@prem0912 Looks like you cannot be added to owners without being added to Kubeflow org. Can we add owners in a separate PR then?

@johnugeorge removed OWNERS file

@gaocegege
Copy link
Member

/ok-to-test

@gaocegege
Copy link
Member

/cc @johnugeorge @andreyvelich @sperlingxx

Can you please give another review? Thanks

@gaocegege
Copy link
Member

/retest

@johnugeorge
Copy link
Member

@prem0912 can you rebase this PR?

"from kubernetes.client import V1PodTemplateSpec\n",
"from kubernetes.client import V1ObjectMeta\n",
"from kubernetes.client import V1PodSpec\n",
"from kubernetes.client import V1Container"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't find where you use V1PodTemplateSpec, V1PodSpec, V1Container in bayesianoptimization-katib-sdk.ipynb example.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed unused imports

},
"outputs": [],
"source": [
"import kubeflow.katib as kc\n",
Copy link
Member

@andreyvelich andreyvelich Jun 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe instead of importing kubeflow.katib as kc, just import required components.
I believe, for your example you can left:

from kubeflow.katib import KatibClient
from kubeflow.katib import utils
from kubeflow.katib import V1alpha3AlgorithmSetting
from kubeflow.katib import V1alpha3AlgorithmSpec
from kubeflow.katib import V1alpha3Experiment
from kubeflow.katib import V1alpha3ExperimentSpec
from kubeflow.katib import V1alpha3FeasibleSpace
from kubeflow.katib import V1alpha3GoTemplate
from kubeflow.katib import V1alpha3ObjectiveSpec
from kubeflow.katib import V1alpha3ParameterSpec
from kubeflow.katib import V1alpha3TrialTemplate

So it will not confuse user with other imports. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its better to import all the components because people will know what are the other components available to make use.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks.

}
],
"source": [
"kclient.get_experiment(name=\"bayesianoptimization\", namespace=None)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can use namespace=namespace here, like you did with other API calls to be consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

"metadata": {},
"outputs": [],
"source": [
" kclient.delete_experiment(name=\"bayesianoptimization\", namespace=namespace)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to move delete_experiment to the latest command in example.
You are run few commands after deleting Experiment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

"from kubernetes.client import V1PodTemplateSpec\n",
"from kubernetes.client import V1ObjectMeta\n",
"from kubernetes.client import V1PodSpec\n",
"from kubernetes.client import V1Container"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same suggestion as I left for BO example.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed unused imports

@prem0912
Copy link
Contributor Author

prem0912 commented Jun 3, 2020

@johnugeorge rebased to upstream

Copy link
Member

@andreyvelich andreyvelich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prem0912 Thank you for doing this!
/lgtm
/cc @gaocegege @johnugeorge

@johnugeorge
Copy link
Member

/approve

@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: johnugeorge

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@johnugeorge
Copy link
Member

@jlewi How can we remove the label - invalid-owners-file? This was added by an earlier commit which is fixed. Can we re trigger?

@andreyvelich
Copy link
Member

/verify-owners

1 similar comment
@gaocegege
Copy link
Member

/verify-owners

@jlewi
Copy link
Contributor

jlewi commented Jun 4, 2020

@andreyvelich @johnugeorge You might want to look at GitHub permissions to see if there are fine grained roles that would allow key owners to add labels using the labels (e.g. the issue triage role, or maybe maintainers). And then create a GitHub team with appropriate owners in that team

@k8s-ci-robot k8s-ci-robot merged commit c2c5288 into kubeflow:master Jun 4, 2020
@andreyvelich
Copy link
Member

@jlewi I can see that Triage role can apply labels (https://help.github.com/en/github/setting-up-and-managing-organizations-and-teams/repository-permission-levels-for-an-organization#repository-access-for-each-permission-level).
Do you know, can Triage role also removing labels from the PRs?

sperlingxx pushed a commit to sperlingxx/katib that referenced this pull request Jul 9, 2020
* python SDK for katib with docs and examples

* Update README.md

* Update README.md

* Update bayesianoptimization-katib-sdk.ipynb

* Update bayesianoptimization-katib-sdk.ipynb

* Update tfjob-katib-sdk.ipynb

* Create OWNERS

* Update bayesianoptimization-katib-sdk.ipynb

* Update tfjob-katib-sdk.ipynb

* Update bayesianoptimization-katib-sdk.ipynb

* Update tfjob-katib-sdk.ipynb

* Update bayesianoptimization-katib-sdk.ipynb

* Update OWNERS

* Update README.md

* updated changes as per review comments

* Update README.md

* Update README.md

* Added pip installation for katib sdk and removed status from get_optimal_hyperparamater API

* Update README.md

* Updated changes for delete_exp and removed unused imports
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants