@@ -436,6 +436,7 @@ def run_with_tmpdir(
436436 git_backend : GitPlatformBackend ,
437437 rerender : bool = True ,
438438 base_branch : str = "main" ,
439+ dry_run : bool = False ,
439440 ** kwargs : typing .Any ,
440441) -> tuple [MigrationUidTypedDict , dict ] | tuple [Literal [False ], Literal [False ]]:
441442 """
@@ -454,19 +455,20 @@ def run_with_tmpdir(
454455 git_backend = git_backend ,
455456 rerender = rerender ,
456457 base_branch = base_branch ,
458+ dry_run = dry_run ,
457459 ** kwargs ,
458460 )
459461
460462
461- def _make_and_sync_pr_lazy_json (pr_data ) -> LazyJson :
463+ def _make_and_sync_pr_lazy_json (pr_data , dry_run ) -> LazyJson :
462464 if pr_data :
463465 pr_lazy_json = LazyJson (
464466 os .path .join ("pr_json" , f"{ pr_data .id } .json" ),
465467 )
466468 with pr_lazy_json as __edit_pr_lazy_json :
467469 __edit_pr_lazy_json .update (** pr_data .model_dump (mode = "json" ))
468470
469- if "id" in pr_lazy_json :
471+ if "id" in pr_lazy_json and not dry_run :
470472 sync_lazy_json_object (pr_lazy_json , "file" , ["github_api" ])
471473
472474 else :
@@ -481,6 +483,7 @@ def run(
481483 git_backend : GitPlatformBackend ,
482484 rerender : bool = True ,
483485 base_branch : str = "main" ,
486+ dry_run : bool = False ,
484487 ** kwargs : typing .Any ,
485488) -> tuple [MigrationUidTypedDict , dict ] | tuple [Literal [False ], Literal [False ]]:
486489 """For a given feedstock and migration run the migration
@@ -557,7 +560,7 @@ def run(
557560
558561 # spoof this so it looks like the package is done
559562 pr_data = get_spoofed_closed_pr_info ()
560- pr_lazy_json = _make_and_sync_pr_lazy_json (pr_data )
563+ pr_lazy_json = _make_and_sync_pr_lazy_json (pr_data , dry_run )
561564 _reset_pre_pr_migrator_fields (
562565 context .attrs , migrator_name , is_version = is_version_migration
563566 )
@@ -652,7 +655,7 @@ def run(
652655 comment = rerender_info .rerender_comment ,
653656 )
654657
655- pr_lazy_json = _make_and_sync_pr_lazy_json (pr_data )
658+ pr_lazy_json = _make_and_sync_pr_lazy_json (pr_data , dry_run )
656659
657660 # If we've gotten this far then the node is good
658661 with context .attrs ["pr_info" ] as pri :
@@ -731,6 +734,7 @@ def _run_migrator_on_feedstock_branch(
731734 mctx ,
732735 migrator_name ,
733736 good_prs ,
737+ dry_run ,
734738):
735739 break_loop = False
736740 sync_pr_info = False
@@ -748,6 +752,7 @@ def _run_migrator_on_feedstock_branch(
748752 rerender = migrator .rerender ,
749753 base_branch = base_branch ,
750754 hash_type = attrs .get ("hash_type" , "sha256" ),
755+ dry_run = dry_run ,
751756 )
752757 finally :
753758 fctx .attrs .pop ("new_version" , None )
@@ -901,19 +906,22 @@ def _run_migrator_on_feedstock_branch(
901906 if sync_pr_info :
902907 with attrs ["pr_info" ] as pri :
903908 pass
904- sync_lazy_json_object (pri , "file" , ["github_api" ])
909+ if not dry_run :
910+ sync_lazy_json_object (pri , "file" , ["github_api" ])
905911
906912 if sync_version_pr_info :
907913 with attrs ["version_pr_info" ] as vpri :
908914 pass
909- sync_lazy_json_object (vpri , "file" , ["github_api" ])
915+ if not dry_run :
916+ sync_lazy_json_object (vpri , "file" , ["github_api" ])
910917
911918 return good_prs , break_loop
912919
913920
914- def _is_migrator_done (_mg_start , good_prs , time_per , pr_limit , tried_prs ):
921+ def _is_migrator_done (
922+ _mg_start , good_prs , time_per , pr_limit , tried_prs , backend : GitPlatformBackend
923+ ):
915924 curr_time = time .time ()
916- backend = github_backend ()
917925 api_req = backend .get_api_requests_left ()
918926
919927 if curr_time - START_TIME > TIMEOUT :
@@ -957,7 +965,9 @@ def _is_migrator_done(_mg_start, good_prs, time_per, pr_limit, tried_prs):
957965 return False
958966
959967
960- def _run_migrator (migrator , mctx , temp , time_per , git_backend : GitPlatformBackend ):
968+ def _run_migrator (
969+ migrator , mctx , temp , time_per , git_backend : GitPlatformBackend , dry_run
970+ ):
961971 _mg_start = time .time ()
962972
963973 migrator_name = get_migrator_name (migrator )
@@ -1013,7 +1023,7 @@ def _run_migrator(migrator, mctx, temp, time_per, git_backend: GitPlatformBacken
10131023 )
10141024
10151025 if _is_migrator_done (
1016- _mg_start , good_prs , time_per , migrator .pr_limit , tried_prs
1026+ _mg_start , good_prs , time_per , migrator .pr_limit , tried_prs , git_backend
10171027 ):
10181028 return 0
10191029
@@ -1032,7 +1042,7 @@ def _run_migrator(migrator, mctx, temp, time_per, git_backend: GitPlatformBacken
10321042 # Don't let CI timeout, break ahead of the timeout so we make certain
10331043 # to write to the repo
10341044 if _is_migrator_done (
1035- _mg_start , good_prs , time_per , migrator .pr_limit , tried_prs
1045+ _mg_start , good_prs , time_per , migrator .pr_limit , tried_prs , git_backend
10361046 ):
10371047 break
10381048
@@ -1089,6 +1099,7 @@ def _run_migrator(migrator, mctx, temp, time_per, git_backend: GitPlatformBacken
10891099 mctx = mctx ,
10901100 migrator_name = migrator_name ,
10911101 good_prs = good_prs ,
1102+ dry_run = dry_run ,
10921103 )
10931104 if break_loop :
10941105 break
@@ -1278,15 +1289,16 @@ def _update_graph_with_pr_info():
12781289 dump_graph (gx )
12791290
12801291
1281- def main (ctx : CliContext ) -> None :
1292+ def main (ctx : CliContext , no_update_graph : bool , filter_pattern : str | None ) -> None :
12821293 global START_TIME
12831294 START_TIME = time .time ()
12841295
12851296 _setup_limits ()
12861297
1287- with fold_log_lines ("updating graph with PR info" ):
1288- _update_graph_with_pr_info ()
1289- deploy (ctx , dirs_to_deploy = ["version_pr_info" , "pr_json" , "pr_info" ])
1298+ if not no_update_graph :
1299+ with fold_log_lines ("updating graph with PR info" ):
1300+ _update_graph_with_pr_info ()
1301+ deploy (ctx , dirs_to_deploy = ["version_pr_info" , "pr_json" , "pr_info" ])
12901302
12911303 # record tmp dir so we can be sure to clean it later
12921304 temp = glob .glob ("/tmp/*" )
@@ -1305,7 +1317,7 @@ def main(ctx: CliContext) -> None:
13051317 smithy_version = smithy_version ,
13061318 pinning_version = pinning_version ,
13071319 )
1308- migrators = load_migrators ()
1320+ migrators = load_migrators (pattern = filter_pattern )
13091321
13101322 # compute the time per migrator
13111323 with fold_log_lines ("computing migrator run times" ):
@@ -1339,7 +1351,15 @@ def main(ctx: CliContext) -> None:
13391351 git_backend = github_backend () if not ctx .dry_run else DryRunBackend ()
13401352
13411353 for mg_ind , migrator in enumerate (migrators ):
1342- _run_migrator (migrator , mctx , temp , time_per_migrator [mg_ind ], git_backend )
1354+ _run_migrator (
1355+ migrator ,
1356+ mctx ,
1357+ temp ,
1358+ time_per_migrator [mg_ind ],
1359+ git_backend ,
1360+ dry_run = ctx .dry_run ,
1361+ )
13431362
1344- logger .info ("API Calls Remaining: %d" , github_backend ().get_api_requests_left ())
1363+ if not ctx .dry_run :
1364+ logger .info ("API Calls Remaining: %d" , git_backend .get_api_requests_left ())
13451365 logger .info ("Done" )
0 commit comments