From bdd6fc45d054a50851ae023e483a8f842d6c7fba Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Mon, 3 Feb 2025 14:16:59 -0500 Subject: [PATCH] [Misc] Fix improper placement of SPDX header in scripts (#12694) Signed-off-by: Russell Bryant Signed-off-by: Felix Marty --- cmake/hipify.py | 3 +-- tests/models/test_transformers.py | 1 + tools/check_spdx_header.py | 17 ++++++++++++----- tools/report_build_time_ninja.py | 2 +- vllm/attention/ops/triton_flash_attention.py | 3 +-- vllm/model_executor/models/transformers.py | 1 + 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/cmake/hipify.py b/cmake/hipify.py index 2e0c8a172410f..a15577125eb1f 100755 --- a/cmake/hipify.py +++ b/cmake/hipify.py @@ -1,6 +1,5 @@ -# SPDX-License-Identifier: Apache-2.0 - #!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 # # A command line tool for running pytorch's hipify preprocessor on CUDA diff --git a/tests/models/test_transformers.py b/tests/models/test_transformers.py index c6536f37cbdc8..1d5d9729df85b 100644 --- a/tests/models/test_transformers.py +++ b/tests/models/test_transformers.py @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: Apache-2.0 """Test the functionality of the Transformers backend. Run `pytest tests/models/test_transformers.py`. diff --git a/tools/check_spdx_header.py b/tools/check_spdx_header.py index 3f7fd66bf64b6..709befc53207c 100644 --- a/tools/check_spdx_header.py +++ b/tools/check_spdx_header.py @@ -10,18 +10,25 @@ def check_spdx_header(file_path): with open(file_path, encoding='UTF-8') as file: lines = file.readlines() if not lines: - # not necessary for an empty file like __init__.py + # Empty file like __init__.py return True - if not lines[0].strip().startswith(SPDX_HEADER_PREFIX): - return False - return True + for line in lines: + if line.strip().startswith(SPDX_HEADER_PREFIX): + return True + return False def add_header(file_path): with open(file_path, 'r+', encoding='UTF-8') as file: lines = file.readlines() file.seek(0, 0) - file.write(SPDX_HEADER + '\n\n' + ''.join(lines)) + if lines and lines[0].startswith("#!"): + file.write(lines[0]) + file.write(SPDX_HEADER + '\n') + file.writelines(lines[1:]) + else: + file.write(SPDX_HEADER + '\n') + file.writelines(lines) def main(): diff --git a/tools/report_build_time_ninja.py b/tools/report_build_time_ninja.py index 33e85b9ff1a42..011af25229f4b 100644 --- a/tools/report_build_time_ninja.py +++ b/tools/report_build_time_ninja.py @@ -1,6 +1,6 @@ +#!/usr/bin/env python3 # SPDX-License-Identifier: Apache-2.0 -#!/usr/bin/env python3 # Copyright (c) 2018 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/vllm/attention/ops/triton_flash_attention.py b/vllm/attention/ops/triton_flash_attention.py index ab8fb89536412..745818eb6cfff 100644 --- a/vllm/attention/ops/triton_flash_attention.py +++ b/vllm/attention/ops/triton_flash_attention.py @@ -1,6 +1,5 @@ -# SPDX-License-Identifier: Apache-2.0 - #!/usr/bin/env python +# SPDX-License-Identifier: Apache-2.0 """ Fused Attention =============== diff --git a/vllm/model_executor/models/transformers.py b/vllm/model_executor/models/transformers.py index ff1ae0ac85bac..160beaa146ea3 100644 --- a/vllm/model_executor/models/transformers.py +++ b/vllm/model_executor/models/transformers.py @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: Apache-2.0 # Copyright 2024 The vLLM team. # # Licensed under the Apache License, Version 2.0 (the "License");