Unverified Commit ccc8c627 authored by Graham King's avatar Graham King Committed by GitHub
Browse files

feat: Support `python -m dynamo.frontend --version` (#2449)

parent 24a935e5
......@@ -79,14 +79,15 @@ __pycache__/
*.so
*.egg-info
# Hatch build artifact
components/**/_version.py
### Helm ###
*.tgz
Chart.lock
generated-values.yaml
# Local build artifacts for devcontainer
.build/
**/.devcontainer/.env
TensorRT-LLM
# Local build artifacts for devcontainer
.build/
\ No newline at end of file
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
try:
from ._version import __version__
except Exception:
try:
from importlib.metadata import version as _pkg_version
__version__ = _pkg_version("ai-dynamo")
except Exception:
__version__ = "0.0.0+unknown"
......@@ -15,6 +15,8 @@ from dynamo.llm import ModelType, register_llm
from dynamo.runtime import DistributedRuntime, dynamo_worker
from dynamo.runtime.logging import configure_dynamo_logging
from . import __version__
DEFAULT_ENDPOINT = "dyn://dynamo.backend.generate"
configure_dynamo_logging()
......@@ -83,6 +85,9 @@ def cmd_line_args():
parser = argparse.ArgumentParser(
description="llama.cpp server integrated with Dynamo LLM."
)
parser.add_argument(
"--version", action="version", version=f"Dynamo Backend llama.cpp {__version__}"
)
parser.add_argument(
"--model-path",
type=str,
......
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
try:
from ._version import __version__
except Exception:
try:
from importlib.metadata import version as _pkg_version
__version__ = _pkg_version("ai-dynamo")
except Exception:
__version__ = "0.0.0+unknown"
......@@ -12,6 +12,8 @@ from dynamo.llm import EngineType, EntrypointArgs, make_engine, run_input
from dynamo.runtime import DistributedRuntime, dynamo_worker
from dynamo.runtime.logging import configure_dynamo_logging
from . import __version__
DEFAULT_ENDPOINT = "dyn://dynamo.backend.generate"
configure_dynamo_logging()
......@@ -41,6 +43,9 @@ def cmd_line_args():
description="Mocker engine for testing Dynamo LLM infrastructure.",
formatter_class=argparse.RawDescriptionHelpFormatter,
)
parser.add_argument(
"--version", action="version", version=f"Dynamo Mocker {__version__}"
)
parser.add_argument(
"--model-path",
type=str,
......
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
try:
from ._version import __version__
except Exception:
try:
from importlib.metadata import version as _pkg_version
__version__ = _pkg_version("ai-dynamo")
except Exception:
__version__ = "0.0.0+unknown"
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
try:
from ._version import __version__
except Exception:
try:
from importlib.metadata import version as _pkg_version
__version__ = _pkg_version("ai-dynamo")
except Exception:
__version__ = "0.0.0+unknown"
......@@ -6,6 +6,7 @@ from typing import Optional
from tensorrt_llm.llmapi import BuildConfig
from dynamo.trtllm import __version__
from dynamo.trtllm.request_handlers.handler_base import (
DisaggregationMode,
DisaggregationStrategy,
......@@ -109,6 +110,9 @@ def cmd_line_args():
parser = argparse.ArgumentParser(
description="TensorRT-LLM server integrated with Dynamo LLM."
)
parser.add_argument(
"--version", action="version", version=f"Dynamo Backend TRTLLM {__version__}"
)
parser.add_argument(
"--endpoint",
type=str,
......
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
try:
from ._version import __version__
except Exception:
try:
from importlib.metadata import version as _pkg_version
__version__ = _pkg_version("ai-dynamo")
except Exception:
__version__ = "0.0.0+unknown"
......@@ -12,6 +12,7 @@ from vllm.distributed.kv_events import KVEventsConfig
from vllm.engine.arg_utils import AsyncEngineArgs
from vllm.utils import FlexibleArgumentParser
from . import __version__
from .ports import (
DEFAULT_DYNAMO_PORT_MAX,
DEFAULT_DYNAMO_PORT_MIN,
......@@ -58,6 +59,9 @@ def parse_args() -> Config:
parser = FlexibleArgumentParser(
description="vLLM server integrated with Dynamo LLM."
)
parser.add_argument(
"--version", action="version", version=f"Dynamo Backend VLLM {__version__}"
)
parser.add_argument(
"--endpoint",
type=str,
......
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
try:
from ._version import __version__
except Exception:
try:
from importlib.metadata import version as _pkg_version
__version__ = _pkg_version("ai-dynamo")
except Exception:
__version__ = "0.0.0+unknown"
......@@ -35,6 +35,8 @@ from dynamo.llm import (
)
from dynamo.runtime import DistributedRuntime
from . import __version__
def validate_static_endpoint(value):
"""Validate that static-endpoint is three words separated by dots."""
......@@ -71,6 +73,9 @@ def parse_args():
description="Dynamo Frontend: HTTP+Pre-processor+Router",
formatter_class=argparse.RawTextHelpFormatter, # To preserve multi-line help formatting
)
parser.add_argument(
"--version", action="version", version=f"Dynamo Frontend {__version__}"
)
parser.add_argument(
"-i", "--interactive", action="store_true", help="Interactive text chat"
)
......
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
__all__ = [
"CircusController",
......@@ -21,10 +9,19 @@ __all__ = [
"SLAPlannerDefaults",
"ServiceConfig",
]
# Import the classes
from dynamo.planner.circusd import CircusController
from dynamo.planner.config import ServiceConfig
from dynamo.planner.defaults import LoadPlannerDefaults, SLAPlannerDefaults
from dynamo.planner.kubernetes_connector import KubernetesConnector
from dynamo.planner.planner_connector import PlannerConnector
try:
from ._version import __version__
except Exception:
try:
from importlib.metadata import version as _pkg_version
__version__ = _pkg_version("ai-dynamo")
except Exception:
__version__ = "0.0.0+unknown"
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import json
import logging
......
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import argparse
import asyncio
......@@ -21,7 +9,7 @@ import time
from dataclasses import dataclass
from typing import Optional
from dynamo.planner import KubernetesConnector
from dynamo.planner import KubernetesConnector, __version__
from dynamo.planner.defaults import WORKER_COMPONENT_NAMES, SLAPlannerDefaults
from dynamo.planner.utils.load_predictor import LOAD_PREDICTORS
from dynamo.planner.utils.perf_interpolation import (
......@@ -346,6 +334,9 @@ async def start_sla_planner(runtime: DistributedRuntime, args: argparse.Namespac
if __name__ == "__main__":
parser = argparse.ArgumentParser()
# Common planner arguments
parser.add_argument(
"--version", action="version", version=f"Dynamo Planner {__version__}"
)
parser.add_argument(
"--environment",
type=str,
......
......@@ -218,7 +218,7 @@ COPY --from=base $VIRTUAL_ENV $VIRTUAL_ENV
ENV PATH=$CARGO_HOME/bin:$VIRTUAL_ENV/bin:$PATH
# Copy configuration files first for better layer caching
COPY pyproject.toml README.md LICENSE Cargo.toml Cargo.lock rust-toolchain.toml /opt/dynamo/
COPY pyproject.toml README.md LICENSE Cargo.toml Cargo.lock rust-toolchain.toml hatch_build.py /opt/dynamo/
# Copy source code
COPY lib/ /opt/dynamo/lib/
......
......@@ -337,6 +337,7 @@ COPY LICENSE /workspace/
COPY Cargo.toml /workspace/
COPY Cargo.lock /workspace/
COPY rust-toolchain.toml /workspace/
COPY hatch_build.py /workspace/
# Copy source code
COPY lib/ /workspace/lib/
......
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
ARG BASE_IMAGE="nvcr.io/nvidia/pytorch"
ARG BASE_IMAGE_TAG="25.05-py3"
......@@ -285,6 +273,7 @@ COPY LICENSE /workspace/
COPY Cargo.toml /workspace/
COPY Cargo.lock /workspace/
COPY rust-toolchain.toml /workspace/
COPY hatch_build.py /workspace/
# Copy source code
COPY lib/ /workspace/lib/
......
......@@ -352,6 +352,7 @@ COPY LICENSE /workspace/
COPY Cargo.toml /workspace/
COPY Cargo.lock /workspace/
COPY rust-toolchain.toml /workspace/
COPY hatch_build.py /workspace/
# Copy source code
COPY lib/ /workspace/lib/
......
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
import os
import subprocess
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
COMPONENTS = [
"frontend/src/dynamo/frontend",
"backends/vllm/src/dynamo/vllm",
"backends/sglang/src/dynamo/sglang",
"backends/trtllm/src/dynamo/trtllm",
"backends/mocker/src/dynamo/mocker",
"backends/llama_cpp/src/dynamo/llama_cpp",
"planner/src/dynamo/planner",
]
class VersionWriterHook(BuildHookInterface):
"""
A Hatch build hook to write the project version to a file.
"""
def initialize(self, version, build_data):
"""
This method is called before the build process begins.
"""
full_version = self.metadata.version
try:
result = subprocess.run(
["git", "rev-parse", "--short", "HEAD"],
cwd=self.root,
capture_output=True,
text=True,
check=True,
)
git_version = result.stdout.strip()
if git_version:
full_version += f"+{git_version}"
except (subprocess.CalledProcessError, FileNotFoundError):
pass
version_content = f'# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n# SPDX-License-Identifier: Apache-2.0\n\n# This file is auto-generated at build time\n__version__ = "{full_version}"\n'
for component in COMPONENTS:
version_file_path = os.path.join(
self.root, f"components/{component}/_version.py"
)
with open(version_file_path, "w") as f:
f.write(version_content)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment