repoman
High-level functionality for creating code datasets from source code repositories.
ManageConfig
dataclass
Configuration settings for managing a built local repository.
Source code in src/codablellm/repoman.py
build_error_handling = 'interactive'
class-attribute
instance-attribute
Specifies how to handle errors during the build process.
cleanup_command = None
class-attribute
instance-attribute
An optional CLI command to clean up the build artifacts of the repository.
cleanup_error_handling = 'ignore'
class-attribute
instance-attribute
Specifies how to handle errors during the cleanup process, if cleanup_command is provided.
run_from = 'repo'
class-attribute
instance-attribute
' Specifies the working directory from which to run build and clean commands.
repo: Use the root of the repository as the working directory. This may refer to the original repository path or a duplicated temporary copy depending on the generation mode.cwd: Use the current working directory at the time the command is run.
This option controls how relative paths within commands are resolved and can affect the behavior of tools that assume a specific project root.
show_progress = None
class-attribute
instance-attribute
Indicates whether to display a progress bar during both the build and cleanup processes.
build(command, error_handler=None, show_progress=None, cwd=None)
Builds a local repository using a specified CLI command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
Command
|
The CLI command to execute for building the repository. |
required |
error_handler
|
Optional[CommandErrorHandler]
|
Specifies how to handle errors during the build process. |
None
|
show_progress
|
Optional[bool]
|
Specifies whether to display a progress bar during the build process. |
None
|
cwd
|
Optional[PathLike]
|
The working directory to execute the build command in. |
None
|
Source code in src/codablellm/repoman.py
cleanup(command, error_handler=None, show_progress=None, cwd=None)
Cleans up build artifacts of a local repository using a specified CLI command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
Command
|
The CLI command to execute for cleaning up the repository. |
required |
error_handler
|
Optional[CommandErrorHandler]
|
Specifies how to handle errors during the cleanup process. |
None
|
show_progress
|
Optional[bool]
|
Specifies whether to display a progress bar during the cleanup process. |
None
|
cwd
|
Optional[PathLike]
|
The working directory to execute the build command in. |
None
|
Source code in src/codablellm/repoman.py
compile_dataset_task(path, bins, build_command, manage_config=ManageConfig(), extract_config=ExtractConfig(), dataset_config=DecompiledCodeDatasetConfig(), generation_mode='temp')
Builds a local repository and creates a DecompiledCodeDataset by decompiling the specified binaries.
This function automates the process of building a repository, decompiling its binaries, and generating a dataset of decompiled functions mapped to their potential source functions. It supports flexible configuration for repository management, source code extraction, and dataset generation.
Example
compile_dataset('path/to/my/repository',
[
'path/to/my/repository/bin1.exe',
'path/to/my/repository/bin2.exe'
],
'make',
manage_config=ManageConfig(
cleanup_command='make clean'
)
extract_config=ExtractConfig(
transform=remove_comments
),
dataset_config=DecompiledCodeDatasetConfig(
strip=True
),
generation_mode='path'
)
The above example creates a decompiled code dataset from
path/to/my/repository. It removes all comments from the extracted source
code functions using the specified transform (remove_comments), builds the repository
with make, decompiles, the binaries bin1.exe and bin2.exe, strips symbols after
decompilation, and finally cleans up the repository with make clean.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
PathLike
|
Path to the local repository to generate the dataset from. |
required |
bins
|
Collection[PathLike]
|
A sequence of paths to the built binaries of the repository that should be decompiled. |
required |
build_command
|
Command
|
The CLI command used to build the repository. |
required |
manage_config
|
ManageConfig
|
Configuration settings for managing the repository. |
ManageConfig()
|
extract_config
|
ExtractConfig
|
Configuration settings for extracting source code functions. |
ExtractConfig()
|
dataset_config
|
DecompiledCodeDatasetConfig
|
Configuration settings for generating the decompiled code dataset. |
DecompiledCodeDatasetConfig()
|
generation_mode
|
DatasetGenerationMode
|
Specifies the mode for generating the dataset. |
'temp'
|
Returns:
| Type | Description |
|---|---|
DecompiledCodeDataset
|
The generated dataset containing mappings of decompiled functions to their potential source code functions. |
Source code in src/codablellm/repoman.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |
manage(build_command, path, config=ManageConfig())
Builds a local repository and optionally cleans up the build artifacts using a context manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
build_command
|
Command
|
The CLI command used to build the repository. |
required |
path
|
PathLike
|
Path to the local repository to manage. |
required |
config
|
ManageConfig
|
Configuration settings for managing the repository. |
ManageConfig()
|
Returns:
| Type | Description |
|---|---|
None
|
A context manager that builds the repository upon entering and optionally cleans up build artifacts upon exiting, based on the provided configuration. |