diff --git a/CHANGELOG b/CHANGELOG index c32e1c5..cbb60c3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +1.1.3 + - ref: connect to Redis via `ckan.lib.redis.connect_to_redis`, since + `ckan.lib.jobs._connect` does not exist anymore in CKAN 2.12 1.1.2 - fix: `RQJob` dependencies were never honored, because the job IDs in `depends_on` had a superfluous underscore and dependent jobs diff --git a/dcor_shared/rqjob.py b/dcor_shared/rqjob.py index 21f22cc..79ff30f 100644 --- a/dcor_shared/rqjob.py +++ b/dcor_shared/rqjob.py @@ -39,11 +39,11 @@ def __init__(self, def enqueue_job(self, resource: Dict, redis_connect=None): # Import here so module can be loaded without ckan available import ckan.plugins.toolkit as toolkit - from ckan.lib.jobs import _connect as ckan_redis_connect + from ckan.lib.redis import connect_to_redis from rq.job import Job if redis_connect is None: - redis_connect = ckan_redis_connect() + redis_connect = connect_to_redis() jid = f"{resource['package_id']}_{resource['position']}_" jid_cur = jid + self.name @@ -66,8 +66,8 @@ def enqueue_job(self, resource: Dict, redis_connect=None): def enqueue_all_jobs(cls, resource: Dict, ckanext: str): - from ckan.lib.jobs import _connect as ckan_redis_connect - redis_connect = ckan_redis_connect() + from ckan.lib.redis import connect_to_redis + redis_connect = connect_to_redis() # Jobs must be enqueued after the jobs they depend on, otherwise # RQ ignores the dependency. diff --git a/tests/test_rqjob.py b/tests/test_rqjob.py index e5421d0..4b63d19 100644 --- a/tests/test_rqjob.py +++ b/tests/test_rqjob.py @@ -1,7 +1,7 @@ from unittest import mock import uuid -from ckan.lib.jobs import _connect as ckan_redis_connect +from ckan.lib.redis import connect_to_redis import pytest from rq.job import Job @@ -70,7 +70,7 @@ def test_rqjob_enqueue_all_jobs(): RQJob(job_b, ckanext="test_ext", timeout=10) RQJob(job_c, ckanext="other_ext") resource = {"package_id": "pkg", "position": 0} - with mock.patch("ckan.lib.jobs._connect"), \ + with mock.patch("ckan.lib.redis.connect_to_redis"), \ mock.patch("rq.job.Job.exists", return_value=False), \ mock.patch("ckan.plugins.toolkit.enqueue_job") as enqueue_job: RQJob.enqueue_all_jobs(resource, ckanext="test_ext") @@ -118,7 +118,7 @@ def test_rqjob_enqueue_all_jobs_depends_on(): pkg_id = str(uuid.uuid4()) RQJob.enqueue_all_jobs({"package_id": pkg_id, "position": 0}, ckanext="test_ext") - redis_connect = ckan_redis_connect() + redis_connect = connect_to_redis() jobs = [Job.fetch(f"{pkg_id}_0_{name}", connection=redis_connect) for name in ["job_first", "job_second", "job_third"]] try: