Skip to content

Commit 2a81d4c

Browse files
committed
Remove remaining infrastructure for dev ZIM file polling. The call to kick this off was already removed in dba549e
1 parent 6ba5bc8 commit 2a81d4c

File tree

5 files changed

+0
-86
lines changed

5 files changed

+0
-86
lines changed

supervisord.conf

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -198,30 +198,6 @@ stopsignal=TERM
198198
autostart=true
199199
autorestart=true
200200

201-
[program:wp1-zimfile-polling]
202-
; In the docker-compose world, the redis host is just 'redis'
203-
command=/usr/local/bin/rq worker -u redis://redis zimfile-polling
204-
; process_num is required if you specify >1 numprocs
205-
process_name=zimfile-polling-%(process_num)s
206-
207-
; If you want to run more than one zimfile-polling worker, increase this
208-
numprocs=1
209-
210-
; This is the directory from which RQ is run. Be sure to point this to the
211-
; directory where your source code is importable from
212-
directory=/usr/src/app
213-
214-
redirect_stderr=true
215-
stdout_logfile=/var/log/wp1bot/%(program_name)s-%(process_num)s.log
216-
stdout_logfile_maxbytes=100MB
217-
stdout_logfile_backups=5
218-
219-
; RQ requires the TERM signal to perform a warm shutdown. If RQ does not die
220-
; within 10 seconds, supervisor will forcefully kill it
221-
stopsignal=TERM
222-
autostart=true
223-
autorestart=true
224-
225201
[program:wp1-zimfile-scheduling]
226202
; In the docker-compose world, the redis host is just 'redis'
227203
command=/usr/local/bin/rq worker -u redis://redis zimfile-scheduling

wp1/constants.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,4 @@ class AssessmentKind(enum.Enum):
8484

8585
WP1_USER_AGENT = "WP 1.0 bot 1.0.0/Audiodude <audiodude@gmail.com>"
8686

87-
# 2 hours
88-
MAX_ZIM_FILE_POLL_TIME = 2 * 60 * 60
89-
9087
SECONDS_PER_MONTH = 30 * 24 * 60 * 60 # Approximate seconds in a month

wp1/logic/builder.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from wp1.constants import (
1717
CONTENT_TYPE_TO_EXT,
1818
EXT_TO_CONTENT_TYPE,
19-
MAX_ZIM_FILE_POLL_TIME,
2019
TS_FORMAT_WP10,
2120
)
2221
from wp1.credentials import CREDENTIALS, ENV
@@ -744,34 +743,6 @@ def _format_active_schedule_data(schedule):
744743
return data
745744

746745

747-
def on_zim_file_status_poll(task_id):
748-
wp10db = wp10_connect()
749-
redis = redis_connect()
750-
app_logging.configure_logging()
751-
752-
result = zimfarm.is_zim_file_ready(task_id)
753-
logging.info("Polled for ZIM file for task_id=%s, result: %s", task_id, result)
754-
if result == "FILE_READY":
755-
logic_selection.update_zimfarm_task(
756-
wp10db, task_id, "FILE_READY", set_updated_now=True
757-
)
758-
update_version_for_finished_zim(wp10db, task_id)
759-
elif result == "REQUESTED":
760-
requested = logic_selection.zim_file_requested_at_for(wp10db, task_id)
761-
if requested is not None:
762-
now = utcnow().timestamp()
763-
if now - requested > MAX_ZIM_FILE_POLL_TIME:
764-
logic_selection.update_zimfarm_task(wp10db, task_id, "FAILED")
765-
return
766-
767-
# There was no requested time, or the time hasn't expired, re-request
768-
queues.poll_for_zim_file_status(redis, task_id)
769-
elif result == "FAILED":
770-
logic_selection.update_zimfarm_task(wp10db, task_id, "FAILED")
771-
772-
wp10db.close()
773-
774-
775746
def _get_builder_data(builder):
776747
return {
777748
"id": builder["b_id"].decode("utf-8"),

wp1/queues.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ def _get_materializer_queue(redis):
3535
return Queue("materializer", connection=redis)
3636

3737

38-
def _get_zimfile_poll_queue(redis):
39-
return Queue("zimfile-polling", connection=redis)
40-
41-
4238
def _get_zimfile_scheduling_queue(redis):
4339
return Queue("zimfile-scheduling", connection=redis)
4440

@@ -187,14 +183,6 @@ def enqueue_materialize(redis, builder_cls, builder, content_type):
187183
)
188184

189185

190-
def poll_for_zim_file_status(redis, task_id):
191-
poll_q = _get_zimfile_poll_queue(redis)
192-
scheduler = Scheduler(queue=poll_q, connection=redis)
193-
scheduler.enqueue_in(
194-
timedelta(minutes=2), logic_builder.on_zim_file_status_poll, task_id
195-
)
196-
197-
198186
def schedule_recurring_zimfarm_task(
199187
redis: Redis, args, scheduled_time, interval_seconds, repeat_count
200188
):

wp1/zimfarm.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -484,24 +484,6 @@ def _get_task_by_id(task_id):
484484
return r.json()
485485

486486

487-
def is_zim_file_ready(task_id):
488-
data = _get_task_by_id(task_id)
489-
if data is None:
490-
# Some kind of HTTP error (could be 404 if the task hasn't moved
491-
# from requested-tasks to tasks yet). Ignore and we'll retry.
492-
return "REQUESTED"
493-
494-
if data.get("status") == "failed":
495-
return "FAILED"
496-
497-
files = data.get("files", {})
498-
499-
for key, value in files.items():
500-
if value.get("status") == "uploaded":
501-
return "FILE_READY"
502-
return "REQUESTED"
503-
504-
505487
def zim_file_url_for_task_id(task_id):
506488
data = _get_task_by_id(task_id)
507489

0 commit comments

Comments
 (0)