Skip to content

Commit

Permalink
Merge pull request #1221 from EdmilsonRodrigues/jasyncio
Browse files Browse the repository at this point in the history
#1221

#### Description

*<I created a new file called _jasyncio, passed all functions from jasyncio to there, but maintained the jasyncio file with a deprecation warning. Then, I changed jasyncio to _jasyncio or asyncio in all files that it appeared.>*

*<Fixes: Stopped using jasyncio and imported asynchronous functions directly from asyncio>*


#### QA Steps

*<Commands / tests / steps to run to verify that the change works: I do not know yet, this is my first contribution to an open source project, and I could use some guidance.>*

```
tox -e py3 -- tests/unit/...
```

```
tox -e integration -- tests/integration/...
```

All CI tests need to pass.

*<Please note that most likely an additional test will be required by the reviewers for any change that's not a one liner to land.>*

#### Notes & Discussion

*<This is my first time contributing and I am still learning how. Can you help me telling how can I test if the changes work, if I should do more smaller commits or only big commits, or any other guidance of how to work on this project?>*
  • Loading branch information
jujubot authored Dec 17, 2024
2 parents b5f7a5a + 38280e0 commit 9734c81
Show file tree
Hide file tree
Showing 73 changed files with 378 additions and 347 deletions.
13 changes: 0 additions & 13 deletions docs/api/juju.loop.rst

This file was deleted.

2 changes: 0 additions & 2 deletions docs/api/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ Public APIs
===========

It is recommended that you start with :doc:`juju.model` or :doc:`juju.controller`.
If you need helpers to manage the asyncio loop, try :doc:`juju.loop`.

.. toctree::

Expand All @@ -16,7 +15,6 @@ If you need helpers to manage the asyncio loop, try :doc:`juju.loop`.
juju.errors
juju.exceptions
juju.juju
juju.loop
juju.machine
juju.model
juju.placement
Expand Down
4 changes: 2 additions & 2 deletions examples/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"""

import asyncio
import logging

from juju import jasyncio
from juju.model import Model


Expand Down Expand Up @@ -50,4 +50,4 @@ async def main():
logging.basicConfig(level=logging.DEBUG)
ws_logger = logging.getLogger("websockets.protocol")
ws_logger.setLevel(logging.INFO)
jasyncio.run(main())
asyncio.run(main())
4 changes: 2 additions & 2 deletions examples/add_k8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
"""

import asyncio
import base64
import logging
import os

import yaml

from juju import jasyncio
from juju.client import client
from juju.controller import Controller

Expand Down Expand Up @@ -58,4 +58,4 @@ async def main():
logging.basicConfig(level=logging.DEBUG)
ws_logger = logging.getLogger("websockets.protocol")
ws_logger.setLevel(logging.INFO)
jasyncio.run(main())
asyncio.run(main())
4 changes: 2 additions & 2 deletions examples/add_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"""

import asyncio
import logging

from juju import jasyncio
from juju.model import Model

MB = 1
Expand Down Expand Up @@ -69,4 +69,4 @@ async def main():
ws_logger = logging.getLogger("websockets.protocol")
ws_logger.setLevel(logging.INFO)

jasyncio.run(main())
asyncio.run(main())
4 changes: 2 additions & 2 deletions examples/add_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import uuid
from logging import getLogger

from juju import jasyncio, utils
from juju import utils
from juju.controller import Controller

LOG = getLogger(__name__)
Expand Down Expand Up @@ -65,4 +65,4 @@ async def main():


if __name__ == "__main__":
jasyncio.run(main())
asyncio.run(main())
5 changes: 3 additions & 2 deletions examples/add_secrets_backend.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Copyright 2023 Canonical Ltd.
# Licensed under the Apache V2, see LICENCE file for details.

import asyncio

import hvac

from juju import jasyncio
from juju.model import Model


Expand Down Expand Up @@ -75,4 +76,4 @@ async def main():


if __name__ == "__main__":
jasyncio.run(main())
asyncio.run(main())
4 changes: 2 additions & 2 deletions examples/allwatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"""

import asyncio
import logging

from juju import jasyncio
from juju.client import client
from juju.model import Model

Expand All @@ -34,4 +34,4 @@ async def watch():
ws_logger.setLevel(logging.INFO)
# Run loop until the process is manually stopped (watch will loop
# forever).
jasyncio.run(watch())
asyncio.run(watch())
5 changes: 3 additions & 2 deletions examples/charmhub_deploy_k8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"""

from juju import jasyncio
import asyncio

from juju.model import Model


Expand Down Expand Up @@ -40,4 +41,4 @@ async def main():


if __name__ == "__main__":
jasyncio.run(main())
asyncio.run(main())
5 changes: 3 additions & 2 deletions examples/charmhub_deploy_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"""

from juju import jasyncio
import asyncio

from juju.model import Model


Expand Down Expand Up @@ -37,4 +38,4 @@ async def main():


