-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from commit-0/types
Change main structure / fix most of the lints
- Loading branch information
Showing
13 changed files
with
252 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: pre-commit | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
pre-commit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v3 | ||
- uses: pre-commit/action@v3.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,3 @@ | ||
__version__ = "0.0.1" | ||
|
||
|
||
from commit0.harness.docker_build import ( | ||
build_image, | ||
build_base_images, | ||
build_repo_images, | ||
close_logger, | ||
setup_logger, | ||
) | ||
"""Commit0 Lib""" | ||
|
||
from commit0.harness.docker_utils import ( | ||
cleanup_container, | ||
copy_to_container, | ||
copy_from_container, | ||
delete_file_from_container, | ||
exec_run_with_timeout, | ||
write_to_container, | ||
create_container, | ||
) | ||
|
||
from commit0.harness.utils import ( | ||
extract_test_output, | ||
) | ||
|
||
__all__ = [ | ||
"build_image", | ||
"build_base_images", | ||
"build_repo_images", | ||
"close_logger", | ||
"setup_logger", | ||
"cleanup_container", | ||
"copy_to_container", | ||
"copy_from_container", | ||
"delete_file_from_container", | ||
"exec_run_with_timeout", | ||
"write_to_container", | ||
"create_container", | ||
"extract_test_output", | ||
] | ||
__version__ = "0.0.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import argparse | ||
import commit0.harness.run_pytest_ids | ||
import commit0.harness.build | ||
import commit0.harness.setup | ||
|
||
|
||
def main() -> None: | ||
parser = argparse.ArgumentParser(description="Commit0 version control system") | ||
subparsers = parser.add_subparsers(dest="command", help="Available commands") | ||
|
||
commit0.harness.setup.add_init_args(subparsers.add_parser("clone")) | ||
commit0.harness.build.add_init_args(subparsers.add_parser("build")) | ||
commit0.harness.run_pytest_ids.add_init_args(subparsers.add_parser("test")) | ||
|
||
args = parser.parse_args() | ||
|
||
if args.command == "clone": | ||
commit0.harness.setup.run(args) | ||
elif args.command == "build": | ||
commit0.harness.build.run(args) | ||
elif args.command == "test": | ||
commit0.harness.run_pytest_ids.run(args) | ||
else: | ||
parser.print_help() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() | ||
|
||
__all__ = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import argparse | ||
import logging | ||
|
||
import docker | ||
from datasets import load_dataset | ||
from typing import Iterator | ||
from commit0.harness.docker_build import build_repo_images | ||
from commit0.harness.spec import make_spec | ||
|
||
logging.basicConfig( | ||
level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s" | ||
) | ||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def main( | ||
hf_name: str, | ||
base_dir: str, | ||
config_file: str, | ||
) -> None: | ||
dataset: Iterator[RepoInstance] = load_dataset(hf_name, split="test") | ||
specs = [] | ||
for example in dataset: | ||
spec = make_spec(example) | ||
specs.append(spec) | ||
|
||
client = docker.from_env() | ||
build_repo_images(client, specs) | ||
logger.info("Done building docker images") | ||
|
||
|
||
def add_init_args(parser: argparse.ArgumentParser) -> None: | ||
parser.add_argument( | ||
"--hf_name", | ||
type=str, | ||
help="HF dataset name", | ||
default="wentingzhao/commit0_docstring", | ||
) | ||
parser.add_argument( | ||
"--base_dir", | ||
type=str, | ||
default="repos/", | ||
help="base directory to write repos to", | ||
) | ||
parser.add_argument( | ||
"--config_file", | ||
type=str, | ||
default="config.yml", | ||
help="where to write config file to", | ||
) | ||
parser.set_defaults(func=run) | ||
|
||
|
||
def run(args: argparse.Namespace) -> None: | ||
main( | ||
hf_name=args.hf_name, | ||
base_dir=args.base_dir, | ||
config_file=args.config_file, | ||
) | ||
|
||
|
||
__all__ = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.