Skip to content

Commit f820ade

Browse files
experimental changes
1 parent 2a576cb commit f820ade

File tree

6 files changed

+14
-13
lines changed

6 files changed

+14
-13
lines changed

codeflash/cli_cmds/cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ def process_pyproject_config(args: Namespace) -> Namespace:
155155
"disable_telemetry",
156156
"disable_imports_sorting",
157157
"git_remote",
158+
"exp_git_remote",
158159
"override_fixtures",
159160
]
160161
for key in supported_keys:
@@ -234,7 +235,7 @@ def handle_optimize_all_arg_parsing(args: Namespace) -> Namespace:
234235
"I need a git repository to run --all and open PRs for optimizations. Exiting..."
235236
)
236237
apologize_and_exit()
237-
if not args.no_pr and not check_and_push_branch(git_repo):
238+
if not args.no_pr and not check_and_push_branch(git_repo, git_remote=args.git_remote):
238239
exit_with_message("Branch is not pushed...", error_on_exit=True)
239240
owner, repo = get_repo_owner_and_name(git_repo)
240241
if not args.no_pr:

codeflash/code_utils/config_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def parse_config_file(
7070
# default values:
7171
path_keys = ["module-root", "tests-root", "benchmarks-root"]
7272
path_list_keys = ["ignore-paths"]
73-
str_keys = {"pytest-cmd": "pytest", "git-remote": "origin"}
73+
str_keys = {"pytest-cmd": "pytest", "git-remote": "origin", "exp-git-remote": "exp-origin"}
7474
bool_keys = {
7575
"override-fixtures": False,
7676
"disable-telemetry": False,

codeflash/code_utils/git_utils.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,12 @@ def confirm_proceeding_with_no_git_repo() -> str | bool:
117117
return True
118118

119119

120-
def check_and_push_branch(repo: git.Repo, wait_for_push: bool = False) -> bool: # noqa: FBT001, FBT002
120+
def check_and_push_branch(repo: git.Repo, git_remote: str, wait_for_push: bool = False) -> bool: # noqa: FBT001, FBT002
121121
current_branch = repo.active_branch.name
122-
origin = repo.remote(name="origin")
122+
remote = repo.remote(name=git_remote)
123123

124124
# Check if the branch is pushed
125-
if f"origin/{current_branch}" not in repo.refs:
125+
if f"{git_remote}/{current_branch}" not in repo.refs:
126126
logger.warning(f"⚠️ The branch '{current_branch}' is not pushed to the remote repository.")
127127
if not sys.__stdin__.isatty():
128128
logger.warning("Non-interactive shell detected. Branch will not be pushed.")
@@ -132,13 +132,13 @@ def check_and_push_branch(repo: git.Repo, wait_for_push: bool = False) -> bool:
132132
f"the branch '{current_branch}' to the remote repository?",
133133
default=False,
134134
):
135-
origin.push(current_branch)
136-
logger.info(f"⬆️ Branch '{current_branch}' has been pushed to origin.")
135+
remote.push(current_branch)
136+
logger.info(f"⬆️ Branch '{current_branch}' has been pushed to {git_remote}.")
137137
if wait_for_push:
138138
time.sleep(3) # adding this to give time for the push to register with GitHub,
139139
# so that our modifications to it are not rejected
140140
return True
141-
logger.info(f"🔘 Branch '{current_branch}' has not been pushed to origin.")
141+
logger.info(f"🔘 Branch '{current_branch}' has not been pushed to {git_remote}.")
142142
return False
143143
logger.debug(f"The branch '{current_branch}' is present in the remote repository.")
144144
return True

codeflash/optimization/function_optimizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ def find_and_process_best_optimization(
10411041
if self.experiment_id
10421042
else self.function_trace_id,
10431043
coverage_message=coverage_message,
1044-
git_remote=self.args.git_remote,
1044+
git_remote=self.args.git_remote if exp_type == "EXP0" else self.args.exp_git_remote,
10451045
)
10461046
if (
10471047
self.args.all

codeflash/result/create_pr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def check_create_pr(
185185
owner, repo = get_repo_owner_and_name(git_repo, git_remote)
186186
logger.info(f"Pushing to {git_remote} - Owner: {owner}, Repo: {repo}")
187187
console.rule()
188-
if not check_and_push_branch(git_repo, wait_for_push=True):
188+
if not check_and_push_branch(git_repo, git_remote, wait_for_push=True):
189189
logger.warning("⏭️ Branch is not pushed, skipping PR creation...")
190190
return
191191
relative_path = explanation.file_path.relative_to(git_root_dir()).as_posix()

tests/test_git_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ def test_check_and_push_branch(self, mock_confirm, mock_isatty, mock_repo):
7373
mock_origin = mock_repo_instance.remote.return_value
7474
mock_origin.push.return_value = None
7575

76-
assert check_and_push_branch(mock_repo_instance)
76+
assert check_and_push_branch(mock_repo_instance, git_remote="origin")
7777
mock_origin.push.assert_called_once_with("test-branch")
7878
mock_origin.push.reset_mock()
7979

8080
# Test when branch is already pushed
8181
mock_repo_instance.refs = [f"origin/{mock_repo_instance.active_branch.name}"]
82-
assert check_and_push_branch(mock_repo_instance)
82+
assert check_and_push_branch(mock_repo_instance, git_remote="origin")
8383
mock_origin.push.assert_not_called()
8484
mock_origin.push.reset_mock()
8585

@@ -93,7 +93,7 @@ def test_check_and_push_branch_non_tty(self, mock_isatty, mock_repo):
9393
mock_origin = mock_repo_instance.remote.return_value
9494
mock_origin.push.return_value = None
9595

96-
assert not check_and_push_branch(mock_repo_instance)
96+
assert not check_and_push_branch(mock_repo_instance, git_remote="origin")
9797
mock_origin.push.assert_not_called()
9898
mock_origin.push.reset_mock()
9999

0 commit comments

Comments
 (0)