Base prefect
command-line application
version
async
Get the current Prefect version.
Source code in prefect/cli/root.py
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156 | @app.command()
async def version():
"""Get the current Prefect version."""
import sqlite3
from prefect.orion.api.server import ORION_API_VERSION
from prefect.orion.utilities.database import get_dialect
from prefect.settings import (
PREFECT_API_URL,
PREFECT_CLOUD_API_URL,
PREFECT_ORION_DATABASE_CONNECTION_URL,
)
version_info = {
"Version": prefect.__version__,
"API version": ORION_API_VERSION,
"Python version": platform.python_version(),
"Git commit": prefect.__version_info__["full-revisionid"][:8],
"Built": pendulum.parse(
prefect.__version_info__["date"]
).to_day_datetime_string(),
"OS/Arch": f"{sys.platform}/{platform.machine()}",
"Profile": prefect.context.get_settings_context().profile.name,
}
is_ephemeral: Optional[bool] = None
try:
async with prefect.get_client() as client:
is_ephemeral = client._ephemeral_app is not None
except Exception as exc:
version_info["Server type"] = "<client error>"
else:
version_info["Server type"] = (
"ephemeral"
if is_ephemeral
else (
"cloud"
if PREFECT_API_URL.value().startswith(PREFECT_CLOUD_API_URL.value())
else "hosted"
)
)
# TODO: Consider adding an API route to retrieve this information?
if is_ephemeral:
database = get_dialect(PREFECT_ORION_DATABASE_CONNECTION_URL.value()).name
version_info["Server"] = {"Database": database}
if database == "sqlite":
version_info["Server"]["SQLite version"] = sqlite3.sqlite_version
def display(object: dict, nesting: int = 0):
# Recursive display of a dictionary with nesting
for key, value in object.items():
key += ":"
if isinstance(value, dict):
app.console.print(key)
return display(value, nesting + 2)
prefix = " " * nesting
app.console.print(f"{prefix}{key.ljust(20 - len(prefix))} {value}")
display(version_info)
|