Skip to content

CG-10473: Generate function_imports on build #143

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 4 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .circleci/ats.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,3 @@ if [ ! -s codecov_ats/tests_to_run.txt ]; then
run_count=1
echo "Added ${TESTS_TO_RUN} as fallback. New run count: $run_count"
fi

3 changes: 0 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,3 @@ workflows:
requires:
- linux-wheels
- osx-wheels



1 change: 0 additions & 1 deletion .github/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,3 @@ cli:
- "--verbose"
- "-n=auto"
python_path: ".venv/bin/python"

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ graph-sitter-types/typings/**
coverage.json
tests/integration/verified_codemods/codemod_data/repo_commits.json
.codegen/*
.benchmarks/*
.benchmarks/*
2 changes: 1 addition & 1 deletion .lfsconfig
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[lfs]
url = [email protected]:codegen-sh/graph-sitter-private.git
url = [email protected]:codegen-sh/graph-sitter-private.git
9 changes: 8 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ repos:
exclude_types: [mdx, pyi]
- id: check-yaml
- id: end-of-file-fixer
files: .*/expected_diff.patch
exclude: (src/codemods/eval)|(tests/unit/skills/snapshots)|(tests/unit/codegen/sdk/output)|(tests/integration/verified_codemods)|(docs/)
- id: check-merge-conflict

- repo: https://github.com/python-jsonschema/check-jsonschema
Expand Down Expand Up @@ -80,6 +80,13 @@ repos:
entry: scripts/disallowed-words-check.sh
language: script
files: '' # Check all files
- id: generate-runner-imports
name: Generate Runner Imports
entry: bash -c "uv run --frozen python -m codegen.gscli.main generate runner-imports src/codegen/shared/compilation/function_imports.py"
language: system
pass_filenames: false
always_run: true

- repo: https://github.com/renovatebot/pre-commit-hooks
rev: 39.120.4
hooks:
Expand Down
1 change: 0 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,3 @@ git push origin v0.YOUR_VERSION
```

This will trigger a release job to build this new version.

1 change: 0 additions & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,3 @@ exclude = (?x)(
| tests/unit/skills/snapshots/*
)
plugins = pydantic.mypy

14 changes: 3 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,7 @@ max-line-length = 200

[tool.ruff]
line-length = 200
exclude = [
"app/codemod/compilation/function_imports.py", # generated import list to compile uesr code with
'codegen_tests/**/expected*/**',
'codegen_tests/**/original/**',
'codegen_tests/projects/**/codebase/**',
'docs/**',
'scripts/Debugging/**',
]
exclude = ["src/codegen/shared/compilation/function_imports.py", 'docs/**']

lint.select = ["F", "E", "W", "I", "UP", "D", "RUF", "DTZ"]
lint.ignore = [
Expand Down Expand Up @@ -192,9 +185,8 @@ lint.exclude = [
] # disable just linting for notebooks (allow for formatting)
lint.pydocstyle.convention = "google"
[tool.ruff.lint.isort]
known-first-party = ["app"]
known-third-party = ["git"]
#known-local-folder=[]
known-first-party = ["codegen"]

[tool.coverage.run]
branch = true
plugins = ["Cython.Coverage"]
Expand Down
2 changes: 1 addition & 1 deletion scripts/setup-lfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
./scripts/install-deps.sh

git lfs install
git lfs pull
git lfs pull
2 changes: 1 addition & 1 deletion scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ uv tool update-shell
uv venv && source .venv/bin/activate
uv sync
pre-commit install
pre-commit install-hooks
pre-commit install-hooks
1 change: 0 additions & 1 deletion src/codegen/gsbuild/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ class SpecialBuildHook(BuildHookInterface):
def initialize(self, version: str, build_data: dict[str, Any]) -> None:
file = Path(self.root) / "src" / "codegen" / "sdk" / "__init__.py"
update_init_file(file)

build_data["artifacts"].append(f"/{file}")
1 change: 0 additions & 1 deletion src/codegen/gscli/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

4 changes: 4 additions & 0 deletions src/codegen/gscli/generate/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,7 @@ def generate_codegen_sdk_docs(docs_dir: str) -> None:
json.dump(mint_data, mint_file, indent=2)

print(colored("Updated mint.json with new page sets", "green"))


if __name__ == "__main__":
generate()
8 changes: 6 additions & 2 deletions src/codegen/gscli/generate/runner_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
CODEGEN_IMPORTS = """
from codegen.git.models.codemod_context import CodemodContext
from codegen.git.models.github_named_user_context import GithubNamedUserContext
from codegen.git.models.pr_options import PROptions
from codegen.git.models.pr_part_context import PRPartContext
from codegen.git.models.pull_request_context import PullRequestContext
"""
Expand All @@ -34,13 +35,16 @@
{gs_public_imports}
""".strip()

IMPORT_FILE_TEMPLATE = '''
# This file is auto-generated, do not modify manually. Edit this in codegen-backend/cli/generate/runner_imports.py.
IMPORT_FILE_TEMPLATE = (
'''
# This file is auto-generated, do not modify manually. Edit this in src/codegen/gscli/generate/runner_imports.py.
def get_generated_imports():
return """
{import_str}
"""
'''.strip()
+ "\n"
)


def get_runner_imports(include_codegen=True, include_private_imports: bool = True) -> str:
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/runner/sandbox/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async def find_flag_groups(self, code_flags: list[CodeFlag], grouping_config: Gr

# =====[ Group the code flags ]=====
logger.info(f"> Grouping CodeFlags by config: {grouping_config}")
grouper = get_grouper_by_group_by(grouping_config.group_by, repo_id=self.codebase.op.repo_config.id)
grouper = get_grouper_by_group_by(grouping_config.group_by)
groups = grouper.create_all_groups(flags=code_flags, repo_operator=self.codebase.op)
logger.info(f"> Created {len(groups)} groups")
return groups
Expand Down
20 changes: 0 additions & 20 deletions src/codegen/sdk/core/global_context.py

This file was deleted.

1 change: 0 additions & 1 deletion src/codegen/shared/compilation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ This includes:
- Catching and logging any compilation errors
- Monkey patching built-ins like print
- etc

5 changes: 3 additions & 2 deletions src/codegen/shared/compilation/function_imports.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file is auto-generated, do not modify manually. Edit this in codegen-backend/cli/generate/runner_imports.py.
# This file is auto-generated, do not modify manually. Edit this in src/codegen/gscli/generate/runner_imports.py.
def get_generated_imports():
return """
# External imports
Expand All @@ -12,10 +12,11 @@ def get_generated_imports():

from codegen.git.models.codemod_context import CodemodContext
from codegen.git.models.github_named_user_context import GithubNamedUserContext
from codegen.git.models.pr_options import PROptions
from codegen.git.models.pr_part_context import PRPartContext
from codegen.git.models.pull_request_context import PullRequestContext

from codegen.sdk.codebase.control_flow import StopCodemodException
from codegen.shared.exceptions.control_flow import StopCodemodException

# GraphSitter imports (public)
from codegen.sdk.codebase.flagging.enums import FlagKwargs
Expand Down
Loading