Skip to content

Commit 3a8aeec

Browse files
author
codegen-bot
committed
CG-10473: Generate function_imports on build
1 parent 8168f6d commit 3a8aeec

File tree

5 files changed

+13
-34
lines changed

5 files changed

+13
-34
lines changed

.pre-commit-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ repos:
4343
exclude_types: [mdx, pyi]
4444
- id: check-yaml
4545
- id: end-of-file-fixer
46-
files: .*/expected_diff.patch
4746
- id: check-merge-conflict
4847

4948
- repo: https://github.com/python-jsonschema/check-jsonschema

pyproject.toml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,7 @@ max-line-length = 200
153153

154154
[tool.ruff]
155155
line-length = 200
156-
exclude = [
157-
"app/codemod/compilation/function_imports.py", # generated import list to compile uesr code with
158-
'codegen_tests/**/expected*/**',
159-
'codegen_tests/**/original/**',
160-
'codegen_tests/projects/**/codebase/**',
161-
'docs/**',
162-
'scripts/Debugging/**',
163-
]
156+
exclude = ["src/codegen/shared/compilation/function_imports.py", 'docs/**']
164157

165158
lint.select = ["F", "E", "W", "I", "UP", "D", "RUF", "DTZ"]
166159
lint.ignore = [
@@ -192,9 +185,8 @@ lint.exclude = [
192185
] # disable just linting for notebooks (allow for formatting)
193186
lint.pydocstyle.convention = "google"
194187
[tool.ruff.lint.isort]
195-
known-first-party = ["app"]
196-
known-third-party = ["git"]
197-
#known-local-folder=[]
188+
known-first-party = ["codegen"]
189+
198190
[tool.coverage.run]
199191
branch = true
200192
plugins = ["Cython.Coverage"]

src/codegen/gsbuild/build.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,19 @@ def update_init_file(file: Path) -> None:
1515
file.write_text(content)
1616

1717

18+
def update_function_imports(root_path: Path) -> None:
19+
from codegen.gscli.generate.runner_imports import _generate_runner_imports
20+
21+
file_path = root_path / "src" / "codegen" / "shared" / "compilation" / "function_imports.py"
22+
print(str(file_path))
23+
_generate_runner_imports(str(file_path))
24+
25+
1826
class SpecialBuildHook(BuildHookInterface):
1927
PLUGIN_NAME = "codegen_build"
2028

2129
def initialize(self, version: str, build_data: dict[str, Any]) -> None:
2230
file = Path(self.root) / "src" / "codegen" / "sdk" / "__init__.py"
2331
update_init_file(file)
24-
32+
update_function_imports(Path(self.root))
2533
build_data["artifacts"].append(f"/{file}")

src/codegen/sdk/core/global_context.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/codegen/shared/compilation/function_imports.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def get_generated_imports():
1515
from codegen.git.models.pr_part_context import PRPartContext
1616
from codegen.git.models.pull_request_context import PullRequestContext
1717
18-
from codegen.sdk.codebase.control_flow import StopCodemodException
18+
from codegen.shared.exceptions.control_flow import StopCodemodException
1919
2020
# GraphSitter imports (public)
2121
from codegen.sdk.codebase.flagging.enums import FlagKwargs

0 commit comments

Comments
 (0)