Skip to content

Commit e734fdc

Browse files
committed
fix rebasing, fix running locally
1 parent 32737f7 commit e734fdc

File tree

2 files changed

+18
-40
lines changed

2 files changed

+18
-40
lines changed

conda_forge_tick/auto_tick.py

Lines changed: 16 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,12 @@
2929
from conda_forge_tick.feedstock_parser import BOOTSTRAP_MAPPINGS
3030
from conda_forge_tick.git_utils import (
3131
DryRunBackend,
32-
DuplicatePullRequestError,
3332
GitCli,
3433
GitCliError,
3534
GitPlatformBackend,
3635
RepositoryNotFoundError,
3736
github_backend,
38-
is_github_api_limit_reached,
37+
is_github_api_limit_reached, DuplicatePullRequestError,
3938
)
4039
from conda_forge_tick.lazy_json_backends import (
4140
LazyJson,
@@ -49,8 +48,7 @@
4948
PR_LIMIT,
5049
load_migrators,
5150
)
52-
from conda_forge_tick.migration_runner import run_migration
53-
from conda_forge_tick.migrators import MigrationYaml, Migrator, Version
51+
from conda_forge_tick.migrators import Migrator, Version, MigrationYaml
5452
from conda_forge_tick.migrators.version import VersionMigrationError
5553
from conda_forge_tick.os_utils import eval_cmd
5654
from conda_forge_tick.rerender_feedstock import rerender_feedstock
@@ -68,6 +66,7 @@
6866
load_existing_graph,
6967
sanitize_string,
7068
)
69+
from .migration_runner import run_migration
7170

7271
from .migrators_types import MigrationUidTypedDict
7372
from .models.pr_info import PullRequestInfoSpecial
@@ -467,34 +466,6 @@ def run_with_tmpdir(
467466
)
468467

469468

470-
def run(
471-
context: ClonedFeedstockContext,
472-
migrator: Migrator,
473-
git_backend: GitPlatformBackend,
474-
rerender: bool = True,
475-
base_branch: str = "main",
476-
**kwargs: typing.Any,
477-
) -> tuple[MigrationUidTypedDict, dict] | tuple[Literal[False], Literal[False]]:
478-
"""
479-
For a given feedstock and migration run the migration in a temporary directory that will be deleted after the
480-
migration is complete.
481-
482-
The parameters are the same as for the `run` function. The only difference is that you pass a FeedstockContext
483-
instance instead of a ClonedFeedstockContext instance.
484-
485-
The exceptions are the same as for the `run` function.
486-
"""
487-
with context.reserve_clone_directory() as cloned_context:
488-
return run(
489-
context=cloned_context,
490-
migrator=migrator,
491-
git_backend=git_backend,
492-
rerender=rerender,
493-
base_branch=base_branch,
494-
**kwargs,
495-
)
496-
497-
498469
def run(
499470
context: ClonedFeedstockContext,
500471
migrator: Migrator,
@@ -879,10 +850,11 @@ def _run_migrator_on_feedstock_branch(
879850
return good_prs, break_loop
880851

881852

882-
def _is_migrator_done(_mg_start, good_prs, time_per, pr_limit):
853+
def _is_migrator_done(
854+
_mg_start, good_prs, time_per, pr_limit, git_backend: GitPlatformBackend
855+
):
883856
curr_time = time.time()
884-
backend = github_backend()
885-
api_req = backend.get_api_requests_left()
857+
api_req = git_backend.get_api_requests_left()
886858

887859
if curr_time - START_TIME > TIMEOUT:
888860
logger.info(
@@ -960,7 +932,7 @@ def _run_migrator(
960932

961933
if package:
962934
if package not in possible_nodes:
963-
logger.warning(
935+
logger.info(
964936
f"Package {package} is not a candidate for migration of {migrator_name}"
965937
)
966938
return 0
@@ -998,7 +970,9 @@ def _run_migrator(
998970
flush=True,
999971
)
1000972

1001-
if _is_migrator_done(_mg_start, good_prs, time_per, migrator.pr_limit):
973+
if _is_migrator_done(
974+
_mg_start, good_prs, time_per, migrator.pr_limit, git_backend
975+
):
1002976
return 0
1003977

1004978
for node_name in possible_nodes:
@@ -1015,7 +989,9 @@ def _run_migrator(
1015989
):
1016990
# Don't let CI timeout, break ahead of the timeout so we make certain
1017991
# to write to the repo
1018-
if _is_migrator_done(_mg_start, good_prs, time_per, migrator.pr_limit):
992+
if _is_migrator_done(
993+
_mg_start, good_prs, time_per, migrator.pr_limit, git_backend
994+
):
1019995
break
1020996

1021997
base_branches = migrator.get_possible_feedstock_branches(attrs)
@@ -1370,6 +1346,7 @@ def main(ctx: CliContext, package: str | None = None) -> None:
13701346
temp,
13711347
time_per_migrator[mg_ind],
13721348
git_backend,
1349+
package,
13731350
)
13741351
if good_prs > 0:
13751352
pass
@@ -1384,5 +1361,5 @@ def main(ctx: CliContext, package: str | None = None) -> None:
13841361
# ],
13851362
# )
13861363

1387-
logger.info("API Calls Remaining: %d", github_backend().get_api_requests_left())
1364+
logger.info(f"API Calls Remaining: {git_backend.get_api_requests_left()}")
13881365
logger.info("Done")

conda_forge_tick/git_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
GithubPullRequestMergeableState,
4040
GithubRepository,
4141
PullRequestData,
42+
PullRequestDataValid,
4243
PullRequestInfoHead,
4344
PullRequestState,
4445
)
@@ -1045,7 +1046,7 @@ def create_pull_request(
10451046
logger.debug("==============================================================")
10461047

10471048
now = datetime.now()
1048-
return PullRequestData.model_validate(
1049+
return PullRequestDataValid.model_validate(
10491050
{
10501051
"ETag": "GITHUB_PR_ETAG",
10511052
"Last-Modified": utils.format_datetime(now),

0 commit comments

Comments
 (0)