Thread
#prefect-community
    Tim Helfensdörfer

    Tim Helfensdörfer

    2 months ago
    In the prefect 2b8:
    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:
    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:
    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,
                }
            )
    Kevin Kho

    Kevin Kho

    2 months ago
    I need to ask the team about this
    Tim Helfensdörfer

    Tim Helfensdörfer

    2 months ago
    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.
    Michael Adkins

    Michael Adkins

    2 months ago
    Are you trying to run the CLI function directly?
    You could run the login command beforehand? It persists credentials to disk
    Tim Helfensdörfer

    Tim Helfensdörfer

    2 months ago
    Ahh ok, that would be a better alternative, thanks!