Skip to content

Development version of codellm-devkit #1

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 2 commits into from
Jul 24, 2024
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
26 changes: 26 additions & 0 deletions CONTRIBUTE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Contributing to Codellm-DevKit

You can report issues or open a pull request (PR) to suggest changes.

## Reporting an issue

To report an issue, or to suggest an idea for a change that you haven't
had time to write-up yet:
1. [Review existing issues](https://github.com/IBM/codellm-devkit/issues) to see if a similar issue has been opened or discussed.
2. [Open an
issue](https://github.com/IBM/codellm-devkit/issues/new). Be sure to include any helpful information, such as your Kubernetes environment details, error messages, or logs that you might have.


## Suggesting a change

To suggest a change to this repository, [submit a pull request](https://github.com/IBM/codellm-devkit/pulls) with the complete set of changes that you want to suggest. Before creating a PR, make sure that your changes pass all of the tests.

The test suite can be executed with the following command in the top-level folder:
```
pytest
```

Also, please make sure that your changes pass static checks such as code styles by executing the following command:
```
pre-commit run --all-files
```
71 changes: 68 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,69 @@
# CodeLLM-devkit: A Python library for seamless interaction with CodeLLMs
# CodeLLM-Devkit: A Python library for seamless interaction with CodeLLMs

![image](cldk.png)
codellm-devkit provides unified language to get off-the-shelf static analysis for multiple programming languages and support for applying those analyses for code LLM use cases.
![image](./docs/assets/cldk.png)
[![Python 3.11](https://img.shields.io/badge/python-3.11-blue.svg)](https://www.python.org/downloads/release/python-3110/)

## Prerequisites

- Python 3.11+
- Poetry (see [doc](https://python-poetry.org/docs/))

## Installation

Obtain Codellm-DevKit from below:

```bash
git clone git@github.com:IBM/codellm-devkit.git /path/to/cloned/repo
```

Install CodeLLM-Devkit

```bash
pip install -U /path/to/cloned/repo
```

## Usage

### 1. Obtain sample application to experiment with (we'll use Daytrader 8 as an example)

```bash
wget https://github.com/OpenLiberty/sample.daytrader8/archive/refs/tags/v1.2.tar.gz
```

Extract the archive and navigate to the `daytrader8` directory:

```bash
tar -xvf v1.2.tar.gz
tar -xvf v1.2.tar.gz
```

Save the location to where daytrader8 is extracted to, as we will need it later:

```bash
export DAYTRADER8_DIR=/path/to/sample.daytrader8-1.2
```

Then you can use the following command to run the codeanalyzer:

```python
import os
from rich import print # Optional, for pretty printing.
from cldk import CLDK
from cldk.models.java.models import *

# Initialize the Codellm-DevKit object with the project directory, language, and backend.
ns = CLDK(
project_dir=os.getenv("DAYTRADER8_DIR"), # Change this to the path of the project you want to analyze.
language="java", # The language of the project.
backend="codeanalyzer", # The backend to use for the analysis.
analysis_db="/tmp", # A temporary directory to store the analysis results.
sdg=True, # Generate the System Dependence Graph (SDG) for the project.
)

# Get the java application view for the project. The application view is a representation of the project as a graph with all the classes, methods, and fields.
app: JApplication = ns.preprocessing.get_application_view()

# Get all the classes in the project.
classes_dict = ns.preprocessing.get_all_classes()
print(classes_dict)
```
3 changes: 3 additions & 0 deletions cldk/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .core import CLDK

__all__ = ["CLDK"]
7 changes: 7 additions & 0 deletions cldk/analysis/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

from .call_graph import CallGraph
from .program_dependence_graph import ProgramDependenceGraph
from .system_dependence_graph import SystemDependenceGraph
from .symbol_table import SymbolTable

__all__ = ["CallGraph", "ProgramDependenceGraph", "SystemDependenceGraph", "SymbolTable"]
Empty file added cldk/analysis/c/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions cldk/analysis/c/treesitter/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from cldk.analysis.c.treesitter.c_sitter import CSitter

__all__ = ["CSitter"]
Loading