Skip to content

Conversation

XuehaiPan
Copy link
Contributor

Motivation

As per the title, fix module docstrings and copyright headers.

Modifications

  1. Use multiline comments instead of triple quoted strings for copyright at the top of the file.

Before:

In [1]: import sglang.srt.layers.activation
 
In [2]: print(sglang.srt.layers.activation.__doc__)

Copyright 2023-2024 SGLang Team
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.

After:

In [1]: import sglang.srt.layers.activation

In [2]: print(sglang.srt.layers.activation.__doc__)
Fused operators for activation layers.
  1. Fix the copyright owner name in LICENSE.

Checklist

  • Format your code according to the Contributor Guide.
  • Add unit tests as outlined in the Contributor Guide.
  • Update documentation as needed, including docstrings or example tutorials.

@@ -1,17 +1,16 @@
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this change is effective, please keep it as it is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you elaborate more about what the word "effective" means?

If the module do not have a docstring, the __doc__ attribute should be None instead of a copyright string.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @XuehaiPan I just realized I didn't look carefully before. Thank you for your reply. Changing """ to # is reasonable. Could you send another PR? Thanks!

@zhyncs
Copy link
Member

zhyncs commented Nov 18, 2024

Thanks anyway!

@zhyncs zhyncs closed this Nov 18, 2024
@XuehaiPan
Copy link
Contributor Author

It's OK for me if you do not want the project to be maintained under a higher code standard. lol 🤷‍♂️

@merrymercy
Copy link
Contributor

@zhyncs why do you reject this PR?

@merrymercy
Copy link
Contributor

@XuehaiPan Can you share your scripts to do these changes?

@merrymercy merrymercy reopened this Nov 22, 2024
@zhyncs zhyncs merged commit 62a4a33 into sgl-project:main Nov 22, 2024
13 checks passed
@XuehaiPan XuehaiPan deleted the copyright branch November 22, 2024 17:04
@XuehaiPan
Copy link
Contributor Author

@XuehaiPan Can you share your scripts to do these changes?

#!/usr/bin/env python3

import re
import subprocess
from pathlib import Path


GIT_DEFAULT_BRANCH = "main"
GIT_TRACKED_FILES = list(
    map(
        Path,
        filter(
            None,
            map(
                str.strip,
                subprocess.check_output(
                    [
                        "git",
                        "ls-tree",
                        "-r",
                        "--name-only",
                        GIT_DEFAULT_BRANCH,
                    ],
                    text=True,
                ).splitlines(),
            ),
        ),
    )
)


COPYRIGHT_PATTERN = re.compile(
    r'''
    """\n
    Copyright
    .*?         # non-greedy match
    License\.\n
    """
    ''',
    flags=re.VERBOSE | re.IGNORECASE | re.DOTALL,
)


def replace_quoted_string_to_comments(match):
    string = match.group().replace('"""', "").strip()
    string = "\n".join(f"# {line}".strip() for line in string.splitlines())
    string += "\n# " + "=" * 78
    return string


for file in GIT_TRACKED_FILES:
    try:
        content = file.read_text(encoding="utf-8")
    except UnicodeError:
        continue  # non-text file

    updated_content = COPYRIGHT_PATTERN.sub(replace_quoted_string_to_comments, content)
    file.write_text(updated_content, encoding="utf-8")

timethink pushed a commit to timethink/sglang that referenced this pull request Mar 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants