Hi all, Just updated to 2.0b14 and ran into a cou...
# prefect-server
k
Hi all, Just updated to 2.0b14 and ran into a couple of issues: 1/ Running
prefect cloud login -k KEY -w WORKSPACE
now asks for
"Creating a profile for this Prefect Cloud login. Please specify a profile name:"
This breaks my deployment flow since I need it to be programmatic. I also tried running
prefect profile create
before but that doesn't seem to help. I also can't give the name of an existing profile. Could someone help explain what I'm doing wrong? I tried searching in the docs but maybe I'm missing something 2/ I was able to just hit enter locally and got the following message "Logged in to Prefect Cloud using profile ''." However, if I try to do
prefect cloud login
or
prefect profile inspect
after this, it throws the following error. I had to fix this by manually deleting
profiles.toml
. Code in thread
a
If you need it to be programmatic, try using PREFECT_API_URL and PREFECT_API_KEY environment variables instead
Cc @dustin
Also could you please move your code to the thread ๐Ÿงต- thanks a lot in advance
k
Code in thread:
Copy code
Traceback (most recent call last):
  File "/Users/kvm/Desktop/cvf/venv/bin/prefect", line 5, in <module>
    from prefect.cli import app
  File "/Users/kvm/Desktop/cvf/venv/lib/python3.9/site-packages/prefect/__init__.py", line 81, in <module>
    prefect.context.enter_root_settings_context()
  File "/Users/kvm/Desktop/cvf/venv/lib/python3.9/site-packages/prefect/context.py", line 486, in enter_root_settings_context
    profiles = prefect.settings.load_profiles()
  File "/Users/kvm/Desktop/cvf/venv/lib/python3.9/site-packages/prefect/settings.py", line 1078, in load_profiles
    user_profiles = _read_profiles_from(user_profiles_path)
  File "/Users/kvm/Desktop/cvf/venv/lib/python3.9/site-packages/prefect/settings.py", line 1049, in _read_profiles_from
    contents = toml.loads(path.read_text())
  File "/Users/kvm/Desktop/cvf/venv/lib/python3.9/site-packages/toml/decoder.py", line 463, in loads
    raise TomlDecodeError("Can't have a keygroup with an empty "
toml.decoder.TomlDecodeError: Can't have a keygroup with an empty name (line 3 column 1 char 13)
d
Hi Karanveer, you'll only be prompted to make a new profile the first time you log in with a key. I think you got an error because
.
is not a valid profile name (we should have better checking here). The second time you use
prefect cloud login
you will switch to the profile associated with that key. The last workspace you used is remembered, so if you're changing workspaces you can change the workspace with
prefect cloud workspace set -w <WORKSPACE>
. Setting both the
PREFECT_API_URL
and
PREFECT_API_KEY
environment variables like Anna mentioned above works also!
๐Ÿ™ 2
k
Thanks for the quick response, and apologies since I think I was unclear! I feel like I shouldn't need to specify a profile. I already have a "default" profile and specified the workspace / API key in the CLI command. I'm deploying this via docker and there's no "-p" equivalent for profile the way we have a -k and -w. So, I have to do the following in my docker scripts as a workaround which is hacky and not ideal:
RUN bash -c 'prefect cloud login -k KEY -w WORKSPACE <<< "profile_name"'
The documentation on https://orion-docs.prefect.io/ui/cloud-getting-started/ also says
"The command then sets PREFECT_API_KEY and PREFECT_API_URL for the current profile.",
so I was quite confused why I need to create a new one. I tried running
prefect profile use default
right before but
prefect cloud login
still asked for a profile name. Anyway, just thought I'd share my experience. Maybe I'm just being an idiot and missing something obvious. But I hope it's helpful!
b
I am also seeing this issue in 2.0b15 running in a docker container. From the documentation it is not clear why the CLI is asking to create a new profile and not just use the default profile.
a
I'd go with the environment variables for automated setup, the CLI is more interactive