Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
dynamo
Commits
ccc8c627
Unverified
Commit
ccc8c627
authored
Aug 15, 2025
by
Graham King
Committed by
GitHub
Aug 15, 2025
Browse files
feat: Support `python -m dynamo.frontend --version` (#2449)
parent
24a935e5
Changes
21
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
170 additions
and
57 deletions
+170
-57
.gitignore
.gitignore
+4
-3
components/backends/llama_cpp/src/dynamo/llama_cpp/__init__.py
...nents/backends/llama_cpp/src/dynamo/llama_cpp/__init__.py
+12
-0
components/backends/llama_cpp/src/dynamo/llama_cpp/main.py
components/backends/llama_cpp/src/dynamo/llama_cpp/main.py
+5
-0
components/backends/mocker/src/dynamo/mocker/__init__.py
components/backends/mocker/src/dynamo/mocker/__init__.py
+12
-0
components/backends/mocker/src/dynamo/mocker/main.py
components/backends/mocker/src/dynamo/mocker/main.py
+5
-0
components/backends/sglang/src/dynamo/sglang/__init__.py
components/backends/sglang/src/dynamo/sglang/__init__.py
+12
-0
components/backends/trtllm/src/dynamo/trtllm/__init__.py
components/backends/trtllm/src/dynamo/trtllm/__init__.py
+12
-2
components/backends/trtllm/src/dynamo/trtllm/utils/trtllm_utils.py
...s/backends/trtllm/src/dynamo/trtllm/utils/trtllm_utils.py
+4
-0
components/backends/vllm/src/dynamo/vllm/__init__.py
components/backends/vllm/src/dynamo/vllm/__init__.py
+12
-0
components/backends/vllm/src/dynamo/vllm/args.py
components/backends/vllm/src/dynamo/vllm/args.py
+4
-0
components/frontend/src/dynamo/frontend/__init__.py
components/frontend/src/dynamo/frontend/__init__.py
+12
-0
components/frontend/src/dynamo/frontend/main.py
components/frontend/src/dynamo/frontend/main.py
+5
-0
components/planner/src/dynamo/planner/__init__.py
components/planner/src/dynamo/planner/__init__.py
+10
-13
components/planner/src/dynamo/planner/config.py
components/planner/src/dynamo/planner/config.py
+0
-12
components/planner/src/dynamo/planner/utils/planner_core.py
components/planner/src/dynamo/planner/utils/planner_core.py
+4
-13
container/Dockerfile
container/Dockerfile
+2
-2
container/Dockerfile.sglang
container/Dockerfile.sglang
+1
-0
container/Dockerfile.trtllm
container/Dockerfile.trtllm
+1
-12
container/Dockerfile.vllm
container/Dockerfile.vllm
+1
-0
hatch_build.py
hatch_build.py
+52
-0
No files found.
.gitignore
View file @
ccc8c627
...
@@ -79,14 +79,15 @@ __pycache__/
...
@@ -79,14 +79,15 @@ __pycache__/
*.so
*.so
*.egg-info
*.egg-info
# Hatch build artifact
components/**/_version.py
### Helm ###
### Helm ###
*.tgz
*.tgz
Chart.lock
Chart.lock
generated-values.yaml
generated-values.yaml
# Local build artifacts for devcontainer
.build/
.build/
**/.devcontainer/.env
**/.devcontainer/.env
TensorRT-LLM
TensorRT-LLM
# Local build artifacts for devcontainer
.build/
\ No newline at end of file
components/backends/llama_cpp/src/dynamo/llama_cpp/__init__.py
View file @
ccc8c627
# 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"
components/backends/llama_cpp/src/dynamo/llama_cpp/main.py
View file @
ccc8c627
...
@@ -15,6 +15,8 @@ from dynamo.llm import ModelType, register_llm
...
@@ -15,6 +15,8 @@ from dynamo.llm import ModelType, register_llm
from
dynamo.runtime
import
DistributedRuntime
,
dynamo_worker
from
dynamo.runtime
import
DistributedRuntime
,
dynamo_worker
from
dynamo.runtime.logging
import
configure_dynamo_logging
from
dynamo.runtime.logging
import
configure_dynamo_logging
from
.
import
__version__
DEFAULT_ENDPOINT
=
"dyn://dynamo.backend.generate"
DEFAULT_ENDPOINT
=
"dyn://dynamo.backend.generate"
configure_dynamo_logging
()
configure_dynamo_logging
()
...
@@ -83,6 +85,9 @@ def cmd_line_args():
...
@@ -83,6 +85,9 @@ def cmd_line_args():
parser
=
argparse
.
ArgumentParser
(
parser
=
argparse
.
ArgumentParser
(
description
=
"llama.cpp server integrated with Dynamo LLM."
description
=
"llama.cpp server integrated with Dynamo LLM."
)
)
parser
.
add_argument
(
"--version"
,
action
=
"version"
,
version
=
f
"Dynamo Backend llama.cpp
{
__version__
}
"
)
parser
.
add_argument
(
parser
.
add_argument
(
"--model-path"
,
"--model-path"
,
type
=
str
,
type
=
str
,
...
...
components/backends/mocker/src/dynamo/mocker/__init__.py
View file @
ccc8c627
# 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"
components/backends/mocker/src/dynamo/mocker/main.py
View file @
ccc8c627
...
@@ -12,6 +12,8 @@ from dynamo.llm import EngineType, EntrypointArgs, make_engine, run_input
...
@@ -12,6 +12,8 @@ from dynamo.llm import EngineType, EntrypointArgs, make_engine, run_input
from
dynamo.runtime
import
DistributedRuntime
,
dynamo_worker
from
dynamo.runtime
import
DistributedRuntime
,
dynamo_worker
from
dynamo.runtime.logging
import
configure_dynamo_logging
from
dynamo.runtime.logging
import
configure_dynamo_logging
from
.
import
__version__
DEFAULT_ENDPOINT
=
"dyn://dynamo.backend.generate"
DEFAULT_ENDPOINT
=
"dyn://dynamo.backend.generate"
configure_dynamo_logging
()
configure_dynamo_logging
()
...
@@ -41,6 +43,9 @@ def cmd_line_args():
...
@@ -41,6 +43,9 @@ def cmd_line_args():
description
=
"Mocker engine for testing Dynamo LLM infrastructure."
,
description
=
"Mocker engine for testing Dynamo LLM infrastructure."
,
formatter_class
=
argparse
.
RawDescriptionHelpFormatter
,
formatter_class
=
argparse
.
RawDescriptionHelpFormatter
,
)
)
parser
.
add_argument
(
"--version"
,
action
=
"version"
,
version
=
f
"Dynamo Mocker
{
__version__
}
"
)
parser
.
add_argument
(
parser
.
add_argument
(
"--model-path"
,
"--model-path"
,
type
=
str
,
type
=
str
,
...
...
components/backends/sglang/src/dynamo/sglang/__init__.py
View file @
ccc8c627
# 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"
components/backends/trtllm/src/dynamo/trtllm/__init__.py
View file @
ccc8c627
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# 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"
components/backends/trtllm/src/dynamo/trtllm/utils/trtllm_utils.py
View file @
ccc8c627
...
@@ -6,6 +6,7 @@ from typing import Optional
...
@@ -6,6 +6,7 @@ from typing import Optional
from
tensorrt_llm.llmapi
import
BuildConfig
from
tensorrt_llm.llmapi
import
BuildConfig
from
dynamo.trtllm
import
__version__
from
dynamo.trtllm.request_handlers.handler_base
import
(
from
dynamo.trtllm.request_handlers.handler_base
import
(
DisaggregationMode
,
DisaggregationMode
,
DisaggregationStrategy
,
DisaggregationStrategy
,
...
@@ -109,6 +110,9 @@ def cmd_line_args():
...
@@ -109,6 +110,9 @@ def cmd_line_args():
parser
=
argparse
.
ArgumentParser
(
parser
=
argparse
.
ArgumentParser
(
description
=
"TensorRT-LLM server integrated with Dynamo LLM."
description
=
"TensorRT-LLM server integrated with Dynamo LLM."
)
)
parser
.
add_argument
(
"--version"
,
action
=
"version"
,
version
=
f
"Dynamo Backend TRTLLM
{
__version__
}
"
)
parser
.
add_argument
(
parser
.
add_argument
(
"--endpoint"
,
"--endpoint"
,
type
=
str
,
type
=
str
,
...
...
components/backends/vllm/src/dynamo/vllm/__init__.py
View file @
ccc8c627
# 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"
components/backends/vllm/src/dynamo/vllm/args.py
View file @
ccc8c627
...
@@ -12,6 +12,7 @@ from vllm.distributed.kv_events import KVEventsConfig
...
@@ -12,6 +12,7 @@ from vllm.distributed.kv_events import KVEventsConfig
from
vllm.engine.arg_utils
import
AsyncEngineArgs
from
vllm.engine.arg_utils
import
AsyncEngineArgs
from
vllm.utils
import
FlexibleArgumentParser
from
vllm.utils
import
FlexibleArgumentParser
from
.
import
__version__
from
.ports
import
(
from
.ports
import
(
DEFAULT_DYNAMO_PORT_MAX
,
DEFAULT_DYNAMO_PORT_MAX
,
DEFAULT_DYNAMO_PORT_MIN
,
DEFAULT_DYNAMO_PORT_MIN
,
...
@@ -58,6 +59,9 @@ def parse_args() -> Config:
...
@@ -58,6 +59,9 @@ def parse_args() -> Config:
parser
=
FlexibleArgumentParser
(
parser
=
FlexibleArgumentParser
(
description
=
"vLLM server integrated with Dynamo LLM."
description
=
"vLLM server integrated with Dynamo LLM."
)
)
parser
.
add_argument
(
"--version"
,
action
=
"version"
,
version
=
f
"Dynamo Backend VLLM
{
__version__
}
"
)
parser
.
add_argument
(
parser
.
add_argument
(
"--endpoint"
,
"--endpoint"
,
type
=
str
,
type
=
str
,
...
...
components/frontend/src/dynamo/frontend/__init__.py
View file @
ccc8c627
# 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"
components/frontend/src/dynamo/frontend/main.py
View file @
ccc8c627
...
@@ -35,6 +35,8 @@ from dynamo.llm import (
...
@@ -35,6 +35,8 @@ from dynamo.llm import (
)
)
from
dynamo.runtime
import
DistributedRuntime
from
dynamo.runtime
import
DistributedRuntime
from
.
import
__version__
def
validate_static_endpoint
(
value
):
def
validate_static_endpoint
(
value
):
"""Validate that static-endpoint is three words separated by dots."""
"""Validate that static-endpoint is three words separated by dots."""
...
@@ -71,6 +73,9 @@ def parse_args():
...
@@ -71,6 +73,9 @@ def parse_args():
description
=
"Dynamo Frontend: HTTP+Pre-processor+Router"
,
description
=
"Dynamo Frontend: HTTP+Pre-processor+Router"
,
formatter_class
=
argparse
.
RawTextHelpFormatter
,
# To preserve multi-line help formatting
formatter_class
=
argparse
.
RawTextHelpFormatter
,
# To preserve multi-line help formatting
)
)
parser
.
add_argument
(
"--version"
,
action
=
"version"
,
version
=
f
"Dynamo Frontend
{
__version__
}
"
)
parser
.
add_argument
(
parser
.
add_argument
(
"-i"
,
"--interactive"
,
action
=
"store_true"
,
help
=
"Interactive text chat"
"-i"
,
"--interactive"
,
action
=
"store_true"
,
help
=
"Interactive text chat"
)
)
...
...
components/planner/src/dynamo/planner/__init__.py
View file @
ccc8c627
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# 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__
=
[
__all__
=
[
"CircusController"
,
"CircusController"
,
...
@@ -21,10 +9,19 @@ __all__ = [
...
@@ -21,10 +9,19 @@ __all__ = [
"SLAPlannerDefaults"
,
"SLAPlannerDefaults"
,
"ServiceConfig"
,
"ServiceConfig"
,
]
]
# Import the classes
# Import the classes
from
dynamo.planner.circusd
import
CircusController
from
dynamo.planner.circusd
import
CircusController
from
dynamo.planner.config
import
ServiceConfig
from
dynamo.planner.config
import
ServiceConfig
from
dynamo.planner.defaults
import
LoadPlannerDefaults
,
SLAPlannerDefaults
from
dynamo.planner.defaults
import
LoadPlannerDefaults
,
SLAPlannerDefaults
from
dynamo.planner.kubernetes_connector
import
KubernetesConnector
from
dynamo.planner.kubernetes_connector
import
KubernetesConnector
from
dynamo.planner.planner_connector
import
PlannerConnector
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"
components/planner/src/dynamo/planner/config.py
View file @
ccc8c627
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# 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
json
import
logging
import
logging
...
...
components/planner/src/dynamo/planner/utils/planner_core.py
View file @
ccc8c627
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# 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
argparse
import
asyncio
import
asyncio
...
@@ -21,7 +9,7 @@ import time
...
@@ -21,7 +9,7 @@ import time
from
dataclasses
import
dataclass
from
dataclasses
import
dataclass
from
typing
import
Optional
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.defaults
import
WORKER_COMPONENT_NAMES
,
SLAPlannerDefaults
from
dynamo.planner.utils.load_predictor
import
LOAD_PREDICTORS
from
dynamo.planner.utils.load_predictor
import
LOAD_PREDICTORS
from
dynamo.planner.utils.perf_interpolation
import
(
from
dynamo.planner.utils.perf_interpolation
import
(
...
@@ -346,6 +334,9 @@ async def start_sla_planner(runtime: DistributedRuntime, args: argparse.Namespac
...
@@ -346,6 +334,9 @@ async def start_sla_planner(runtime: DistributedRuntime, args: argparse.Namespac
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
parser
=
argparse
.
ArgumentParser
()
parser
=
argparse
.
ArgumentParser
()
# Common planner arguments
# Common planner arguments
parser
.
add_argument
(
"--version"
,
action
=
"version"
,
version
=
f
"Dynamo Planner
{
__version__
}
"
)
parser
.
add_argument
(
parser
.
add_argument
(
"--environment"
,
"--environment"
,
type
=
str
,
type
=
str
,
...
...
container/Dockerfile
View file @
ccc8c627
...
@@ -218,7 +218,7 @@ COPY --from=base $VIRTUAL_ENV $VIRTUAL_ENV
...
@@ -218,7 +218,7 @@ COPY --from=base $VIRTUAL_ENV $VIRTUAL_ENV
ENV
PATH=$CARGO_HOME/bin:$VIRTUAL_ENV/bin:$PATH
ENV
PATH=$CARGO_HOME/bin:$VIRTUAL_ENV/bin:$PATH
# Copy configuration files first for better layer caching
# 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 source code
COPY
lib/ /opt/dynamo/lib/
COPY
lib/ /opt/dynamo/lib/
...
@@ -270,4 +270,4 @@ RUN --mount=type=bind,source=./container/launch_message.txt,target=/opt/dynamo/l
...
@@ -270,4 +270,4 @@ RUN --mount=type=bind,source=./container/launch_message.txt,target=/opt/dynamo/l
echo
"cat ~/.launch_screen"
>>
~/.bashrc
echo
"cat ~/.launch_screen"
>>
~/.bashrc
ENTRYPOINT
["/opt/nvidia/nvidia_entrypoint.sh"]
ENTRYPOINT
["/opt/nvidia/nvidia_entrypoint.sh"]
CMD
[]
CMD
[]
\ No newline at end of file
container/Dockerfile.sglang
View file @
ccc8c627
...
@@ -337,6 +337,7 @@ COPY LICENSE /workspace/
...
@@ -337,6 +337,7 @@ COPY LICENSE /workspace/
COPY Cargo.toml /workspace/
COPY Cargo.toml /workspace/
COPY Cargo.lock /workspace/
COPY Cargo.lock /workspace/
COPY rust-toolchain.toml /workspace/
COPY rust-toolchain.toml /workspace/
COPY hatch_build.py /workspace/
# Copy source code
# Copy source code
COPY lib/ /workspace/lib/
COPY lib/ /workspace/lib/
...
...
container/Dockerfile.trtllm
View file @
ccc8c627
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# 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="nvcr.io/nvidia/pytorch"
ARG BASE_IMAGE_TAG="25.05-py3"
ARG BASE_IMAGE_TAG="25.05-py3"
...
@@ -285,6 +273,7 @@ COPY LICENSE /workspace/
...
@@ -285,6 +273,7 @@ COPY LICENSE /workspace/
COPY Cargo.toml /workspace/
COPY Cargo.toml /workspace/
COPY Cargo.lock /workspace/
COPY Cargo.lock /workspace/
COPY rust-toolchain.toml /workspace/
COPY rust-toolchain.toml /workspace/
COPY hatch_build.py /workspace/
# Copy source code
# Copy source code
COPY lib/ /workspace/lib/
COPY lib/ /workspace/lib/
...
...
container/Dockerfile.vllm
View file @
ccc8c627
...
@@ -352,6 +352,7 @@ COPY LICENSE /workspace/
...
@@ -352,6 +352,7 @@ COPY LICENSE /workspace/
COPY Cargo.toml /workspace/
COPY Cargo.toml /workspace/
COPY Cargo.lock /workspace/
COPY Cargo.lock /workspace/
COPY rust-toolchain.toml /workspace/
COPY rust-toolchain.toml /workspace/
COPY hatch_build.py /workspace/
# Copy source code
# Copy source code
COPY lib/ /workspace/lib/
COPY lib/ /workspace/lib/
...
...
hatch_build.py
0 → 100644
View file @
ccc8c627
# 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
)
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment