-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
feat: add examples for asynchronous usage (callback, asycio) #324
Conversation
Could you add an example with a thanks for working on this. |
I think callbacks don't work well with I've prepared a modification to |
@tomplus The new swagger codegen supports asyncio. We need to remove our manual changes to api_client.py file and then use the new version of generator. Then we can update this example and check it in. I will create an umbrella issue for that. Thanks for being patient. |
@mbohlool Thanks, I'll check the new swagger too. |
@tomplus The master now does not have any manual changes in api_client.py. Can you checkout the asyncio python client in swagger-codegen? I assume it is a simple flag and you should be able to change our generator script to set the flag and try the client. As you are more familiar with this topic than me, you would be a good judge on this. Thanks. |
@mbohlool Sure, I'll do it over the weekend. |
I've regenerated library using swagger-codegen with switch Finally I have working piece of asynchronous code:
I can submit my changes but I have one fundamental question. Using the asyncio library in swagger-codegen will generate new REST client based on aiohttp instead of urlib3. It means that we get completely new library... Do we want to start deploy new library ? I'm not sure. It would be better to have two different REST client inside one library. Let me know what do you think . |
We may want to start with having |
@mbohlool agree with your assessment. We can experiment elsewhere and bring it back if it shows promise. |
I discovered the end of this thread too late. (did the same regeneration that @tomplus had already did) |
I'm working on it in my free time. There were some issues in swagger/asyncio generator which had to be fixed. I hope I'll publish async version in next month. Stay tuned... |
At last I’ve prepared the new library kubernetes_asyncio which is based on this Python client, but uses the asyncio generator from swagger-codegen. I've added a script to create this client to kubernetes-client/gen repo in this PR kubernetes-client/gen#60. I've also decided to incorporate functionality from sub-repository kubernetes-client/python-base because a lot of changes according to asyncio were needed. Please take a look. Do you think it's possible to migrate this project to official kubernetes-clients' repo ? |
"Thank you" doesn't come often enough in the open source world. The small startup where I work bet on Kubernetes and Python as base server technologies eighteen months ago, and so far we haven't regretted it (and AWS have come on board with a managed service). Async operations bundled in will be a huge win for the Python community. So, thank you to everyone who's working on this development (or has done so). |
@tomplus Thanks for working on this! The examples seem to be outdated (IIUC it's compatible with release-3.0), but we definitely want to give the asyncio library (https://github.com/tomplus/kubernetes_asyncio) a try and see what people think about it. Asyncio is introduced in Python 3 and we need to support Python 2.7, so we have to keep the old synchronous library in this package. I'd suggest we having a The We could have two new branches |
@roycaihw Many thanks for your response. kubernetes_asyncio is almost identical from user point of view (only changing imports and async syntax are required). I watch the official repository and catch up changes. It would be much easier if the library became experimental/official. Thanks for considering this issue. Unfortunately there are a lot of changes related to classes from python-base. To be honest I had to rewrite Watch, Stream to be able to work in the asynchronous environment. We can try using the named branches but it may be confusing for contributors. I have other 2 options to discuss:
WRT final libraries, I think it’d be better to have libraries in separate repositories instead of branches, it’s more common to have a repository per package, it’s easy to install from repo, issues are tracked separately etc. |
Hello guys, is there any way to push this forward? |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
/remove-lifecycle stale |
@tomplus is this still relevant? how should we move forward with this? |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
/remove-lifecycle stale |
/lifecycle frozen |
@tomplus I like your proposal for python-base below: "I can create dedicated classes for asyncio with different names (like AsyncWatch, AsyncStream etc.) in python-base repo. This classes will be imported by kubernetes_asyncio and exported again with previous name. This trick allows us to have the common python-base and consistent libraries." For async library, i'm thinking to have a separate directory inside python repo for asyncio, instead of a separate repo. then the releases / issues are all tracked in one repo. The current library and the async one should be kept independent, separate. of course we need to clearly state in the release note that the async library is new, and for preview. The library has stopped supporting python 2 starting from v18.0.0. so the async library can be added in v18.0.0 or later. |
it's pending #1413. The plan is to drop python 2 in v18.x.0b1. ETA is next Monday for v17 GA, and next week or two for v18.x.0b1. |
The This bot removes
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /remove-lifecycle frozen |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
I am using kubernetes-asyncio successfully and I'm a bit confused about what is remaining in this issue (and why it's going "stale" while the requested features exists). |
kubernetes-asyncio currently lives under tomplus's, the issue is to merge it to the github.com/kubernetes-client/python |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /close |
@k8s-triage-robot: Closed this PR. In response to this:
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. |
/reopen |
@yliaog: Reopened this PR. In response to this:
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. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: tomplus The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /close |
@k8s-triage-robot: Closed this PR. In response to this:
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. |
/reopen |
@Ark-kun: You can't reopen an issue/PR unless you authored it or you are a collaborator. In response to this:
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. |
Any progress on this? |
I added examples how to use a callback and how the library can be integrated with
asyncio
. Should I add this examples to readme too ?Related to #323