In the prefect 2b8: ``` File "/Users/****/Library...
# prefect-community
t
In the prefect 2b8:
Copy code
File "/Users/****/Library/Caches/pypoetry/virtualenvs/equation-kGZ4A1K9-py3.8/lib/python3.8/site-packages/prefect/cli/cloud.py", line 231, in login
    exit_with_success(
  File "/Users/****/Library/Caches/pypoetry/virtualenvs/equation-kGZ4A1K9-py3.8/lib/python3.8/site-packages/prefect/cli/_utilities.py", line 36, in exit_with_success
    app.console.print(message, **kwargs)
AttributeError: 'PrefectTyper' object has no attribute 'console'
When trying to run (which worked in 2b7:
Copy code
await login(
            key=os.environ.get("PREFECT_API_KEY"),
            workspace_handle=os.environ.get("PREFECT_WORKSPACE_HANDLE"),
        )
It does work when you login manually (replace the
await login
method with the following:
Copy code
key = os.environ.get("PREFECT_API_KEY")
        workspace_handle = os.environ.get("PREFECT_WORKSPACE_HANDLE")

        async with get_cloud_client(api_key=key) as client:
            try:
                workspaces = await client.read_workspaces()
            except CloudUnauthorizedError:
                logger.error(
                    "Unable to authenticate. Please ensure your credentials are correct."
                )
                return ""

        workspaces = {
            f"{workspace['account_handle']}/{workspace['workspace_handle']}": workspace
            for workspace in workspaces
        }

        update_current_profile(
            {
                PREFECT_API_URL: build_url_from_workspace(workspaces[workspace_handle]),
                PREFECT_API_KEY: key,
            }
        )
k
I need to ask the team about this
t
Yeah the problem is very simple. The login function is decorated as a command. When you execute it as a command it works. I guess it was never intended to be used this way. But if you want to register your task in a ci/cd pipeline, I do not know how else you should do it.
z
Are you trying to run the CLI function directly?
You could run the login command beforehand? It persists credentials to disk
t
Ahh ok, that would be a better alternative, thanks!