Skip to content

Commit

Permalink
Upgrade packages
Browse files Browse the repository at this point in the history
  • Loading branch information
medihack committed Aug 31, 2024
1 parent 8544e90 commit ff5ed4d
Show file tree
Hide file tree
Showing 6 changed files with 997 additions and 900 deletions.
1,848 changes: 976 additions & 872 deletions poetry.lock

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ authors = ["medihack <[email protected]>"]
license = "GPL-3.0-or-later"

[tool.poetry.dependencies]
adit-radis-shared = {git = "https://github.com/openradx/adit-radis-shared.git", rev = "v0.6.6"}
adit-radis-shared = {git = "https://github.com/openradx/adit-radis-shared.git", rev = "v0.6.8"}
adrf = "^0.1.4"
aiofiles = "^23.1.0"
aiofiles = "^24.1.0"
asyncinotify = "^4.0.1"
channels = "^4.0.0"
crispy-bootstrap5 = "^2024.2"
cryptography = "^42.0.2"
cryptography = "^43.0.0"
daphne = "^4.1.0"
Django = "^5.0.4"
django-crispy-forms = "^2.0"
Expand All @@ -36,11 +36,11 @@ pebble = "^5.0.7"
procrastinate = { extras = ["django"], version = "^2.8.0" }
psycopg = { extras = ["binary"], version = "^3.1.13" }
pyparsing = "^3.1.2"
python = ">=3.11,<4.0"
python = ">=3.12,<4.0"
toml = "^0.10.2"
Twisted = { extras = ["tls", "http2"], version = "^24.3.0" }
wait-for-it = "^2.2.2"
watchfiles = "^0.22.0"
watchfiles = "^0.24.0"
whitenoise = "^6.0.0"
django-betterforms = "^2.0.0"

Expand All @@ -55,15 +55,15 @@ django-test-migrations = "^1.3.0"
djangorestframework-stubs = "^3.15.0"
djlint = "^1.19.16"
factory-boy = "^3.1.0"
Faker = "^25.4.0"
Faker = "^28.1.0"
invoke = "^2.1.2"
ipykernel = "^6.29.2"
ipython = "^8.1.1"
nest-asyncio = "^1.5.6"
pydicom = "^2.4.3"
pyright = "^1.1.336"
pytest = "^8.1.1"
pytest-asyncio = "^0.23.5"
pytest-asyncio = "^0.24.0"
pytest-cov = "^5.0.0"
pytest-django = "^4.5.2"
pytest-mock = "^3.10.0"
Expand All @@ -75,7 +75,7 @@ pytest-watch = "^4.2.0"
python-dotenv = "^1.0.0"
pywatchman = "^2.0.0"
requests = "^2.27.1"
ruff = "^0.4.7"
ruff = "^0.6.3"
tiktoken = "^0.7.0"
time-machine = "^2.1.0"
tqdm = "^4.66.2"
Expand Down
6 changes: 1 addition & 5 deletions radis/collections/factories.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Generic, TypeVar

import factory
from adit_radis_shared.accounts.factories import UserFactory
from faker import Faker
Expand All @@ -8,10 +6,8 @@

fake = Faker()

T = TypeVar("T")


class BaseDjangoModelFactory(Generic[T], factory.django.DjangoModelFactory):
class BaseDjangoModelFactory[T](factory.django.DjangoModelFactory):
@classmethod
def create(cls, *args, **kwargs) -> T:
return super().create(*args, **kwargs)
Expand Down
6 changes: 2 additions & 4 deletions radis/rag/factories.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Generic, TypeVar, cast
from typing import cast

import factory
from faker import Faker
Expand All @@ -8,14 +8,12 @@
from .models import Answer, Question, RagInstance, RagJob, RagTask
from .site import retrieval_providers

T = TypeVar("T")

fake = Faker()

MODALITIES = ("CT", "MR", "DX", "PT", "US")


class BaseDjangoModelFactory(Generic[T], factory.django.DjangoModelFactory):
class BaseDjangoModelFactory[T](factory.django.DjangoModelFactory):
@classmethod
def create(cls, *args, **kwargs) -> T:
return super().create(*args, **kwargs)
Expand Down
5 changes: 1 addition & 4 deletions radis/reports/factories.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
import random
from datetime import timezone
from typing import Generic, TypeVar

import factory
from faker import Faker

from .models import Language, Metadata, Modality, Report

T = TypeVar("T")

fake = Faker()

MODALITIES = ("CT", "MR", "DX", "PT", "US")


class BaseDjangoModelFactory(Generic[T], factory.django.DjangoModelFactory):
class BaseDjangoModelFactory[T](factory.django.DjangoModelFactory):
@classmethod
def create(cls, *args, **kwargs) -> T:
return super().create(*args, **kwargs)
Expand Down
16 changes: 9 additions & 7 deletions radis/subscriptions/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
from asyncio import Semaphore
from typing import List

from adit_radis_shared.accounts.models import Group
from adit_radis_shared.common.types import User
from channels.db import database_sync_to_async
from django import db
from django.conf import settings
from django.db.models import Prefetch, QuerySet
from django.db.models import QuerySet

from radis.chats.utils.chat_client import AsyncChatClient
from radis.core.processors import AnalysisTaskProcessor
Expand All @@ -19,9 +21,12 @@

class SubscriptionTaskProcessor(AnalysisTaskProcessor):
def process_task(self, task: SubscriptionTask) -> None:
asyncio.run(self.process_task_async(task))
user: User = task.job.owner
active_group = user.active_group

async def process_task_async(self, task: SubscriptionTask) -> None:
asyncio.run(self.process_task_async(task, active_group))

async def process_task_async(self, task: SubscriptionTask, active_group: Group) -> None:
client = AsyncChatClient()
sem = Semaphore(settings.RAG_LLM_CONCURRENCY_LIMIT)

Expand All @@ -30,7 +35,7 @@ async def process_task_async(self, task: SubscriptionTask) -> None:
await asyncio.gather(
*[
self.process_report(task, report, questions, sem, client)
async for report in task.reports.prefetch_related(Prefetch("language"))
async for report in task.reports.filter(groups=active_group)
]
)
await database_sync_to_async(db.close_old_connections)()
Expand All @@ -43,9 +48,6 @@ async def process_report(
sem: Semaphore,
client: AsyncChatClient,
) -> None:
if report.language.code not in settings.SUPPORTED_LANGUAGES:
raise ValueError(f"Language '{report.language.code}' is not supported.")

async with sem:
results: List[RagResult] = await asyncio.gather(
*[
Expand Down

0 comments on commit ff5ed4d

Please sign in to comment.