if __name__ == "__main__":
jasyncio.run(main())
asyncio.run(main())
4 changes: 2 additions & 2 deletions examples/charmhub_find.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
repository for charms.
"""

import asyncio
import logging

from juju import jasyncio
from juju.model import Model

log = logging.getLogger(__name__)
Expand All @@ -33,4 +33,4 @@ async def main():

if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
jasyncio.run(main())
asyncio.run(main())
4 changes: 2 additions & 2 deletions examples/charmhub_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
repository for information about a given charm.
"""

import asyncio
import logging

from juju import jasyncio
from juju.model import Model

log = logging.getLogger(__name__)
Expand All @@ -29,4 +29,4 @@ async def main():

if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
jasyncio.run(main())
asyncio.run(main())
4 changes: 2 additions & 2 deletions examples/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"""

import asyncio
import logging

from juju import jasyncio
from juju.controller import Controller


Expand All @@ -28,4 +28,4 @@ async def main():
logging.basicConfig(level=logging.DEBUG)
ws_logger = logging.getLogger("websockets.protocol")
ws_logger.setLevel(logging.INFO)
jasyncio.run(main())
asyncio.run(main())
4 changes: 2 additions & 2 deletions examples/clouds.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"""

import asyncio
import logging

from juju import jasyncio
from juju.controller import Controller


Expand All @@ -28,4 +28,4 @@ async def main():
logging.basicConfig(level=logging.DEBUG)
ws_logger = logging.getLogger("websockets.protocol")
ws_logger.setLevel(logging.INFO)
jasyncio.run(main())
asyncio.run(main())
4 changes: 2 additions & 2 deletions examples/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"""

import asyncio
import logging

from juju import jasyncio
from juju.model import Model

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -59,4 +59,4 @@ async def main():
# logging.basicConfig(level=logging.DEBUG)
ws_logger = logging.getLogger("websockets.protocol")
ws_logger.setLevel(logging.INFO)
jasyncio.run(main())
asyncio.run(main())
4 changes: 2 additions & 2 deletions examples/connect_current_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
and prints the number of applications deployed to it.
"""

import asyncio
import logging

from juju import jasyncio
from juju.model import Model

log = logging.getLogger(__name__)
Expand All @@ -27,4 +27,4 @@ async def main():

if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
jasyncio.run(main())
asyncio.run(main())
4 changes: 2 additions & 2 deletions examples/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"""

import asyncio
import logging

from juju import jasyncio
from juju.controller import Controller


Expand Down Expand Up @@ -41,4 +41,4 @@ async def main():
logging.basicConfig(level=logging.DEBUG)
ws_logger = logging.getLogger("websockets.protocol")
ws_logger.setLevel(logging.INFO)
jasyncio.run(main())
asyncio.run(main())
4 changes: 2 additions & 2 deletions examples/credential.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Copyright 2023 Canonical Ltd.
# Licensed under the Apache V2, see LICENCE file for details.

import asyncio
import sys

from juju import jasyncio
from juju.controller import Controller


Expand Down Expand Up @@ -47,4 +47,4 @@ async def main(cloud_name, credential_name):

if __name__ == "__main__":
assert len(sys.argv) > 2, "Please provide a cloud and credential name"
jasyncio.run(main(sys.argv[1], sys.argv[2]))
asyncio.run(main(sys.argv[1], sys.argv[2]))
4 changes: 2 additions & 2 deletions examples/crossmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
"""

import asyncio
import tempfile
from logging import getLogger

from juju import jasyncio
from juju.controller import Controller

log = getLogger(__name__)
Expand Down Expand Up @@ -83,4 +83,4 @@ async def main():


if __name__ == "__main__":
jasyncio.run(main())
asyncio.run(main())
4 changes: 2 additions & 2 deletions examples/crossmodel_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
"""

import asyncio
import time
from logging import getLogger
from pathlib import Path

from juju import jasyncio
from juju.controller import Controller

log = getLogger(__name__)
Expand Down Expand Up @@ -87,4 +87,4 @@ async def main():


if __name__ == "__main__":
jasyncio.run(main())
asyncio.run(main())
4 changes: 2 additions & 2 deletions examples/crossmodel_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
10. Destroys models and disconnects
"""

import asyncio
import tempfile
from logging import getLogger

from juju import jasyncio
from juju.controller import Controller

log = getLogger(__name__)
Expand Down Expand Up @@ -92,4 +92,4 @@ async def main():


if __name__ == "__main__":
jasyncio.run(main())
asyncio.run(main())
4 changes: 2 additions & 2 deletions examples/crossmodel_relation.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
"""

import asyncio
import tempfile
import time
from logging import getLogger

from juju import jasyncio
from juju.controller import Controller

log = getLogger(__name__)
Expand Down Expand Up @@ -106,4 +106,4 @@ async def main():


if __name__ == "__main__":
jasyncio.run(main())
asyncio.run(main())
5 changes: 3 additions & 2 deletions examples/debug-log.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

"""This example demonstrate how debug-log works"""

from juju import jasyncio
import asyncio

from juju.model import Model


Expand Down Expand Up @@ -34,4 +35,4 @@ async def main():


if __name__ == "__main__":
jasyncio.run(main())
asyncio.run(main())
Loading

0 comments on commit 9734c81

Please sign in to comment.