Skip to content

Commit 3462efb

Browse files
committed
Revert "Fix cyclic import"
This reverts commit 57d7fb7.
1 parent 57d7fb7 commit 3462efb

16 files changed

+31
-37
lines changed

alws/dramatiq/__init__.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
and it's important for all tasks which involves user interaction
99
to have priority 0.
1010
4. If you need to use async function in your dramatiq task - ALWAYS use
11-
loop from tasks/__init__.py, since creating multiple loops for tasks
11+
loop from this __init__.py, since creating multiple loops for tasks
1212
will break your tasks.
1313
"""
1414

15+
import asyncio
16+
1517
import dramatiq
1618
from dramatiq.brokers.rabbitmq import RabbitmqBroker
1719

@@ -25,10 +27,11 @@
2527
f"{settings.rabbitmq_default_vhost}",
2628
)
2729
dramatiq.set_broker(rabbitmq_broker)
30+
event_loop = asyncio.get_event_loop()
2831

2932
# Tasks import started from here
30-
from alws.dramatiq.tasks.build import build_done, start_build
31-
from alws.dramatiq.tasks.errata import (
33+
from alws.dramatiq.build import build_done, start_build
34+
from alws.dramatiq.errata import (
3235
bulk_errata_release,
3336
bulk_new_errata_release,
3437
release_errata,
@@ -37,6 +40,8 @@
3740
)
3841

3942
# dramatiq.user and dramatiq.products need to go before dramatiq.releases
40-
from alws.dramatiq.tasks.products import perform_product_modification
41-
from alws.dramatiq.tasks.sign_task import complete_sign_task
42-
from alws.dramatiq.tasks.user import perform_user_removal
43+
from alws.dramatiq.products import perform_product_modification
44+
from alws.dramatiq.releases import execute_release_plan, revert_release
45+
from alws.dramatiq.sign_task import complete_sign_task
46+
from alws.dramatiq.tests import complete_test_task
47+
from alws.dramatiq.user import perform_user_removal

alws/dramatiq/tasks/build.py renamed to alws/dramatiq/build.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from alws.crud import build_node as build_node_crud
2222
from alws.crud import test
2323
from alws.dependencies import get_async_db_key
24-
from alws.dramatiq.tasks import event_loop
24+
from alws.dramatiq import event_loop
2525
from alws.errors import (
2626
ArtifactConversionError,
2727
ModuleUpdateError,

alws/dramatiq/tasks/errata.py renamed to alws/dramatiq/errata.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
release_new_errata_record,
1111
reset_matched_erratas_packages_threshold,
1212
)
13-
from alws.dramatiq.tasks import event_loop
13+
from alws.dramatiq import event_loop
1414
from alws.utils.fastapi_sqla_setup import setup_all
1515

1616
__all__ = ["release_errata"]

alws/dramatiq/tasks/products.py renamed to alws/dramatiq/products.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from alws.config import settings
1414
from alws.constants import DRAMATIQ_TASK_TIMEOUT, BuildTaskStatus
1515
from alws.dependencies import get_async_db_key
16-
from alws.dramatiq.tasks import event_loop
16+
from alws.dramatiq import event_loop
1717
from alws.utils.fastapi_sqla_setup import setup_all
1818
from alws.utils.log_utils import setup_logger
1919
from alws.utils.pulp_client import PulpClient

alws/dramatiq/tasks/releases.py renamed to alws/dramatiq/releases.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
from contextlib import asynccontextmanager
2+
13
import dramatiq
24
from fastapi_sqla import open_async_session
35

46
from alws.constants import DRAMATIQ_TASK_TIMEOUT
57
from alws.crud import release as r_crud
68
from alws.dependencies import get_async_db_key
7-
from alws.dramatiq.tasks import event_loop
9+
from alws.dramatiq import event_loop
810
from alws.utils.fastapi_sqla_setup import setup_all
911

1012
__all__ = ["execute_release_plan"]

alws/dramatiq/tasks/sign_task.py renamed to alws/dramatiq/sign_task.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from alws.constants import DRAMATIQ_TASK_TIMEOUT
66
from alws.crud import sign_task
7-
from alws.dramatiq.tasks import event_loop
7+
from alws.dramatiq import event_loop
88
from alws.schemas import sign_schema
99
from alws.utils.fastapi_sqla_setup import setup_all
1010

alws/dramatiq/tasks/__init__.py

-13
This file was deleted.

alws/dramatiq/tasks/tests.py renamed to alws/dramatiq/tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from alws.constants import DRAMATIQ_TASK_TIMEOUT, TestTaskStatus
88
from alws.crud import test as t_crud
99
from alws.dependencies import get_async_db_key
10-
from alws.dramatiq.tasks import event_loop
10+
from alws.dramatiq import event_loop
1111
from alws.schemas.test_schema import TestTaskResult
1212
from alws.utils.fastapi_sqla_setup import setup_all
1313

alws/dramatiq/tasks/user.py renamed to alws/dramatiq/user.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from alws.constants import DRAMATIQ_TASK_TIMEOUT
88
from alws.crud import build as build_crud
99
from alws.dependencies import get_async_db_key
10-
from alws.dramatiq.tasks import event_loop
10+
from alws.dramatiq import event_loop
1111
from alws.utils.fastapi_sqla_setup import setup_all
1212

1313
__all__ = ['perform_user_removal']

alws/routers/releases.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
from fastapi import APIRouter, Depends
44
from fastapi_sqla import AsyncSessionDependency
5-
from sqlalchemy import update
5+
from sqlalchemy import select, update
66
from sqlalchemy.ext.asyncio import AsyncSession
77

8-
from alws import dramatiq
98
from alws import models
109
from alws.auth import get_current_user
1110
from alws.constants import ReleaseStatus
1211
from alws.crud import release as r_crud
1312
from alws.dependencies import get_async_db_key
13+
from alws.dramatiq import execute_release_plan, revert_release
1414
from alws.schemas import release_schema
1515

1616
router = APIRouter(
@@ -97,7 +97,7 @@ async def commit_release(
9797
.values(status=ReleaseStatus.IN_PROGRESS)
9898
)
9999
await db.flush()
100-
dramatiq.tasks.releases.execute_release_plan.send(release_id, user.id)
100+
execute_release_plan.send(release_id, user.id)
101101
return {"message": "Release plan execution has been started"}
102102

103103

@@ -119,7 +119,7 @@ async def revert_db_release(
119119
.values(status=ReleaseStatus.IN_PROGRESS)
120120
)
121121
await db.flush()
122-
dramatiq.tasks.releases.revert_release.send(release_id, user.id)
122+
revert_release.send(release_id, user.id)
123123
return {"message": "Release plan revert has been started"}
124124

125125

alws/routers/sign_task.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ async def complete_sign_task(
7171
task = await sign_task.get_sign_task(db, sign_task_id)
7272
task.ts = datetime.datetime.utcnow() + datetime.timedelta(hours=2)
7373
await db.flush()
74-
dramatiq.tasks.sign_task.complete_sign_task.send(
74+
dramatiq.sign_task.complete_sign_task.send(
7575
sign_task_id, payload.model_dump()
7676
)
7777
return {'success': True}

alws/routers/tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ async def update_test_task_result(
2727
test_task_id: int,
2828
result: test_schema.TestTaskResult,
2929
):
30-
dramatiq.tasks.tests.complete_test_task.send(test_task_id, result.model_dump())
30+
dramatiq.tests.complete_test_task.send(test_task_id, result.model_dump())
3131
return {'ok': True}
3232

3333

tests/fixtures/builds.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from sqlalchemy.orm.session import Session
99

1010
from alws.crud.build import create_build, get_builds
11-
from alws.dramatiq.tasks.build import _start_build
11+
from alws.dramatiq.build import _start_build
1212
from alws.models import Build, Product
1313
from alws.schemas.build_schema import BuildCreate
1414
from tests.constants import ADMIN_USER_ID

tests/fixtures/dramatiq.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from alws.crud import test
99
from alws.crud.build import get_builds
1010
from alws.crud.build_node import safe_build_done
11-
from alws.dramatiq.tasks.build import _start_build, _build_done
11+
from alws.dramatiq.build import _start_build, _build_done
1212
from alws.models import Build
1313
from alws.schemas.build_node_schema import BuildDone
1414
from alws.schemas.build_schema import BuildCreate

tests/test_api/test_products.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from sqlalchemy.ext.asyncio import AsyncSession
44
from sqlalchemy.orm import selectinload
55

6-
from alws.dramatiq.tasks.products import _perform_product_modification
6+
from alws.dramatiq.products import _perform_product_modification
77
from alws.models import Build, Product
88
from tests.mock_classes import BaseAsyncTestCase
99

tests/test_unit/test_products.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
from alws.constants import BuildTaskStatus
1010
from alws.crud.build import create_build
11-
from alws.dramatiq.tasks.build import _start_build
12-
from alws.dramatiq.tasks.products import (
11+
from alws.dramatiq.build import _start_build
12+
from alws.dramatiq.products import (
1313
get_packages_to_blacklist,
1414
group_tasks_by_ref_id,
1515
)

0 commit comments

Comments
 (0)