from juju import jasyncio
from juju.model import Model


async def main():
    model = Model()
    print('Connecting to model')
    # Connect to current model with current user, per Juju CLI
    await model.connect()

    try:
        print('Deploying bundle')
        applications = await model.deploy(
            './examples/k8s-local-bundle/bundle.yaml',
        )

        print('Waiting for active')
        await model.wait_for_idle(status='active')
        print("Successfully deployed!")

        await applications[0].upgrade_charm(path='./examples/charms/onos.charm')

        await model.wait_for_idle(status='active')

        print('Removing bundle')
        for application in applications:
            await application.remove()
    finally:
        print('Disconnecting from model')
        await model.disconnect()
        print("Success")


if __name__ == '__main__':
    jasyncio.run(main())

from juju import jasyncio
from juju.model import Model


async def main():
    model = Model()
    print('Connecting to model')
    # Connect to current model with current user, per Juju CLI
    await model.connect()

    try:
        print('Deploying bundle')
        applications = await model.deploy(
            './examples/k8s-local-bundle/bundle.yaml',
        )

        print('Waiting for active')
        await model.wait_for_idle(status='active')
        print("Successfully deployed!")

        local_path = './examples/charms/onos.charm'
        print('Upgrading charm with %s' % local_path)
        await applications[0].upgrade_charm(path=local_path)

        await model.wait_for_idle(status='active')

        print('Removing bundle')
        for application in applications:
            await application.remove()
    finally:
        print('Disconnecting from model')
        await model.disconnect()
        print("Success")


if __name__ == '__main__':
    jasyncio.run(main())

Make the example more informative
Make the example more informative

  from juju import jasyncio
  from juju.model import Model
  
  
  async def main():
      model = Model()
      print('Connecting to model')
      # Connect to current model with current user, per Juju CLI
      await model.connect()
  
      try:
          print('Deploying bundle')
          applications = await model.deploy(
              './examples/k8s-local-bundle/bundle.yaml',
          )
  
          print('Waiting for active')
          await model.wait_for_idle(status='active')
          print("Successfully deployed!")
  
+         local_path = './examples/charms/onos.charm'
+         print('Upgrading charm with %s' % local_path)
-         await applications[0].upgrade_charm(path='./examples/charms/onos.charm')
+         await applications[0].upgrade_charm(path=local_path)
  
          await model.wait_for_idle(status='active')
  
          print('Removing bundle')
          for application in applications:
              await application.remove()
      finally:
          print('Disconnecting from model')
          await model.disconnect()
          print("Success")
  
  
  if __name__ == '__main__':
      jasyncio.run(main())
  
Make the example more informative
## Code Before:
from juju import jasyncio
from juju.model import Model


async def main():
    model = Model()
    print('Connecting to model')
    # Connect to current model with current user, per Juju CLI
    await model.connect()

    try:
        print('Deploying bundle')
        applications = await model.deploy(
            './examples/k8s-local-bundle/bundle.yaml',
        )

        print('Waiting for active')
        await model.wait_for_idle(status='active')
        print("Successfully deployed!")

        await applications[0].upgrade_charm(path='./examples/charms/onos.charm')

        await model.wait_for_idle(status='active')

        print('Removing bundle')
        for application in applications:
            await application.remove()
    finally:
        print('Disconnecting from model')
        await model.disconnect()
        print("Success")


if __name__ == '__main__':
    jasyncio.run(main())

## Instruction:
Make the example more informative
## Code After:
from juju import jasyncio
from juju.model import Model


async def main():
    model = Model()
    print('Connecting to model')
    # Connect to current model with current user, per Juju CLI
    await model.connect()

    try:
        print('Deploying bundle')
        applications = await model.deploy(
            './examples/k8s-local-bundle/bundle.yaml',
        )

        print('Waiting for active')
        await model.wait_for_idle(status='active')
        print("Successfully deployed!")

        local_path = './examples/charms/onos.charm'
        print('Upgrading charm with %s' % local_path)
        await applications[0].upgrade_charm(path=local_path)

        await model.wait_for_idle(status='active')

        print('Removing bundle')
        for application in applications:
            await application.remove()
    finally:
        print('Disconnecting from model')
        await model.disconnect()
        print("Success")


if __name__ == '__main__':
    jasyncio.run(main())
