Skip to content

Eli cg 10431 rename gs to codegensdk #34

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 8 commits into from
Jan 23, 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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ executors:
default_image:
docker:
- image: ghcr.io/astral-sh/uv:python<<pipeline.parameters.python_version>>-bookworm
working_directory: /graph-sitter
working_directory: /codegen-sdk
environment:
UV_COMPILE_BYTECODE: 1
UV_LINK_MODE: copy
Expand Down
4 changes: 2 additions & 2 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
* @codegen-sh/graph-sitter @codegen-team
* @codegen-sh/codegen-sdk @codegen-team
**/skills @codegen-sh/capabilities @codegen-team @codegen-sh/capabilities
**/code_generation @codegen-sh/graph-sitter @codegen-team
**/code_generation @codegen-sh/codegen-sdk @codegen-team
18 changes: 9 additions & 9 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@ component_management:
- type: project # in this case every component that doens't have a status defined will have a project type one
threshold: 0 # Shouldn't remove coverage
individual_components:
- component_id: graph-sitter-python # this is an identifier that should not be changed
name: graph-sitter-python # this is a display name, and can be changed freely
- component_id: codegen-sdk-python # this is an identifier that should not be changed
name: codegen-sdk-python # this is a display name, and can be changed freely
paths:
- src/graph_sitter/python/**
- src/codegen/sdk/python/**
statuses:
- type: project # in this case every component that doens't have a status defined will have a project type one
threshold: 0 # Shouldn't remove coverage
- type: patch
target: 50 # Language specific featues must be 100% covered
- component_id: graph-sitter-typescript
name: graph-sitter-typescript
- component_id: codegen-sdk-typescript
name: codegen-sdk-typescript
paths:
- src/graph_sitter/typescript/**
- src/codegen/sdk/typescript/**
statuses:
- type: project # in this case every component that doens't have a status defined will have a project type one
threshold: 0 # Shouldn't remove coverage
- type: patch
target: 50 # Language specific featues must be 100% covered
- component_id: graph-sitter-core
name: graph-sitter-core
- component_id: codegen-sdk-core
name: codegen-sdk-core
paths:
- src/graph_sitter/**
- src/codegen/sdk/**
- component_id: codegen-git
name: codegen-git
paths:
Expand Down
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,20 @@ alembic_versions_backup
**/.virtual_documents
/.nvmrc
**/build/test-results/test/TEST*.xml
src/graph_sitter/__init__.py
src/codegen/sdk/__init__.py
src/**/*.html
.ccache/
uv-*.tar.gz
.venv
graph-sitter-types/out/**
graph-sitter-types/typings/**
codegen-sdk/out/**
codegen-sdk/typings/**
coverage.json
tests/verified_codemods/codemod_data/repo_commits.json

# =====[ Docs ]=====
# These are auto-generated
docs/api-reference/core/*
docs/api-reference/python/*
docs/api-reference/typescript/*
docs/api-reference/typescript/*
9 changes: 0 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,6 @@ repos:
# - tomli
# files: "codegen-backend/docs/.*/.*.mdx"

# - repo: "local"
# hooks:
# - id: clean-diffs
# name: Clean codemod diffs
# entry: bash -c "cd codegen-backend && poetry run cg codemod clean-diffs"
# types: [file]
# language: system
# pass_filenames: false
# files: "codegen-backend/codegen_tests/graph_sitter/codemod/.*/expected_diff.patch"
- repo: https://github.com/fpgmaas/deptry.git
rev: "0.22.0"
hooks:
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy
ENV GITHUB_WORKSPACE=/workspace
LABEL com.circleci.preserve-entrypoint=true
# RUN uv tool install keyring --with keyrings.codeartifact
## Change the working directory to the `graph-sitter` directory
## Change the working directory to the `codegen-sdk` directory
FROM base_uv AS install-tools
RUN apt-get update && apt-get install -y build-essential curl git
RUN curl -fsSL https://deb.nodesource.com/setup_23.x -o nodesource_setup.sh
Expand All @@ -15,7 +15,7 @@ RUN corepack enable
RUN --mount=type=cache,target=/root/.cache/uv uv pip install --system coverage
RUN --mount=type=cache,target=/root/.cache/uv uv tool install codecov-cli --python 3.10
RUN --mount=type=cache,target=/root/.cache/uv uv tool install pre-commit --with pre-commit-uv
WORKDIR /graph-sitter
WORKDIR /codegen-sdk
ENTRYPOINT [ "uv", "run", "--frozen", "/bin/bash"]
FROM install-tools AS base-image
## Install dependencies
Expand All @@ -24,7 +24,7 @@ RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
--mount=type=bind,source=hatch.toml,target=hatch.toml \
uv sync --frozen --no-install-workspace --all-extras
ADD . /graph-sitter
ADD . /codegen-sdk
## Sync the project
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --all-extras
Expand Down
4 changes: 2 additions & 2 deletions codegen-git/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ source = "vcs"
raw-options = { root = ".." }

