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
vllm_cscc
Commits
111fc6e7
Unverified
Commit
111fc6e7
authored
Jul 12, 2024
by
Michael Goin
Committed by
GitHub
Jul 12, 2024
Browse files
[Misc] Add generated git commit hash as `vllm.__commit__` (#6386)
parent
75f64d8b
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
1 deletion
+47
-1
.gitignore
.gitignore
+3
-0
setup.py
setup.py
+24
-0
tests/test_embedded_commit.py
tests/test_embedded_commit.py
+7
-0
vllm/__init__.py
vllm/__init__.py
+2
-1
vllm/version.py
vllm/version.py
+11
-0
No files found.
.gitignore
View file @
111fc6e7
# vllm commit id, generated by setup.py
vllm/commit_id.py
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
...
...
setup.py
View file @
111fc6e7
...
...
@@ -5,6 +5,7 @@ import os
import
re
import
subprocess
import
sys
import
warnings
from
shutil
import
which
from
typing
import
Dict
,
List
...
...
@@ -26,6 +27,29 @@ def load_module_from_path(module_name, path):
ROOT_DIR
=
os
.
path
.
dirname
(
__file__
)
logger
=
logging
.
getLogger
(
__name__
)
def
embed_commit_hash
():
try
:
commit_id
=
subprocess
.
check_output
([
"git"
,
"rev-parse"
,
"HEAD"
],
encoding
=
"utf-8"
).
strip
()
commit_contents
=
f
'__commit__ = "
{
commit_id
}
"
\n
'
version_file
=
os
.
path
.
join
(
ROOT_DIR
,
"vllm"
,
"commit_id.py"
)
with
open
(
version_file
,
"w"
,
encoding
=
"utf-8"
)
as
f
:
f
.
write
(
commit_contents
)
except
subprocess
.
CalledProcessError
as
e
:
warnings
.
warn
(
f
"Failed to get commit hash:
\n
{
e
}
"
,
RuntimeWarning
,
stacklevel
=
2
)
except
Exception
as
e
:
warnings
.
warn
(
f
"Failed to embed commit hash:
\n
{
e
}
"
,
RuntimeWarning
,
stacklevel
=
2
)
embed_commit_hash
()
# cannot import envs directly because it depends on vllm,
# which is not installed yet
envs
=
load_module_from_path
(
'envs'
,
os
.
path
.
join
(
ROOT_DIR
,
'vllm'
,
'envs.py'
))
...
...
tests/test_embedded_commit.py
0 → 100644
View file @
111fc6e7
import
vllm
def
test_embedded_commit_defined
():
assert
vllm
.
__commit__
!=
"COMMIT_HASH_PLACEHOLDER"
# 7 characters is the length of a short commit hash
assert
len
(
vllm
.
__commit__
)
>=
7
vllm/__init__.py
View file @
111fc6e7
...
...
@@ -12,9 +12,10 @@ from vllm.outputs import (CompletionOutput, EmbeddingOutput,
from
vllm.pooling_params
import
PoolingParams
from
vllm.sampling_params
import
SamplingParams
from
.version
import
__version__
from
.version
import
__commit__
,
__version__
__all__
=
[
"__commit__"
,
"__version__"
,
"LLM"
,
"ModelRegistry"
,
...
...
vllm/version.py
View file @
111fc6e7
import
warnings
try
:
import
vllm.commit_id
__commit__
=
vllm
.
commit_id
.
__commit__
except
Exception
as
e
:
warnings
.
warn
(
f
"Failed to read commit hash:
\n
{
e
}
"
,
RuntimeWarning
,
stacklevel
=
2
)
__commit__
=
"COMMIT_HASH_PLACEHOLDER"
__version__
=
"0.5.1"
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