https://prefect.io logo
Title
b

Brad

03/15/2022, 9:04 PM
hey team - orion 2.0b1 is throwing some typer errors on success (I can see they are succeeding but it looks potentially misleading)
Set default storage to 'local'.
Traceback (most recent call last):
  File "/home/brad/.local/pipx/venvs/prefect/lib/python3.9/site-packages/prefect/cli/base.py", line 58, in wrapper
    return fn(*args, **kwargs)
  File "/home/brad/.local/pipx/venvs/prefect/lib/python3.9/site-packages/prefect/utilities/asyncio.py", line 120, in wrapper
    return run_async_in_new_loop(async_fn, *args, **kwargs)
  File "/home/brad/.local/pipx/venvs/prefect/lib/python3.9/site-packages/prefect/utilities/asyncio.py", line 67, in run_async_in_new_loop
    return anyio.run(partial(__fn, *args, **kwargs))
  File "/home/brad/.local/pipx/venvs/prefect/lib/python3.9/site-packages/anyio/_core/_eventloop.py", line 56, in run
    return asynclib.run(func, *args, **backend_options)
  File "/home/brad/.local/pipx/venvs/prefect/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 233, in run
    return native_run(wrapper(), debug=debug)
  File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/home/brad/.local/pipx/venvs/prefect/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 228, in wrapper
    return await func(*args)
  File "/home/brad/.local/pipx/venvs/prefect/lib/python3.9/site-packages/prefect/cli/storage.py", line 136, in create
    exit_with_success(f"Set default storage to {name!r}.")
  File "/home/brad/.local/pipx/venvs/prefect/lib/python3.9/site-packages/prefect/cli/base.py", line 193, in exit_with_success
    raise typer.Exit(0)
click.exceptions.Exit: 0
An exception occurred.
:thank-you: 3
a

Anna Geller

03/15/2022, 9:15 PM
How did you install it? I couldn't reproduce the issue.
Can you try reinstalling using:
pip install -U "prefect==2.0b1"
And then running a simple hello world flow like this?
from prefect import task, flow
from prefect import get_run_logger


@task
def say_hi():
    logger = get_run_logger()
    <http://logger.info|logger.info>("Hello world!")


@flow
def hello_world():
    say_hi()


from prefect.deployments import DeploymentSpec

DeploymentSpec(
    name="hello_world_dev",
    flow=hello_world,
    flow_location="/Users/anna/repos/gitops-orion-flows/flows/hello_world.py",
)

if __name__ == "__main__":
    flow_run_state = hello_world()
and if nothing else works, you can remove or reset the database:
prefect orion database reset -y
Also - you can now help us reproduce your issue by sharing the output of the
prefect version
command which is incredibly slick - shoutout to @Zanie for that πŸ™‚
d

Darshan

03/15/2022, 9:25 PM
https://orion-docs.prefect.io/collections/overview.md seems to be broken. Getting 404.
:thank-you: 1
a

Anna Geller

03/15/2022, 9:26 PM
thx for reporting that πŸ™
d

Darshan

03/15/2022, 9:26 PM
https://orion-docs.prefect.io/collections/overview/ this one seems to be working fine
a

Anna Geller

03/15/2022, 9:26 PM
without the .md
d

Darshan

03/15/2022, 9:27 PM
Yep, may be updating the link in slack messages and discourse will be helpful for others
πŸ‘ 2
βœ… 1
b

Brad

03/15/2022, 9:29 PM
Hey @Anna Geller I have prefect install with
pipx
in a clean env
❯ pipx install prefect==2.0b1                                                                                                                                                                                                                                                                                                       08:29:38
  installed package prefect 2.0b1, Python 3.9.7
  These apps are now globally available
    - prefect
done! ✨ 🌟 ✨

❯ rm ~/.prefect/orion.db                                                                                                                                                                                                                                                                                                            08:30:05

