Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for picking a non-prd Prefect Cloud environment #15

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions src/prefect_cloud/auth.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import os
import socket
import threading
import webbrowser
Expand All @@ -16,9 +17,22 @@

from prefect_cloud.utilities.tui import prompt_select_from_list

# TODO: Get this configuration from the user's environment if possible
CLOUD_UI_URL = "https://app.prefect.cloud"
CLOUD_API_URL = "https://api.prefect.cloud/api"
if os.environ.get("CLOUD_ENV") in ("prd", "prod", None):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There a pydantic settings file we could use for this instead of getting it directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, I've felt a little off-kilter with where the settings should be with this one, since we're kinda piggybacking on ~/.prefect/profiles.toml. I figured this was only for us devs, so we didn't want to expose this as a user-facing option (like as a --cloud-env switch or something, which is how I started)

CLOUD_UI_URL = "https://app.prefect.cloud"
CLOUD_API_URL = "https://api.prefect.cloud/api"
elif os.environ.get("CLOUD_ENV") == "stg":
CLOUD_UI_URL = "https://app.stg.prefect.dev"
CLOUD_API_URL = "https://api.stg.prefect.dev/api"
elif os.environ.get("CLOUD_ENV") == "dev":
CLOUD_UI_URL = "https://app.prefect.dev"
CLOUD_API_URL = "https://api.prefect.dev/api"
elif os.environ.get("CLOUD_ENV") == "lcl":
CLOUD_UI_URL = "http://localhost:3000"
CLOUD_API_URL = "http://localhost:8000/api"
else:
raise ValueError(f"Invalid CLOUD_ENV: {os.environ.get('CLOUD_ENV')}")


PREFECT_HOME = Path.home() / ".prefect"


Expand Down
4 changes: 1 addition & 3 deletions src/prefect_cloud/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,10 @@ async def deploy(
f"\n ➜ [link={url_for('deployment', deployment_id)}]"
f"{deployment_name}"
f"[/link]",
style="blue",
)

app.console.print(
f"Run it with: \n $ prefect deployment run {function}/{deployment_name}",
style="blue",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These blue styles are pretty dark on Ubuntu's default theme. Dialing them back for now

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

boooo

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I joke

f"Run it with: \n $ prefect-cloud run {function}/{deployment_name}",
)


Expand Down