Repository navigation
Prepare component licensing for EgoPost #1248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
jiwenc-nv marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| OpenMDW License Agreement, version 1.1 (OpenMDW-1.1) | ||
|
|
||
| By exercising rights granted to you under this agreement, you accept and agree | ||
| to its terms. | ||
|
|
||
| As used in this agreement, "Model Materials" means the materials provided to | ||
| you under this agreement, consisting of: (1) one or more machine learning | ||
| models (including architecture and parameters); and (2) all related artifacts | ||
| (including associated data, documentation and software) that are provided to | ||
| you hereunder. | ||
|
|
||
| Subject to your compliance with this agreement, permission is hereby granted, | ||
| free of charge, to deal in the Model Materials without restriction, including | ||
| under all copyright, patent, database, and trade secret rights included or | ||
| embodied therein. | ||
|
|
||
| If you distribute any portion of the Model Materials, you shall retain in your | ||
| distribution (1) a copy of this agreement, and (2) all copyright notices and | ||
| other notices of origin included in the Model Materials that are applicable to | ||
| your distribution. | ||
|
|
||
| If you file, maintain, or voluntarily participate in a lawsuit against any | ||
| person or entity asserting that the Model Materials directly or indirectly | ||
| infringe any patent or copyright, then all rights and grants made to you | ||
| hereunder are terminated, unless that lawsuit was in response to a | ||
| corresponding lawsuit first brought against you. | ||
|
|
||
| This agreement does not impose any restrictions or obligations with respect to | ||
| any use, modification, or sharing of any outputs generated by using the Model | ||
| Materials. | ||
|
|
||
| THE MODEL MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
| OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE, TITLE, NONINFRINGEMENT, ACCURACY, OR THE | ||
| ABSENCE OF LATENT OR OTHER DEFECTS OR ERRORS, WHETHER OR NOT DISCOVERABLE, ALL | ||
| TO THE GREATEST EXTENT PERMISSIBLE UNDER APPLICABLE LAW. | ||
|
|
||
| YOU ARE SOLELY RESPONSIBLE FOR (1) CLEARING RIGHTS OF OTHER PERSONS THAT MAY | ||
| APPLY TO THE MODEL MATERIALS OR ANY USE THEREOF, INCLUDING WITHOUT LIMITATION | ||
| ANY PERSON'S COPYRIGHTS OR OTHER RIGHTS INCLUDED OR EMBODIED IN THE MODEL | ||
| MATERIALS; (2) OBTAINING ANY NECESSARY CONSENTS, PERMISSIONS OR OTHER RIGHTS | ||
| REQUIRED FOR ANY USE OF THE MODEL MATERIALS; OR (3) PERFORMING ANY DUE | ||
| DILIGENCE OR UNDERTAKING ANY OTHER INVESTIGATIONS INTO THE MODEL MATERIALS OR | ||
| ANYTHING INCORPORATED OR EMBODIED THEREIN. | ||
|
|
||
| IN NO EVENT SHALL THE PROVIDERS OF THE MODEL MATERIALS BE LIABLE FOR ANY CLAIM, | ||
| DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
| OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MODEL MATERIALS, THE | ||
| USE THEREOF OR OTHER DEALINGS THEREIN. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,176 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """Check and fix Isaac Capture source headers, including all EgoPost assets.""" | ||
|
|
||
| import argparse | ||
| import re | ||
| import subprocess | ||
| import sys | ||
| from datetime import date | ||
| from pathlib import Path | ||
|
|
||
| from reuse.global_licensing import ReuseTOML | ||
| from reuse.project import Project | ||
|
|
||
| EGOPOST_SUBTREE = Path("src/python/isaaccapture_egopost") | ||
| EGOPOST_LICENSE = "LicenseRef-OpenMDW-1.1" | ||
| DEFAULT_LICENSE = "Apache-2.0" | ||
| COPYRIGHT_HOLDER = "NVIDIA CORPORATION & AFFILIATES. All rights reserved." | ||
| SOURCE_FILES = re.compile( | ||
| r"\.(py|js|ts|cpp|c|h|hpp|cxx|hxx|cmake|md|yaml|yml|sh|fbs|toml|html)$" | ||
| r"|CMakeLists\.txt$|Dockerfile(\.[A-Za-z0-9_-]+)?$" | ||
| ) | ||
|
|
||
|
|
||
| def covered_paths(project: Project) -> list[Path]: | ||
| # Check source files repository-wide; EgoPost additionally includes all assets. | ||
| paths = (path.relative_to(project.root) for path in project.all_files()) | ||
| return sorted( | ||
| path | ||
| for path in paths | ||
| if path.is_relative_to(EGOPOST_SUBTREE) or SOURCE_FILES.search(str(path)) | ||
| ) | ||
|
|
||
|
|
||
| def third_party_path(path: Path) -> bool: | ||
| # Directory exemptions follow the repository layout: third_party lives in deps. | ||
| return path.parts[0] == "deps" | ||
|
|
||
|
|
||
| def is_egopost_default(project: Project, path: Path, info) -> bool: | ||
| if info.source_type.value != "reuse-toml" or info.source_path != "REUSE.toml": | ||
| return False | ||
| annotation = ReuseTOML.from_file(project.root / "REUSE.toml").find_annotations_item( | ||
| path | ||
| ) | ||
| # A subtree fallback is policy, not an explicit per-file exception. | ||
| return annotation is not None and f"{EGOPOST_SUBTREE}/**" in annotation.paths | ||
|
|
||
|
|
||
| def check_egopost_default(project: Project) -> bool: | ||
| annotations = ReuseTOML.from_file(project.root / "REUSE.toml").annotations | ||
| defaults = [item for item in annotations if f"{EGOPOST_SUBTREE}/**" in item.paths] | ||
| if not defaults or any( | ||
| {str(expr) for expr in item.spdx_expressions} != {EGOPOST_LICENSE} | ||
| or item.precedence.value != "closest" | ||
| for item in defaults | ||
| ): | ||
| print( | ||
| f"REUSE.toml: EgoPost default must be {EGOPOST_LICENSE} with closest precedence" | ||
| ) | ||
| return False | ||
| return True | ||
|
|
||
|
|
||
| def first_party_licenses(project: Project, path: Path) -> set[str] | None: | ||
| if third_party_path(path): | ||
| return None | ||
| infos = project.reuse_info_of(path) | ||
| notices = {notice.name for info in infos for notice in info.copyright_notices} | ||
| explicit_exception = any( | ||
| info.spdx_expressions | ||
| and info.source_type.value != "file-header" | ||
| and not is_egopost_default(project, path, info) | ||
| for info in infos | ||
| ) | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| if ( | ||
| explicit_exception | ||
| or not notices | ||
| or not all("NVIDIA CORPORATION & AFFILIATES" in notice for notice in notices) | ||
| ): | ||
| return None | ||
| return {str(expr) for info in infos for expr in info.spdx_expressions} | ||
|
|
||
|
|
||
| def fix_license(project: Project, path: Path) -> bool: | ||
| if third_party_path(path): | ||
| return False | ||
| expected = ( | ||
| EGOPOST_LICENSE if path.is_relative_to(EGOPOST_SUBTREE) else DEFAULT_LICENSE | ||
| ) | ||
| infos = project.reuse_info_of(path) | ||
| notices = {notice for info in infos for notice in info.copyright_notices} | ||
| effective = {str(expr) for info in infos for expr in info.spdx_expressions} | ||
| expressions = first_party_licenses(project, path) | ||
| add_copyright = not notices and effective <= {expected} | ||
| if add_copyright or expressions == set(): | ||
| command = [ | ||
| sys.executable, | ||
| "-m", | ||
| "reuse", | ||
| "annotate", | ||
| "--fallback-dot-license", | ||
| "-l", | ||
| expected, | ||
| ] | ||
| if add_copyright: | ||
| command += ["-c", COPYRIGHT_HOLDER, "--year", str(date.today().year)] | ||
| subprocess.run(command + [str(path)], check=True) | ||
| return True | ||
| if expressions is None: | ||
| return False | ||
| if expected == EGOPOST_LICENSE and expressions == {"Apache-2.0"}: | ||
| content = path.read_text() | ||
| # Replace only the default header tag, retaining copyright and other notices. | ||
| updated, count = re.subn( | ||
| r"(SPDX-License-Identifier:[ \t]*)Apache-2\.0(?=[ \t]*(?:\*/|-->)?[ \t]*$)", | ||
| rf"\g<1>{EGOPOST_LICENSE}", | ||
| content, | ||
| count=1, | ||
| flags=re.MULTILINE, | ||
| ) | ||
| if count: | ||
| path.write_text(updated) | ||
| print(f"{path}: updated default license to {EGOPOST_LICENSE}") | ||
| return True | ||
| return False | ||
|
|
||
|
|
||
| def check_policy(project: Project, path: Path) -> bool: | ||
| expressions = first_party_licenses(project, path) | ||
| if expressions is not None and EGOPOST_LICENSE not in expressions: | ||
| print( | ||
| f"{path}: expected {EGOPOST_LICENSE}; document any license exception explicitly" | ||
| ) | ||
| return False | ||
| return True | ||
|
|
||
|
|
||
| def main(fix: bool = False) -> int: | ||
| project = Project.from_directory(Path.cwd()) | ||
| if not check_egopost_default(project): | ||
| return 1 | ||
| paths = covered_paths(project) | ||
| changed = False | ||
| if fix: | ||
| for path in paths: | ||
| changed = fix_license(project, path) or changed | ||
| project = Project.from_directory(Path.cwd()) | ||
| ok = True | ||
| # Pass complete coverage on every invocation, including metadata-only changes. | ||
| for start in range(0, len(paths), 200): | ||
| result = subprocess.run( | ||
| [sys.executable, "-m", "reuse", "lint-file", "--"] | ||
| + [str(path) for path in paths[start : start + 200]], | ||
| check=False, | ||
| ) | ||
| ok = result.returncode == 0 and ok | ||
| for path in paths: | ||
| if path.is_relative_to(EGOPOST_SUBTREE): | ||
| ok = check_policy(project, path) and ok | ||
| if changed: | ||
| print( | ||
| "License headers updated; review and stage the changes before committing." | ||
| ) | ||
| return 0 if ok and not changed else 1 | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| parser = argparse.ArgumentParser(description=__doc__) | ||
| parser.add_argument( | ||
| "--fix", | ||
| action="store_true", | ||
| help="add default NVIDIA headers and repair default license tags", | ||
| ) | ||
| sys.exit(main(fix=parser.parse_args().fix)) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.