mirror of
https://github.com/NVIDIA/OpenShell.git
synced 2026-10-02 07:34:45 +08:00
* feat(api)!: use sandbox names as canonical references Signed-off-by: Drew Newberry <anewberry@nvidia.com> * test(cli): update forward color fixture for workspace scope Signed-off-by: Drew Newberry <anewberry@nvidia.com> * fix(supervisor): use sandbox names for settings lookup Signed-off-by: Drew Newberry <anewberry@nvidia.com> * test(e2e): use canonical sandbox request fields Signed-off-by: Drew Newberry <anewberry@nvidia.com> * test(e2e): use canonical sandbox receipt field Signed-off-by: Drew Newberry <anewberry@nvidia.com> * fix(server): harden sandbox mutation handling Signed-off-by: Drew Newberry <anewberry@nvidia.com> * fix(ci): update rebased sandbox references Signed-off-by: Drew Newberry <anewberry@nvidia.com> * feat(api)!: standardize canonical entity references Signed-off-by: Drew Newberry <anewberry@nvidia.com> * docs(api): codify protobuf API conventions Signed-off-by: Drew Newberry <anewberry@nvidia.com> * fix(api): preserve workspace selector semantics Signed-off-by: Drew Newberry <anewberry@nvidia.com> * fix(api): restore workspace selector parity Signed-off-by: Drew Newberry <anewberry@nvidia.com> * fix(api): preserve descriptive name fields Signed-off-by: Drew Newberry <anewberry@nvidia.com> * fix(api): update e2e request fixtures Signed-off-by: Drew Newberry <anewberry@nvidia.com> * fix(core): omit workspace selector during bootstrap Signed-off-by: Drew Newberry <anewberry@nvidia.com> * chore(api): remove proto convention checker Signed-off-by: Drew Newberry <anewberry@nvidia.com> * chore(api): refresh schema fingerprints after rebase Signed-off-by: Drew Newberry <anewberry@nvidia.com> * fix(cli): use canonical provider receipt field Signed-off-by: Drew Newberry <anewberry@nvidia.com> --------- Signed-off-by: Drew Newberry <anewberry@nvidia.com>
100 lines
2.8 KiB
Python
100 lines
2.8 KiB
Python
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
"""Generate Python protobuf stubs and make their imports package-relative."""
|
|
|
|
import re
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
PROTO_FILES = [
|
|
"proto/openshell.proto",
|
|
"proto/datamodel.proto",
|
|
"proto/options.proto",
|
|
"proto/sandbox.proto",
|
|
]
|
|
|
|
LINE_REWRITES = {
|
|
"python/openshell/_proto/openshell_pb2_grpc.py": [
|
|
(
|
|
r"^import openshell_pb2 as openshell__pb2$",
|
|
"from . import openshell_pb2 as openshell__pb2",
|
|
),
|
|
(
|
|
r"^import sandbox_pb2 as sandbox__pb2$",
|
|
"from . import sandbox_pb2 as sandbox__pb2",
|
|
),
|
|
],
|
|
"python/openshell/_proto/openshell_pb2.py": [
|
|
(
|
|
r"^import datamodel_pb2 as datamodel__pb2$",
|
|
"from . import datamodel_pb2 as datamodel__pb2",
|
|
),
|
|
(
|
|
r"^import options_pb2 as options__pb2$",
|
|
"from . import options_pb2 as options__pb2",
|
|
),
|
|
(
|
|
r"^import sandbox_pb2 as sandbox__pb2$",
|
|
"from . import sandbox_pb2 as sandbox__pb2",
|
|
),
|
|
],
|
|
"python/openshell/_proto/datamodel_pb2.py": [
|
|
(
|
|
r"^import options_pb2 as options__pb2$",
|
|
"from . import options_pb2 as options__pb2",
|
|
),
|
|
(
|
|
r"^import sandbox_pb2 as sandbox__pb2$",
|
|
"from . import sandbox_pb2 as sandbox__pb2",
|
|
),
|
|
],
|
|
"python/openshell/_proto/datamodel_pb2_grpc.py": [
|
|
(
|
|
r"^import datamodel_pb2 as datamodel__pb2$",
|
|
"from . import datamodel_pb2 as datamodel__pb2",
|
|
),
|
|
],
|
|
"python/openshell/_proto/sandbox_pb2.py": [
|
|
(
|
|
r"^import datamodel_pb2 as datamodel__pb2$",
|
|
"from . import datamodel_pb2 as datamodel__pb2",
|
|
),
|
|
],
|
|
"python/openshell/_proto/sandbox_pb2_grpc.py": [
|
|
(
|
|
r"^import sandbox_pb2 as sandbox__pb2$",
|
|
"from . import sandbox_pb2 as sandbox__pb2",
|
|
),
|
|
],
|
|
}
|
|
|
|
|
|
def main() -> None:
|
|
subprocess.run(
|
|
[
|
|
sys.executable,
|
|
"-m",
|
|
"grpc_tools.protoc",
|
|
"-Iproto",
|
|
"--python_out=python/openshell/_proto",
|
|
"--pyi_out=python/openshell/_proto",
|
|
"--grpc_python_out=python/openshell/_proto",
|
|
*PROTO_FILES,
|
|
],
|
|
check=True,
|
|
)
|
|
|
|
for path, rules in LINE_REWRITES.items():
|
|
file_path = Path(path)
|
|
text = file_path.read_text()
|
|
text = text.replace("from . from . import", "from . import")
|
|
for pattern, replacement in rules:
|
|
text = re.sub(pattern, replacement, text, flags=re.MULTILINE)
|
|
file_path.write_text(text)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|