Skip to content

Commit b3ade8c

Browse files
author
gibsondan
committed
Consolidate python versions in dg cli, add python 3.14 (#33141)
## Summary & Motivation There were a bunch of different places we list out valid python versions, and one was missing python 3.13. Consolidate them into a constant and add python 3.14 now that we have serverless support for that as well. ## How I Tested These Changes BK, deploy a dg project to python 3.13 ## Changelog Added support for using python version 3.13 when running `dg plus deploy`.
1 parent 0aa846c commit b3ade8c

6 files changed

Lines changed: 25 additions & 16 deletions

File tree

python_modules/libraries/dagster-cloud-cli/dagster_cloud_cli/core/pex_builder/util.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
from packaging import version
1212

1313
from dagster_cloud_cli.core.pex_builder.platforms import COMPLETE_PLATFORMS
14-
from dagster_cloud_cli.utils import DEFAULT_PYTHON_VERSION
14+
from dagster_cloud_cli.utils import DEFAULT_PYTHON_VERSION, SUPPORTED_PYTHON_VERSIONS
1515

1616
TARGET_PYTHON_VERSIONS = [
17-
version.Version(python_version) for python_version in ["3.9", "3.10", "3.11", "3.12", "3.13"]
17+
version.Version(python_version) for python_version in SUPPORTED_PYTHON_VERSIONS
1818
]
1919

2020

@@ -142,7 +142,7 @@ def python_version_option():
142142
"""Reusable click.option."""
143143
return click.option(
144144
"--python-version",
145-
type=click.Choice([str(v) for v in TARGET_PYTHON_VERSIONS]),
145+
type=click.Choice(SUPPORTED_PYTHON_VERSIONS),
146146
default=DEFAULT_PYTHON_VERSION,
147147
show_default=True,
148148
help="Target Python version.",

python_modules/libraries/dagster-cloud-cli/dagster_cloud_cli/utils.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,30 @@
33
import inspect
44
import math
55
import os
6-
from typing import Any
6+
from typing import TYPE_CHECKING, Any
77

8-
import typer
9-
from typer.models import OptionInfo
8+
if TYPE_CHECKING:
9+
from typer import Typer
10+
from typer.models import OptionInfo
1011

11-
from dagster_cloud_cli import ui
1212

1313
DEFAULT_PYTHON_VERSION = "3.11"
1414

15+
SUPPORTED_PYTHON_VERSIONS = ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
16+
17+
18+
def create_stub_app(package_name: str) -> "Typer":
19+
import typer
1520

16-
def create_stub_app(package_name: str) -> typer.Typer:
1721
return typer.Typer(
1822
help=f"This command is not available unless you install the {package_name} package.",
1923
hidden=True,
2024
)
2125

2226

2327
def create_stub_command(package_name: str):
28+
from dagster_cloud_cli import ui
29+
2430
def fn():
2531
ui.print(f"This command is not available unless you install the {package_name} package.")
2632

@@ -48,7 +54,7 @@ def without_params(signature: inspect.Signature, to_remove: list[str]) -> inspec
4854
return signature.replace(parameters=list(params.values()))
4955

5056

51-
def add_options(options: dict[str, tuple[Any, OptionInfo]]):
57+
def add_options(options: dict[str, tuple[Any, "OptionInfo"]]):
5258
"""Decorator to add Options to a particular command."""
5359

5460
def decorator(to_wrap):

python_modules/libraries/dagster-dg-cli/dagster_dg_cli/cli/plus/deploy/commands.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import click
1010
from dagster_cloud_cli.types import SnapshotBaseDeploymentCondition
11+
from dagster_cloud_cli.utils import SUPPORTED_PYTHON_VERSIONS
1112
from dagster_dg_core.config import DgRawCliConfig, normalize_cli_config
1213
from dagster_dg_core.context import DgContext
1314
from dagster_dg_core.shared_options import (
@@ -95,7 +96,7 @@ def _get_deployment(input_deployment: Optional[str], plus_config: DagsterPlusCli
9596
@click.option(
9697
"--python-version",
9798
"python_version",
98-
type=click.Choice(["3.9", "3.10", "3.11", "3.12"]),
99+
type=click.Choice(SUPPORTED_PYTHON_VERSIONS),
99100
help=(
100101
"Python version used to deploy the project. If not set, defaults to the calling process's Python minor version."
101102
),
@@ -341,7 +342,7 @@ def start_deploy_session_command(
341342
@click.option(
342343
"--python-version",
343344
"python_version",
344-
type=click.Choice(["3.9", "3.10", "3.11", "3.12"]),
345+
type=click.Choice(SUPPORTED_PYTHON_VERSIONS),
345346
help=(
346347
"Python version used to deploy the project. If not set, defaults to the calling process's Python minor version."
347348
),

python_modules/libraries/dagster-dg-cli/dagster_dg_cli/cli/plus/deploy/configure/commands.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from typing import Optional
1010

1111
import click
12+
from dagster_cloud_cli.utils import SUPPORTED_PYTHON_VERSIONS
1213
from dagster_dg_core.config import normalize_cli_config
1314
from dagster_dg_core.context import DgContext
1415
from dagster_dg_core.shared_options import dg_editable_dagster_options, dg_global_options
@@ -296,7 +297,7 @@ def deploy_configure_group(
296297
)
297298
@click.option(
298299
"--python-version",
299-
type=click.Choice(["3.9", "3.10", "3.11", "3.12", "3.13"]),
300+
type=click.Choice(SUPPORTED_PYTHON_VERSIONS),
300301
help="Python version used to deploy the project",
301302
)
302303
@click.option(
@@ -384,7 +385,7 @@ def deploy_configure_serverless(
384385
)
385386
@click.option(
386387
"--python-version",
387-
type=click.Choice(["3.9", "3.10", "3.11", "3.12", "3.13"]),
388+
type=click.Choice(SUPPORTED_PYTHON_VERSIONS),
388389
help="Python version used to deploy the project",
389390
)
390391
@click.option(

python_modules/libraries/dagster-dg-cli/dagster_dg_cli/cli/scaffold/build_artifacts.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from typing import Optional
99

1010
import click
11+
from dagster_cloud_cli.utils import SUPPORTED_PYTHON_VERSIONS
1112
from dagster_dg_core.config import normalize_cli_config
1213
from dagster_dg_core.context import DgContext
1314
from dagster_dg_core.shared_options import dg_editable_dagster_options, dg_global_options
@@ -76,7 +77,7 @@ def _resolve_config_for_build_artifacts(
7677
@click.option(
7778
"--python-version",
7879
"python_version",
79-
type=click.Choice(["3.9", "3.10", "3.11", "3.12", "3.13"]),
80+
type=click.Choice(SUPPORTED_PYTHON_VERSIONS),
8081
help=(
8182
"Python version used to deploy the project. If not set, defaults to the calling process's Python minor version."
8283
),

python_modules/libraries/dagster-dg-cli/dagster_dg_cli_tests/cli_tests/import_perf_tests/test_import_perf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ def test_import_perf():
5858
# if `tuna` output is unfriendly, another way to debug imports is to open `/tmp/import.txt`
5959
# using https://kmichel.github.io/python-importtime-graph/
6060
assert not expensive_imports, (
61-
"The following expensive libraries were imported with the top-level `dagster` module, "
62-
f"slowing down any process that imports Dagster: {', '.join(expensive_imports)}; to debug, "
61+
"The following expensive libraries were imported with the top-level `dagster_dg_cli` module, "
62+
f"slowing down any process that imports dg: {', '.join(expensive_imports)}; to debug, "
6363
"`pip install tuna`, then run "
6464
"`python -X importtime python_modules/libraries/dagster-dg-cli/dagster_dg_cli_tests/cli_tests/import_perf_tests/simple_import.py noop &> /tmp/import.txt && tuna /tmp/import.txt`."
6565
)

0 commit comments

Comments
 (0)