Skip to content

Commit cd4c3f7

Browse files
committed
fixes
1 parent 199ed45 commit cd4c3f7

3 files changed

Lines changed: 35 additions & 34 deletions

File tree

.github/workflows/system.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ jobs:
3232
env:
3333
GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}
3434
run: |
35-
uv run commit0 save simpy test-save-commit0
35+
uv run commit0 save simpy test-save-commit0 master

commit0/__main__.py

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,21 @@ def main() -> None:
4646
config.base_dir = os.path.abspath(config.base_dir)
4747

4848
if command == "clone":
49+
if len(sys.argv) != 3:
50+
raise ValueError(
51+
"You provided an incorrect number of arguments.\nUsage: commit0 clone {repo_split}"
52+
)
4953
commit0.harness.setup.main(
5054
config.dataset_name,
5155
config.dataset_split,
5256
config.repo_split,
5357
config.base_dir,
5458
)
5559
elif command == "build":
60+
if len(sys.argv) != 3:
61+
raise ValueError(
62+
"You provided an incorrect number of arguments.\nUsage: commit0 build {repo_split}"
63+
)
5664
commit0.harness.build.main(
5765
config.dataset_name,
5866
config.dataset_split,
@@ -61,30 +69,26 @@ def main() -> None:
6169
config.backend,
6270
)
6371
elif command == "get-tests":
72+
if len(sys.argv) != 3:
73+
raise ValueError(
74+
"You provided an incorrect number of arguments.\nUsage: commit0 get-tests {repo_name}"
75+
)
6476
repo = sys.argv[2]
6577
commit0.harness.get_pytest_ids.main(repo, stdout=True)
6678
elif command == "test" or command == "test-reference":
6779
# this command assume execution in arbitrary working directory
6880
repo_or_repo_path = sys.argv[2]
6981
if command == "test-reference":
70-
if len(sys.argv) < 4:
82+
if len(sys.argv) != 4:
7183
raise ValueError(
72-
"An argument is missing for commit0 test-reference.\nUsage: commit0 test-reference {repo_dir} {test_ids}"
73-
)
74-
elif len(sys.argv) > 4:
75-
raise ValueError(
76-
"Too many arguments are passed to commit0 test-reference.\nUsage: commit0 test-reference {repo_dir} {test_ids}"
84+
"You provided an incorrect number of arguments.\nUsage: commit0 test-reference {repo_dir} {test_ids}"
7785
)
7886
branch = "reference"
7987
test_ids = sys.argv[3]
8088
else:
81-
if len(sys.argv) < 5:
82-
raise ValueError(
83-
"An argument is missing for commit0 test.\nUsage: commit0 test {repo_dir} {branch} {test_ids}"
84-
)
85-
elif len(sys.argv) > 5:
89+
if len(sys.argv) != 5:
8690
raise ValueError(
87-
"Too many arguments are passed to commit0 test.\nUsage: commit0 test {repo_dir} {branch} {test_ids}"
91+
"You provided an incorrect number of arguments.\nUsage: commit0 test {repo_dir} {branch} {test_ids}"
8892
)
8993
branch = sys.argv[3]
9094
test_ids = sys.argv[4]
@@ -104,23 +108,15 @@ def main() -> None:
104108
)
105109
elif command == "evaluate" or command == "evaluate-reference":
106110
if command == "evaluate-reference":
107-
if len(sys.argv) < 3:
108-
raise ValueError(
109-
"An argument is missing for commit0 evaluate-reference.\nUsage: commit0 evaluate-reference {repo_split}"
110-
)
111-
elif len(sys.argv) > 3:
111+
if len(sys.argv) != 3:
112112
raise ValueError(
113-
"Too many arguments are passed to commit0 evaluate-reference.\nUsage: commit0 evaluate-reference {repo_split}"
113+
"You provided an incorrect number of arguments.\nUsage: commit0 evaluate-reference {repo_split}"
114114
)
115115
branch = "reference"
116116
else:
117-
if len(sys.argv) < 4:
117+
if len(sys.argv) != 4:
118118
raise ValueError(
119-
"An argument is missing for commit0 evaluate.\nUsage: commit0 evaluate {repo_split} {branch}"
120-
)
121-
elif len(sys.argv) > 4:
122-
raise ValueError(
123-
"Too many arguments are passed to commit0 evaluate.\nUsage: commit0 evaluate {repo_split} {branch}"
119+
"You provided an incorrect number of arguments.\nUsage: commit0 evaluate {repo_split} {branch}"
124120
)
125121
branch = sys.argv[3]
126122
if branch.startswith("branch="):
@@ -137,14 +133,21 @@ def main() -> None:
137133
config.num_workers,
138134
)
139135
elif command == "save":
140-
organization = sys.argv[3]
136+
if len(sys.argv) != 5:
137+
raise ValueError(
138+
"You provided an incorrect number of arguments.\nUsage: commit0 save {repo_split} {owner} {branch}"
139+
)
140+
owner = sys.argv[3]
141+
branch = sys.argv[4]
142+
if branch.startswith("branch="):
143+
branch = branch[len("branch=") :]
141144
commit0.harness.save.main(
142145
config.dataset_name,
143146
config.dataset_split,
144147
config.repo_split,
145148
config.base_dir,
146-
organization,
147-
config.branch,
149+
owner,
150+
branch,
148151
config.github_token,
149152
)
150153

commit0/harness/save.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def main(
2020
dataset_split: str,
2121
repo_split: str,
2222
base_dir: str,
23-
organization: str,
23+
owner: str,
2424
branch: str,
2525
github_token: str,
2626
) -> None:
@@ -33,7 +33,7 @@ def main(
3333
if repo_split != "all" and repo_name not in SPLIT[repo_split]:
3434
continue
3535
local_repo_path = f"{base_dir}/{repo_name}"
36-
github_repo_url = f"https://github.com/{organization}/{repo_name}.git"
36+
github_repo_url = f"https://github.com/{owner}/{repo_name}.git"
3737
github_repo_url = github_repo_url.replace(
3838
"https://", f"https://x-access-token:{github_token}@"
3939
)
@@ -46,7 +46,7 @@ def main(
4646

4747
# create Github repo
4848
create_repo_on_github(
49-
organization=organization, repo=repo_name, logger=logger, token=github_token
49+
organization=owner, repo=repo_name, logger=logger, token=github_token
5050
)
5151
# Add your remote repository URL
5252
remote_name = "progress-tracker"
@@ -75,9 +75,7 @@ def main(
7575
origin.push(refspec=f"{branch}:{branch}")
7676
logger.info(f"Pushed to {github_repo_url} on branch {branch}")
7777
except Exception as e:
78-
raise Exception(
79-
f"Push {branch} to {organization}/{repo_name} fails.\n{str(e)}"
80-
)
78+
raise Exception(f"Push {branch} to {owner}/{repo_name} fails.\n{str(e)}")
8179

8280

8381
__all__ = []

0 commit comments

Comments
 (0)