Skip to content

Commit 311a442

Browse files
authored
Revert "Readd git backend"
1 parent 3176fcf commit 311a442

File tree

7 files changed

+252
-1563
lines changed

7 files changed

+252
-1563
lines changed

conda_forge_tick/auto_tick.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
from conda_forge_tick.git_utils import (
3131
GIT_CLONE_DIR,
3232
comment_on_pr,
33+
get_github_api_requests_left,
3334
get_repo,
34-
github_backend,
3535
is_github_api_limit_reached,
3636
push_repo,
3737
)
@@ -195,7 +195,13 @@ def run(
195195

196196
# TODO: run this in parallel
197197
feedstock_dir, repo = get_repo(
198-
fctx=feedstock_ctx, branch=branch_name, base_branch=base_branch
198+
fctx=feedstock_ctx,
199+
branch=branch_name,
200+
feedstock=feedstock_ctx.feedstock_name,
201+
protocol=protocol,
202+
pull_request=pull_request,
203+
fork=fork,
204+
base_branch=base_branch,
199205
)
200206
if not feedstock_dir or not repo:
201207
logger.critical(
@@ -612,8 +618,7 @@ def _run_migrator_on_feedstock_branch(
612618
fctx.feedstock_name,
613619
)
614620

615-
if is_github_api_limit_reached():
616-
logger.warning("GitHub API error", exc_info=e)
621+
if is_github_api_limit_reached(e):
617622
break_loop = True
618623

619624
except VersionMigrationError as e:
@@ -694,8 +699,7 @@ def _run_migrator_on_feedstock_branch(
694699

695700
def _is_migrator_done(_mg_start, good_prs, time_per, pr_limit):
696701
curr_time = time.time()
697-
backend = github_backend()
698-
api_req = backend.get_api_requests_left()
702+
api_req = get_github_api_requests_left()
699703

700704
if curr_time - START_TIME > TIMEOUT:
701705
logger.info(
@@ -1127,5 +1131,5 @@ def main(ctx: CliContext) -> None:
11271131
# ],
11281132
# )
11291133

1130-
logger.info("API Calls Remaining: %d", github_backend().get_api_requests_left())
1134+
logger.info("API Calls Remaining: %d", get_github_api_requests_left())
11311135
logger.info("Done")

conda_forge_tick/executors.py

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,9 @@ def __exit__(self, *args, **kwargs):
1616
pass
1717

1818

19-
GIT_LOCK_THREAD = TRLock()
20-
GIT_LOCK_PROCESS = DummyLock()
21-
GIT_LOCK_DASK = DummyLock()
22-
23-
24-
@contextlib.contextmanager
25-
def lock_git_operation():
26-
"""
27-
A context manager to lock git operations - it can be acquired once per thread, once per process,
28-
and once per dask worker.
29-
Note that this is a reentrant lock, so it can be acquired multiple times by the same thread/process/worker.
30-
"""
31-
32-
with GIT_LOCK_THREAD, GIT_LOCK_PROCESS, GIT_LOCK_DASK:
33-
yield
19+
TRLOCK = TRLock()
20+
PRLOCK = DummyLock()
21+
DRLOCK = DummyLock()
3422

3523

3624
logger = logging.getLogger(__name__)
@@ -39,12 +27,10 @@ def lock_git_operation():
3927
class DaskRLock(DaskLock):
4028
"""A reentrant lock for dask that is always blocking and never times out."""
4129

42-
def __init__(self, *args, **kwargs):
43-
super().__init__(*args, **kwargs)
44-
self._rcount = 0
45-
self._rdata = None
30+
def acquire(self):
31+
if not hasattr(self, "_rcount"):
32+
self._rcount = 0
4633

47-
def acquire(self, *args):
4834
self._rcount += 1
4935

5036
if self._rcount == 1:
@@ -53,29 +39,29 @@ def acquire(self, *args):
5339
return self._rdata
5440

5541
def release(self):
56-
if self._rcount == 0:
42+
if not hasattr(self, "_rcount") or self._rcount == 0:
5743
raise RuntimeError("Lock not acquired so cannot be released!")
5844

5945
self._rcount -= 1
6046

6147
if self._rcount == 0:
62-
self._rdata = None
48+
delattr(self, "_rdata")
6349
return super().release()
6450
else:
6551
return None
6652

6753

6854
def _init_process(lock):
69-
global GIT_LOCK_PROCESS
70-
GIT_LOCK_PROCESS = lock
55+
global PRLOCK
56+
PRLOCK = lock
7157

7258

7359
def _init_dask(lock):
74-
global GIT_LOCK_DASK
75-
# it appears we have to construct the lock by name instead
60+
global DRLOCK
61+
# it appears we have to construct the locak by name instead
7662
# of passing the object itself
7763
# otherwise dask uses a regular lock
78-
GIT_LOCK_DASK = DaskRLock(name=lock)
64+
DRLOCK = DaskRLock(name=lock)
7965

8066

8167
@contextlib.contextmanager
@@ -84,8 +70,8 @@ def executor(kind: str, max_workers: int, daemon=True) -> typing.Iterator[Execut
8470
8571
This allows us to easily use other executors as needed.
8672
"""
87-
global GIT_LOCK_DASK
88-
global GIT_LOCK_PROCESS
73+
global DRLOCK
74+
global PRLOCK
8975

9076
if kind == "thread":
9177
with ThreadPoolExecutor(max_workers=max_workers) as pool_t:
@@ -99,7 +85,7 @@ def executor(kind: str, max_workers: int, daemon=True) -> typing.Iterator[Execut
9985
initargs=(lock,),
10086
) as pool_p:
10187
yield pool_p
102-
GIT_LOCK_PROCESS = DummyLock()
88+
PRLOCK = DummyLock()
10389
elif kind in ["dask", "dask-process", "dask-thread"]:
10490
import dask
10591
import distributed
@@ -115,6 +101,6 @@ def executor(kind: str, max_workers: int, daemon=True) -> typing.Iterator[Execut
115101
with distributed.Client(cluster) as client:
116102
client.run(_init_dask, "cftick")
117103
yield ClientExecutor(client)
118-
GIT_LOCK_DASK = DummyLock()
104+
DRLOCK = DummyLock()
119105
else:
120106
raise NotImplementedError("That kind is not implemented")

0 commit comments

Comments
 (0)