Ensure blank line after copyright header (#97)

* Ensure copyright header has separating blank line

* fix check script

* trigger pre-commits
This commit is contained in:
Yuge Zhang
2025-09-19 13:32:24 +08:00
committed by GitHub
parent ba10c845e1
commit 0a92600a4c
53 changed files with 182 additions and 0 deletions
+3
View File
@@ -29,6 +29,9 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -e .[dev]
- name: Check Python headers
run: |
python scripts/check_python_headers.py
- name: Run Black
run: |
black --check --diff --line-length=120 .
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
__version__ = "0.1.2"
from .client import AgentLightningClient, DevTaskLoader
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
import time
from agentlightning.instrumentation.agentops import AgentOpsServerManager
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
from typing import List
from vllm.entrypoints.cli.main import main
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
import asyncio
import logging
import time
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
"""
This file is not carefully reviewed.
It might contain unintentional bugs and issues.
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
import warnings
AGENTOPS_INSTALLED = False
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
import logging
import multiprocessing
import signal
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
from typing import Dict, Any
from agentops.integration.callbacks.langchain import LangchainCallbackHandler
from agentops import instrumentation
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
from typing import Optional, Any
from litellm.integrations.opentelemetry import OpenTelemetry
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
# type: ignore
# https://github.com/volcengine/verl/blob/bd94bd61fe4193e56f2845dc794004afbef7f818/examples/ppo_trainer/naive_chat_scheduler.py
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
from __future__ import annotations
import warnings
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
from __future__ import annotations
import logging
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
import logging
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
import asyncio
import inspect
import warnings
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
import asyncio
import json
import logging
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
import asyncio
import logging
import time
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
from .base import BaseTracer
from .agentops import AgentOpsTracer
from .triplet import TripletExporter
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
from __future__ import annotations
import logging
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
from contextlib import contextmanager
from typing import Iterator, List, Optional, Callable, Any, Awaitable
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
from contextlib import contextmanager
from typing import Iterator, List, Optional, Any, Dict, Callable, Awaitable
import logging
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
import json
import re
from enum import Enum
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
import asyncio
import logging
import multiprocessing
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
from typing import Any, Dict, List, Optional, Union, Literal, Annotated
from pydantic import BaseModel, Field, Discriminator
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
from .trainer import *
from .daemon import *
from .dataset import *
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
from .entrypoint import main
if __name__ == "__main__":
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
import ray
from copy import deepcopy
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
import asyncio
import json
import random
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
import torch
from verl.utils.dataset.rl_dataset import RLHFDataset
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
import hydra
import ray
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
import random
from contextlib import contextmanager
from copy import deepcopy
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
import asyncio
from agentlightning.server import AgentLightningServer
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
import dotenv
import os
import random
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
import math
import os
import string
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
import os
from agentlightning import Trainer, DevTaskLoader, LLM
from calc_agent import CalcAgent
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
import agentops
from agentlightning.reward import reward
from agentops.sdk.decorators import operation
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
import os
import asyncio
import json
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
from __future__ import annotations
import os
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
import json
import pickle
import re
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
import faiss
from sentence_transformers import SentenceTransformer
import pickle
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
import os
import pandas as pd
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
# type: ignore
# The evaluation code is from https://github.com/taoyds/test-suite-sql-eval
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
# type: ignore
# The evaluation code is from https://github.com/taoyds/test-suite-sql-eval
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
# type: ignore
# The evaluation code is from https://github.com/taoyds/test-suite-sql-eval
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
# type: ignore
# The evaluation code is from https://github.com/taoyds/test-suite-sql-eval
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
"""
Adapted from https://python.langchain.com/docs/tutorials/sql_qa/
as well as https://langchain-ai.github.io/langgraph/tutorials/sql-agent/
+77
View File
@@ -0,0 +1,77 @@
# Copyright (c) Microsoft. All rights reserved.
"""Utility script to ensure Python files include the required copyright header."""
from __future__ import annotations
import subprocess
import sys
from pathlib import Path
REQUIRED_HEADER = "# Copyright (c) Microsoft. All rights reserved."
REPO_ROOT = Path(__file__).resolve().parent.parent
def iter_python_files() -> list[Path]:
"""Return a list of tracked Python files respecting .gitignore rules."""
result = subprocess.run(
[
"git",
"ls-files",
"--cached",
"--others",
"--exclude-standard",
"*.py",
],
capture_output=True,
text=True,
check=True,
cwd=REPO_ROOT,
)
return [REPO_ROOT / line.strip() for line in result.stdout.splitlines() if line.strip()]
def main() -> int:
missing_header: list[str] = []
missing_blank_line: list[str] = []
for file_path in iter_python_files():
try:
with file_path.open("r", encoding="utf-8") as file:
first_line = file.readline().rstrip("\r\n")
second_line = file.readline()
except OSError as exc:
print(f"Failed to read {file_path}: {exc}", file=sys.stderr)
return 1
if first_line != REQUIRED_HEADER:
missing_header.append(str(file_path.relative_to(REPO_ROOT)))
continue
# Second line should be either an EOF or a blank line
if second_line and second_line.strip():
missing_blank_line.append(str(file_path.relative_to(REPO_ROOT)))
if missing_header:
print("The following Python files are missing the required copyright header:")
for path in missing_header:
print(f" - {path}")
print(
"Run the appropriate script or add the header manually:",
f"\n{REQUIRED_HEADER}",
)
if missing_blank_line:
print("The following Python files are missing a blank line after the copyright header:")
for path in missing_blank_line:
print(f" - {path}")
print("Ensure there is an empty line separating the header from the rest of the file.")
if missing_header or missing_blank_line:
return 1
return 0
if __name__ == "__main__":
sys.exit(main())
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
import wandb
import sys
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
import asyncio
import time
from typing import Any, Dict, AsyncGenerator
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
"""
This file is not carefully reviewed.
It is to ensure the *somewhat* correctness of the code in agentlightning/config.py.
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
import pytest
from contextlib import contextmanager
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
"""
Integration tests for various agent frameworks with AgentLightning.
+2
View File
@@ -1,3 +1,5 @@
# Copyright (c) Microsoft. All rights reserved.
#!/usr/bin/env python3
"""
Functional tests for HttpTracer with real HTTP requests.