Skip to content

Commit 0b4643d

Browse files
authored
Add GitHub repository seed reader plugin (#4)
1 parent 49e4928 commit 0b4643d

18 files changed

Lines changed: 1381 additions & 1 deletion

File tree

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
/.github/ @NVIDIA-NeMo/data_designer_reviewers
88

99
# Plugins
10+
/plugins/data-designer-github/ @NVIDIA-NeMo/data_designer_reviewers @eric-tramel
1011
/plugins/data-designer-retrieval-sdg/ @NVIDIA-NeMo/data_designer_reviewers @shan-nvidia @oliverholworthy
1112
/plugins/data-designer-template/ @NVIDIA-NeMo/data_designer_reviewers

catalog/plugins.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,38 @@
11
{
22
"schema_version": 2,
33
"packages": [
4+
{
5+
"name": "data-designer-github",
6+
"description": "GitHub and local git repository seed reader for Data Designer",
7+
"install": {
8+
"requirement": "data-designer-github",
9+
"index_url": "https://nvidia-nemo.github.io/DataDesignerPlugins/simple/"
10+
},
11+
"compatibility": {
12+
"python": {
13+
"specifier": ">=3.10"
14+
},
15+
"data_designer": {
16+
"requirement": "data-designer>=0.5.7",
17+
"specifier": ">=0.5.7",
18+
"marker": null
19+
}
20+
},
21+
"docs": {
22+
"url": "https://nvidia-nemo.github.io/DataDesignerPlugins/plugins/data-designer-github/"
23+
},
24+
"plugins": [
25+
{
26+
"name": "github",
27+
"plugin_type": "seed-reader",
28+
"entry_point": {
29+
"group": "data_designer.plugins",
30+
"name": "github",
31+
"value": "data_designer_github.plugin:plugin"
32+
}
33+
}
34+
]
35+
},
436
{
537
"name": "data-designer-retrieval-sdg",
638
"description": "Retriever SDG toolkit: registers the embedding-dedup column generator and document-chunker seed reader, plus a multi-step QA generation pipeline, CLI, and Automodel-compatible data conversion",
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# data-designer-github
2+
3+
`data-designer-github` is a Data Designer seed reader for repository files. It
4+
turns GitHub repositories or local git repositories into seed rows that carry
5+
file content, path metadata, repository provenance, and commit identifiers.
6+
7+
Use it when a workflow needs code repository data as the starting point for
8+
generation, review, transformation, or indexing tasks. The reader is intentionally
9+
file-oriented: each matching text file becomes one seed row, and downstream Data
10+
Designer columns decide how to summarize, critique, rewrite, label, or enrich
11+
that row.
12+
13+
## Installation
14+
15+
```bash
16+
uv add data-designer data-designer-github
17+
```
18+
19+
The plugin is discovered through the `data_designer.plugins` entry point once it
20+
is installed in the same environment as Data Designer.
21+
22+
## Seed source
23+
24+
Use the `github` seed source when the seed dataset should come from one or more
25+
repositories.
26+
27+
| Field | Required | Description |
28+
| --- | --- | --- |
29+
| `path` | No | A local git repository path, or a directory whose immediate children are git repositories. |
30+
| `repositories` | No | GitHub repositories to clone. Entries may be `owner/name`, `https://github.com/owner/name`, or `https://github.com/owner/name.git`. |
31+
| `repository_paths` | No | Additional explicit local git repository paths to read. |
32+
| `ref` | No | Branch, tag, or commit to check out for cloned GitHub repositories. |
33+
| `clone_depth` | No | Shallow clone depth for GitHub repositories. Defaults to `1`; set to `None` for a full clone. |
34+
| `clone_timeout_seconds` | No | Timeout for each clone or checkout operation. Defaults to `300`. |
35+
| `file_pattern` | No | Inherited file glob from Data Designer's filesystem seed source. For example, `*.py`. |
36+
| `recursive` | No | Whether `file_pattern` is applied recursively. |
37+
| `include_extensions` | No | File extensions to include after the glob match. Defaults to common code and documentation extensions. Set to `None` to allow every extension. |
38+
| `include_file_names` | No | Extensionless file names to include, such as `Dockerfile` and `Makefile`. |
39+
| `exclude_patterns` | No | Relative path glob patterns to skip, including `.git`, cache, build, virtualenv, and dependency directories by default. |
40+
| `max_file_size_bytes` | No | Maximum file size to hydrate into `content`. Defaults to `1_000_000`. |
41+
| `encoding` | No | Text encoding used when reading file contents. Defaults to `utf-8`. |
42+
43+
At least one of `path`, `repositories`, or `repository_paths` is required.
44+
45+
## Output columns
46+
47+
| Column | Description |
48+
| --- | --- |
49+
| `repo_id` | Repository identifier. GitHub repositories use `owner/name`; local repositories use their GitHub remote when available, otherwise the directory name. |
50+
| `repo_url` | Remote origin URL when available. |
51+
| `commit_sha` | Checked-out commit SHA for the repository. |
52+
| `source_kind` | `github` for cloned repositories, or `git_repository` for local repositories. |
53+
| `repository_path` | Local path used by the reader. GitHub repositories are cloned into a temporary runtime directory. |
54+
| `source_path` | Absolute path to the file that produced the seed row. |
55+
| `relative_path` | File path relative to the repository root. |
56+
| `file_name` | Basename of the file. |
57+
| `file_extension` | Lowercase file extension. |
58+
| `code_lang` | Language hint inferred from the file name or extension. |
59+
| `size_bytes` | File size at manifest time. |
60+
| `content_sha256` | SHA-256 hash of the hydrated file bytes. |
61+
| `content` | Decoded text content. |
62+
63+
## Behavior
64+
65+
When the reader is attached, it resolves local repository roots, clones any
66+
configured GitHub repositories, records the checked-out commit, and builds a
67+
manifest of matching files. File content is read during row hydration, so Data
68+
Designer can batch and sample repository content using the same seed reader
69+
interfaces as other filesystem-backed datasets.
70+
71+
The plugin reads repository files only. It does not parse code into functions,
72+
classes, symbols, dependency graphs, or AST nodes. If a workflow needs those
73+
structures, use this reader to collect stable file-level inputs and add
74+
downstream columns that perform the language-specific analysis.
75+
76+
The plugin shells out to `git` for repository operations and does not manage
77+
GitHub API tokens. Public repositories work directly. Private repositories
78+
require the execution environment's git credential configuration to already have
79+
access.
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
# Usage
2+
3+
This tutorial walks through the common patterns for turning repositories into
4+
Data Designer seed rows. The examples use the Python builder API, but the same
5+
configuration fields apply when a workflow is built from serialized config.
6+
7+
## Read a GitHub repository
8+
9+
Start with a small repository and a narrow file pattern. This keeps previews
10+
fast and makes it clear which rows are entering the workflow.
11+
12+
```python
13+
from data_designer.config.config_builder import DataDesignerConfigBuilder
14+
from data_designer.interface.data_designer import DataDesigner
15+
from data_designer_github.config import GitHubSeedSource
16+
17+
builder = DataDesignerConfigBuilder()
18+
builder.with_seed_dataset(
19+
GitHubSeedSource(
20+
repositories=["pallets/markupsafe"],
21+
file_pattern="*.py",
22+
recursive=True,
23+
)
24+
)
25+
26+
builder.add_column(
27+
name="_row_id",
28+
column_type="sampler",
29+
sampler_type="uuid",
30+
params={},
31+
)
32+
33+
preview = DataDesigner().preview(builder, num_records=5)
34+
print(preview.dataset[["repo_id", "relative_path", "code_lang", "content"]])
35+
```
36+
37+
The seed rows contain repository provenance and file text. Downstream columns can
38+
then ask questions such as "summarize this file", "identify risky APIs", "write
39+
a short module description", or "extract candidate test scenarios" using the
40+
`content`, `relative_path`, `code_lang`, and `commit_sha` columns.
41+
42+
## Pin a branch, tag, or commit
43+
44+
Use `ref` when the dataset must be reproducible against a specific branch, tag,
45+
or commit. Branches and tags are passed to `git clone --branch`; commit SHAs are
46+
checked out after cloning.
47+
48+
```python
49+
source = GitHubSeedSource(
50+
repositories=["NVIDIA-NeMo/DataDesigner"],
51+
ref="v0.5.7",
52+
clone_depth=1,
53+
file_pattern="*.py",
54+
recursive=True,
55+
)
56+
```
57+
58+
For arbitrary commit SHAs, set `clone_depth=None` if the commit may not be
59+
reachable from the shallow default clone.
60+
61+
```python
62+
source = GitHubSeedSource(
63+
repositories=["NVIDIA-NeMo/DataDesigner"],
64+
ref="0123456789abcdef0123456789abcdef01234567",
65+
clone_depth=None,
66+
file_pattern="*.py",
67+
recursive=True,
68+
)
69+
```
70+
71+
## Read local repositories
72+
73+
Local repositories are useful for private code, local experiments, or a checked
74+
out monorepo that already exists on disk.
75+
76+
```python
77+
source = GitHubSeedSource(
78+
repository_paths=[
79+
"/workspace/services/api",
80+
"/workspace/libraries/shared",
81+
],
82+
file_pattern="*.py",
83+
recursive=True,
84+
)
85+
```
86+
87+
If `path` points at a git repository, that repository is read. If `path` points
88+
at a directory whose immediate children are git repositories, each child
89+
repository is discovered and read.
90+
91+
```python
92+
source = GitHubSeedSource(
93+
path="/workspace/repos",
94+
file_pattern="*.ts",
95+
recursive=True,
96+
)
97+
```
98+
99+
## Control which files become rows
100+
101+
The reader first applies `file_pattern` and `recursive`, then filters by
102+
extension, file name, exclude pattern, and file size.
103+
104+
```python
105+
source = GitHubSeedSource(
106+
repositories=["NVIDIA-NeMo/DataDesigner"],
107+
file_pattern="*",
108+
recursive=True,
109+
include_extensions=["py", "toml", "md"],
110+
include_file_names=["Dockerfile", "Makefile"],
111+
exclude_patterns=[
112+
".git/**",
113+
"**/__pycache__/**",
114+
"**/build/**",
115+
"**/dist/**",
116+
"docs/generated/**",
117+
],
118+
max_file_size_bytes=250_000,
119+
)
120+
```
121+
122+
Use `include_extensions=None` for broad repository inventory tasks where the
123+
glob and exclude patterns should decide the candidate set.
124+
125+
```python
126+
source = GitHubSeedSource(
127+
repositories=["owner/repo"],
128+
file_pattern="LICENSE*",
129+
recursive=False,
130+
include_extensions=None,
131+
)
132+
```
133+
134+
## Typical workflows
135+
136+
`data-designer-github` works best as the seed layer for file-level code
137+
workflows:
138+
139+
- Repository QA: score files for risky dependencies, missing license headers, or
140+
stale implementation notes.
141+
- Documentation generation: turn source files into module summaries, migration
142+
notes, or API reference drafts.
143+
- Test ideation: derive test scenarios from implementation files and route them
144+
to a code-generation column.
145+
- Code search preparation: create embeddings or labels from stable file content
146+
and repository metadata.
147+
- Dataset construction: sample representative code files from several projects
148+
while preserving `repo_id`, `relative_path`, and `commit_sha` provenance.
149+
150+
Because the reader emits full file content, prompts should account for file
151+
length and language. A common pattern is to filter or sample seed rows first,
152+
then generate focused columns that reference only the metadata and content each
153+
task needs.
154+
155+
## Operational notes
156+
157+
The plugin requires `git` on `PATH`. GitHub repositories are cloned into a
158+
temporary runtime directory for the reader attachment and local repositories are
159+
read in place. Files that exceed `max_file_size_bytes` are skipped before
160+
hydration. Files that cannot be decoded with `encoding` are skipped with a
161+
warning rather than producing partial text.
162+
163+
The reader does not call the GitHub API, manage credentials, or expand GitHub
164+
issues and pull requests. It is scoped to repository file content so workflows
165+
can compose repository-aware seed data with the rest of Data Designer.

docs/plugins/index.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@
55
Browse available Data Designer plugins by what they add to your data generation workflow.
66

77
<div class="plugin-doc-grid">
8+
<a class="plugin-doc-card" href="data-designer-github/" aria-label="Open data-designer-github documentation">
9+
<span class="plugin-doc-card__header">
10+
<span class="plugin-doc-card__title">data-designer-github</span>
11+
<span class="plugin-doc-card__version">v0.1.0</span>
12+
</span>
13+
<span class="plugin-doc-card__description">GitHub and local git repository seed reader for Data Designer</span>
14+
<span class="plugin-doc-card__section">
15+
<span class="plugin-doc-card__label">Entry points</span>
16+
<span class="plugin-doc-card__chips"><span class="plugin-doc-chip">github</span></span>
17+
</span>
18+
</a>
819
<a class="plugin-doc-card" href="data-designer-retrieval-sdg/" aria-label="Open data-designer-retrieval-sdg documentation">
920
<span class="plugin-doc-card__header">
1021
<span class="plugin-doc-card__title">data-designer-retrieval-sdg</span>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Owner(s) of this plugin — used to generate the root CODEOWNERS file.
2+
# GitHub accepts @username, @org/team, or email format.
3+
* @NVIDIA-NeMo/data_designer_reviewers @eric-tramel
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# data-designer-github
2+
3+
GitHub and local git repository seed reader for
4+
[NeMo Data Designer](https://github.com/NVIDIA-NeMo/DataDesigner).
5+
6+
## Installation
7+
8+
```bash
9+
pip install data-designer-github
10+
```
11+
12+
## Usage
13+
14+
This plugin provides a `github` seed source. Once installed, the seed reader is
15+
automatically discovered by Data Designer.
16+
17+
```python
18+
from data_designer.config.config_builder import DataDesignerConfigBuilder
19+
from data_designer.interface.data_designer import DataDesigner
20+
from data_designer_github.config import GitHubSeedSource
21+
22+
builder = DataDesignerConfigBuilder()
23+
builder.with_seed_dataset(
24+
GitHubSeedSource(
25+
repositories=["NVIDIA-NeMo/DataDesigner"],
26+
file_pattern="*.py",
27+
recursive=True,
28+
)
29+
)
30+
31+
preview = DataDesigner().preview(builder, num_records=5)
32+
print(preview.dataset[["repo_id", "relative_path", "code_lang", "content"]])
33+
```
34+
35+
The reader can also scan local git repositories:
36+
37+
```python
38+
builder.with_seed_dataset(
39+
GitHubSeedSource(
40+
path="/path/to/repos",
41+
repository_paths=["/path/to/one/repo"],
42+
file_pattern="*.py",
43+
)
44+
)
45+
```
46+
47+
Seed columns include repository metadata, file paths, language hints, file
48+
content, and content SHA-256 hashes.
49+
50+
For the full plugin authoring guide, see the
51+
[main repository docs](https://github.com/NVIDIA-NeMo/DataDesignerPlugins/blob/main/docs/adding-a-plugin.md).

0 commit comments

Comments
 (0)