[tool.hatch.metadata.hooks.vcs]
Homepage = "https://github.com/codegen-sh/graph_sitter"
source_archive = "https://github.com/codegen-sh/graph_sitter/archive/{commit_hash}.zip"
Homepage = "https://github.com/codegen-sh/codegen-sdk"
source_archive = "https://github.com/codegen-sh/codegen-sdk/archive/{commit_hash}.zip"

#[tool.hatch.build.targets.wheel.hooks.mypyc]
#dependencies = ["hatch-mypyc", "pydantic"]
Expand Down
8 changes: 1 addition & 7 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import logging
import os

from graph_sitter.core import autocommit
from graph_sitter.testing.models import Size
from codegen.sdk.testing.models import Size


def find_dirs_to_ignore(start_dir, prefix):
Expand All @@ -15,11 +14,6 @@ def find_dirs_to_ignore(start_dir, prefix):
return dirs_to_ignore


collect_ignore_glob = ["codegen_tests/graph_sitter/codemod/**/*.py"]
if not autocommit.enabled:
collect_ignore_glob.append("**/test_autocommit.py")


def pytest_addoption(parser):
parser.addoption(
"--size",
Expand Down
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Codegen Docs

This unites docs from:
- graph-sitter (this repo)
- codegen-sdk (this repo)
- codegen-cli

## Development
Expand All @@ -17,4 +17,4 @@ You should then get hot reloading. Also recommend installing the `MDX` extension
## Adding New Pages

- Edit the page as a `.mdx` doc
- Make sure to edit `mint.json` so it appears in the UI
- Make sure to edit `mint.json` so it appears in the UI
26 changes: 13 additions & 13 deletions docs/building-with-codegen/traversing-the-call-graph.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,48 +34,48 @@ Here's how to build a directed graph of function calls using NetworkX:

```python
import networkx as nx
from graph_sitter.core.interfaces.callable import FunctionCallDefinition
from graph_sitter.core.function import Function
from codegen.sdk.core.interfaces.callable import FunctionCallDefinition
from codegen.sdk.core.function import Function

def create_call_graph(start_func, end_func, max_depth=5):
G = nx.DiGraph()

def traverse_calls(parent_func, current_depth):
if current_depth > max_depth:
return

# Determine source node
if isinstance(parent_func, Function):
src_call = src_func = parent_func
else:
src_func = parent_func.callables[0]
src_call = parent_func.call

# Traverse all function calls
for func_call_def in src_func.call_graph_successors():
call = func_call_def.call
func = func_call_def.callables[0]

# Skip recursive calls
if func.name == src_func.name:
continue

# Add nodes and edges
G.add_node(call)
G.add_edge(src_call, call)

# Check if we reached the target
if func == end_func:
G.add_edge(call, end_func)
return

# Continue traversal
traverse_calls(func_call_def, current_depth + 1)

# Initialize graph
G.add_node(start_func, color="blue") # Start node
G.add_node(end_func, color="red") # End node

# Start traversal
traverse_calls(start_func, 1)
return G
Expand Down Expand Up @@ -139,15 +139,15 @@ Find the longest call chain in your codebase:
```python
def get_max_call_chain(function):
G = nx.DiGraph()

def build_graph(func, depth=0):
if depth > 10: # Prevent infinite recursion
return
for successor in func.call_graph_successors():
called_func = successor.callables[0]
G.add_edge(func, called_func)
build_graph(called_func, depth + 1)

build_graph(function)
return nx.dag_longest_path(G)
```
Expand Down
10 changes: 5 additions & 5 deletions docs/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
from sybil.parsers.markdown import PythonCodeBlockParser
from doctest import ELLIPSIS

from graph_sitter.code_generation.current_code_codebase import get_documented_objects
from graph_sitter.codebase.factory.get_session import get_codebase_session
from graph_sitter.enums import ProgrammingLanguage
from graph_sitter.typescript.class_definition import TSClass
from graph_sitter.typescript.file import TSFile
from codegen.sdk.code_generation.current_code_codebase import get_documented_objects
from codegen.sdk.codebase.factory.get_session import get_codebase_session
from codegen.sdk.enums import ProgrammingLanguage
from codegen.sdk.typescript.class_definition import TSClass
from codegen.sdk.typescript.file import TSFile
from gscli.generate.runner_imports import EXTERNAL_IMPORTS
SAMPLE_FILENAME = {
ProgrammingLanguage.PYTHON: "sample.py",
Expand Down
6 changes: 3 additions & 3 deletions hatch.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build.hooks.vcs]
dependencies = ["hatch-vcs>=0.4.0"]
version-file = "src/graph_sitter/__init__.py"
version-file = "src/codegen/sdk/__init__.py"

[metadata]
allow-direct-references = true
Expand Down Expand Up @@ -32,7 +32,7 @@ dependencies = [
]

[build.targets.wheel.hooks.cython.options]
src = "graph_sitter"
src = "codegen/sdk"
compile_args = [
"-O3",
{ platforms = [
Expand Down Expand Up @@ -71,7 +71,7 @@ macos-max-compat = false

[build]
packages = [
"src/graph_sitter",
"src/codegen/sdk",
"src/graph_visualization",
"src/gscli",
]
Expand Down
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ exclude = (?x)(
| scripts/.*
| .*/codemods/.*/test_.*/
| ^/expected/
| src/graph_sitter/skills/*
| src/codegen/sdk/skills/*
)
plugins = pydantic.mypy

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[project]
name = "graph-sitter"
name = "codegen-sdk"
dynamic = ["version", "urls"]
description = "Add your description here"
readme = "README.md"
Expand Down Expand Up @@ -62,7 +62,7 @@ classifiers = [

[project.scripts]
gs = "gscli.main:main"
run_string = "graph_sitter.core.main:main"
run_string = "codegen.sdk.core.main:main"
[project.optional-dependencies]
types = [
"types-networkx>=3.2.1.20240918",
Expand Down
6 changes: 3 additions & 3 deletions scripts/profiling/apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import networkx as nx
from tabulate import tabulate

from graph_sitter.codebase.factory.get_dev_customer_codebase import get_codebase_codegen
from graph_sitter.enums import ProgrammingLanguage
from codegen.sdk.codebase.factory.get_dev_customer_codebase import get_codebase_codegen
from codegen.sdk.enums import ProgrammingLanguage

logging.basicConfig(level=logging.INFO)
codegen = get_codebase_codegen("../codegen", ".")
Expand All @@ -21,7 +21,7 @@
if "test" not in file.filepath:
if file.ctx.repo_name == "codegen":
color = "yellow"
elif file.ctx.repo_name == "graph_sitter":
elif file.ctx.repo_name == "codegen-sdk":
color = "red"
if file.ctx.base_path == "codegen-git":
color = "green"
Expand Down
2 changes: 1 addition & 1 deletion src/graph_sitter/_proxy.py → src/codegen/sdk/_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from lazy_object_proxy.simple import make_proxy_method

try:
from graph_sitter.extensions.utils import cached_property
from codegen.sdk.extensions.utils import cached_property
except ModuleNotFoundError:
from functools import cached_property

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from openai import OpenAI
from tenacity import retry, stop_after_attempt, wait_random_exponential

from graph_sitter.ai.converters import convert_openai_messages_to_claude
from graph_sitter.utils import XMLUtils
from codegen.sdk.ai.converters import convert_openai_messages_to_claude
from codegen.sdk.utils import XMLUtils

CLAUDE_OPENAI_MODEL_MAP = {
"gpt-4o": "claude-3-5-sonnet-20240620",
Expand Down
16 changes: 16 additions & 0 deletions src/codegen/sdk/code_generation/codegen_sdk_codebase.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import os.path

from codegen.sdk.code_generation.current_code_codebase import get_codegen_codebase_base_path, get_current_code_codebase
from codegen.sdk.codebase.config import CodebaseConfig
from codegen.sdk.core.codebase import Codebase


def get_codegen_sdk_subdirectories() -> list[str]:
base = get_codegen_codebase_base_path()
return [os.path.join(base, "codegen/sdk"), os.path.join(base, "codemods")]


def get_codegen_sdk_codebase() -> Codebase:
"""Grabs a Codebase w/ GraphSitter content. Responsible for figuring out where it is, e.g. in Modal or local"""
codebase = get_current_code_codebase(CodebaseConfig(), subdirectories=get_codegen_sdk_subdirectories())
return codebase
Loading
Loading