❯ prefect orion database reset                                                                                                                                                                                                                                                                                                      08:30:11
Are you sure you want to reset the Orion database located at "sqlite+aiosqlite://///home/brad/.prefect/orion.db"? This will drop and recreate all tables. [y/N]: y
Resetting Orion database...
Dropping tables...
Creating tables...
Orion database "sqlite+aiosqlite://///home/brad/.prefect/orion.db" reset!
Traceback (most recent call last):
  File "/home/brad/.local/pipx/venvs/prefect/lib/python3.9/site-packages/prefect/cli/base.py", line 58, in wrapper
    return fn(*args, **kwargs)
  File "/home/brad/.local/pipx/venvs/prefect/lib/python3.9/site-packages/prefect/utilities/asyncio.py", line 120, in wrapper
    return run_async_in_new_loop(async_fn, *args, **kwargs)
  File "/home/brad/.local/pipx/venvs/prefect/lib/python3.9/site-packages/prefect/utilities/asyncio.py", line 67, in run_async_in_new_loop
    return anyio.run(partial(__fn, *args, **kwargs))
  File "/home/brad/.local/pipx/venvs/prefect/lib/python3.9/site-packages/anyio/_core/_eventloop.py", line 56, in run
    return asynclib.run(func, *args, **backend_options)
  File "/home/brad/.local/pipx/venvs/prefect/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 233, in run
    return native_run(wrapper(), debug=debug)
  File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/home/brad/.local/pipx/venvs/prefect/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 228, in wrapper
    return await func(*args)
  File "/home/brad/.local/pipx/venvs/prefect/lib/python3.9/site-packages/prefect/cli/orion.py", line 220, in reset
    exit_with_success(f'Orion database "{engine.url}" reset!')
  File "/home/brad/.local/pipx/venvs/prefect/lib/python3.9/site-packages/prefect/cli/base.py", line 193, in exit_with_success
    raise typer.Exit(0)
click.exceptions.Exit: 0
An exception occurred.
a

Anna Geller

03/15/2022, 9:30 PM
what about your prefect version @Brad? did you try the hello world flow - did it return the same error?
b

Brad

03/15/2022, 9:30 PM
^ fresh install, wipe orion db
db reset gives me the same error
a

Anna Geller

03/15/2022, 9:31 PM
now I have to learn what is pipx πŸ˜‚
b

Brad

03/15/2022, 9:31 PM
its basically just a clean venv for cli tools
a

Anna Geller

03/15/2022, 9:31 PM
can you maybe just try using normal pip like old-school people like me? haha
b

Brad

03/15/2022, 9:31 PM
yep, let me try in a clean conda env
πŸ‘ 1
a

Anna Geller

03/15/2022, 9:32 PM
maybe pipx doesn't have the latest repository from pip?
z

Zanie

03/15/2022, 9:32 PM
πŸ˜„ I can reproduce this
a

Anna Geller

03/15/2022, 9:32 PM
πŸ˜„
z

Zanie

03/15/2022, 9:32 PM
The success exit exception is not being properly captured
There’s no real error here, just a bad message.
b

Brad

03/15/2022, 9:33 PM
yeah copy that @Zanie - just wanted to raise typer was handling the clean exit loudly
:thank-you: 2
same issue in a clean conda env
just an FYI
j

justabill

03/15/2022, 9:34 PM
That you for letting us know about the mis-formatted link @Darshan, I have updated it in the announcement post.
πŸ‘ 3
@Brad I've reproduced the issue you identified as well and made a note of it. I'll let you know when we ship a change to that message.
z

Zanie

03/15/2022, 9:42 PM
If you want to patch it before we cut a release:
index 2f7a0d4c9..a1368848c 100644
--- a/src/prefect/cli/base.py
+++ b/src/prefect/cli/base.py
@@ -13,6 +13,7 @@ import pendulum
 import rich.console
 import typer
 import typer.core
+from click.exceptions import ClickException
 
 import prefect
 import prefect.context
@@ -56,6 +57,8 @@ def with_cli_exception_handling(fn):
     def wrapper(*args, **kwargs):
         try:
             return fn(*args, **kwargs)
+        except (typer.Exit, typer.Abort, ClickException):
+            raise  # Do not capture click or typer exceptions
         except MissingProfileError as exc:
             exit_with_error(exc)
         except Exception:
b

Brad

03/15/2022, 10:00 PM
cheers!
not an issue for me - but it might be for some other users
z

Zanie

03/17/2022, 8:54 PM
This should be solved in 2.0b2