Skip to content

Commit d9ce5e9

Browse files
committed
Remove starting the supervisor locally
Starting the collector and processor together locally is a foot-gun - it's going to go off and start doing things on production. There's not much point in doing so, so remove the option, but add: make supervisor-collect: collect once make supervisor-clear-queue: clear the queue So that the collector can be tested locally (testing the processor is best done with process-issue and process-errratum)
1 parent b12ba8b commit d9ce5e9

File tree

5 files changed

+33
-25
lines changed

5 files changed

+33
-25
lines changed

Makefile

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -173,18 +173,6 @@ trigger-pipeline:
173173

174174
# Testing and Release Supervisor
175175

176-
.PHONY: supervisor-start
177-
supervisor-start:
178-
DRY_RUN=$(DRY_RUN) $(COMPOSE_SUPERVISOR) up
179-
180-
.PHONY: supervisor-start-detached
181-
supervisor-start-detached:
182-
DRY_RUN=$(DRY_RUN) $(COMPOSE_SUPERVISOR) up -d
183-
184-
.PHONY: supervisor-stop
185-
supervisor-stop:
186-
$(COMPOSE_SUPERVISOR) down
187-
188176
DEBUG_LOWER := $(shell echo $(DEBUG) | tr '[:upper:]' '[:lower:]')
189177
ifeq ($(DEBUG_LOWER),true)
190178
DEBUG_FLAG := --debug
@@ -199,6 +187,16 @@ else
199187
DRY_RUN_FLAG :=
200188
endif
201189

190+
.PHONY: supervisor-clear-queue
191+
supervisor-clear-queue:
192+
$(COMPOSE_SUPERVISOR) run --rm \
193+
supervisor python -m supervisor.main $(DEBUG_FLAG) clear-queue
194+
195+
.PHONY: supervisor-collect
196+
supervisor-collect:
197+
$(COMPOSE_SUPERVISOR) run --rm \
198+
supervisor python -m supervisor.main $(DEBUG_FLAG) collect --no-repeat
199+
202200
.PHONY: process-issue
203201
process-issue:
204202
$(COMPOSE_SUPERVISOR) run --rm \

README-supervisor.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,14 @@ DRY_RUN=true # Don't actually make any changes to issues/errata, just show what
5858
DEBUG=true # Use more detailed logging (shows exactly what would happen for dry run items)
5959
```
6060

61-
## Starting the collector and processor
61+
## Testing the collector
62+
63+
You can test the collection process with:
6264

6365
```
64-
make supervisor-start
66+
make supervisor-clear-queue
67+
make supervisor-collect
6568
```
6669

67-
This runs the services in the foreground, showing logs for monitoring and debugging. If you prefer to run the services in the background, use `make supervisor-start-detached` instead.
70+
That will clear any existing queue items, collect items from scratch,
71+
and log what gets added to the queue.

compose.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,6 @@ services:
151151
command: ["python", "agents/rebase_agent.py"]
152152
profiles: ["agents"]
153153

154-
supervisor-collector:
155-
<<: *supervisor
156-
command: ["python", "-m", "supervisor.main", "collect"]
157-
profiles: ["supervisor"]
158-
159-
supervisor-processor:
160-
<<: *supervisor
161-
command: ["python", "-m", "supervisor.main", "process"]
162-
profiles: ["supervisor"]
163-
164154
# This is here so we can use it for '$(COMPOSE) run'
165155
supervisor:
166156
<<: *supervisor

supervisor/main.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,19 @@ def collect(
123123
asyncio.run(do_collect(repeat, repeat_delay))
124124

125125

126+
async def do_clear_queue():
127+
async with work_queue(os.environ["REDIS_URL"]) as queue:
128+
await queue.remove_all_work_items()
129+
logger.info("Cleared the work item queue")
130+
131+
132+
@app.command()
133+
def clear_queue():
134+
check_env(redis=True)
135+
136+
asyncio.run(do_clear_queue())
137+
138+
126139
@with_http_sessions()
127140
async def process_once(queue: WorkQueue):
128141
work_item = await queue.wait_first_ready_work_item()

supervisor/work_queue.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ async def remove_work_items(self, work_items: Iterable[WorkItem]) -> None:
9898

9999
await self.client.zrem("supervisor_work_queue", *to_remove)
100100

101+
async def remove_all_work_items(self) -> None:
102+
await self.client.delete("supervisor_work_queue")
103+
101104
async def get_all_work_items(self) -> list[WorkItem]:
102105
work_items = await self.client.zrange("supervisor_work_queue", 0, -1)
103106
return [

0 commit comments

Comments
 (0)