Skip to content

Commit

Permalink
Update beslisboom to version v1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
berrydenhartog committed Dec 6, 2024
1 parent 391aae1 commit 9b9edb2
Show file tree
Hide file tree
Showing 27 changed files with 364 additions and 244 deletions.
56 changes: 42 additions & 14 deletions amt/api/ai_act_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

from fastapi import Request

from amt.api.publication_category import PublicationCategories
from amt.core.internationalization import get_current_translation


class AiActProfileItem(Enum):
TYPE = "type"
OPEN_SOURCE = "open_source"
PUBLICATION_CATEGORY = "publication_category"
RISK_GROUP = "risk_group"
CONFORMITY_ASSESSMENT_BODY = "conformity_assessment_body"
SYSTEMIC_RISK = "systemic_risk"
TRANSPARENCY_OBLIGATIONS = "transparency_obligations"
ROLE = "role"
Expand All @@ -24,8 +24,10 @@ def get_translation(item: AiActProfileItem, translations: NullTranslations) -> s
return _("Type")
case AiActProfileItem.OPEN_SOURCE:
return _("Is the application open source?")
case AiActProfileItem.PUBLICATION_CATEGORY:
return _("Publication Category")
case AiActProfileItem.RISK_GROUP:
return _("In what risk group falls the application?")
case AiActProfileItem.CONFORMITY_ASSESSMENT_BODY:
return _("Does a conformity assessment need to be performed by an accredited body")
case AiActProfileItem.SYSTEMIC_RISK:
return _("Is there a systemic risk?")
case AiActProfileItem.TRANSPARENCY_OBLIGATIONS:
Expand Down Expand Up @@ -54,14 +56,17 @@ class AiActProfileSelector:
radio_select: list[SelectAiProfileItem] | None
multiple_select: list[SelectAiProfileItem] | None
binary_select: list[SelectAiProfileItem] | None
dropdown_select: list[SelectAiProfileItem] | None

def __init__(
self,
radio_select: list[SelectAiProfileItem] | None = None,
multiple_select: list[SelectAiProfileItem] | None = None,
dropdown_select: list[SelectAiProfileItem] | None = None,
binary_select: list[SelectAiProfileItem] | None = None,
) -> None:
self.radio_select = radio_select
self.dropdown_select = dropdown_select
self.multiple_select = multiple_select
self.binary_select = binary_select

Expand All @@ -71,32 +76,55 @@ def get_ai_act_profile_selector(request: Request) -> AiActProfileSelector:
"AI-systeem",
"AI-systeem voor algemene doeleinden",
"AI-model voor algemene doeleinden",
"impactvol algoritme",
"niet-impactvol algoritme",
"geen algoritme",
)
role_options = ("aanbieder", "gebruiksverantwoordelijke")
publication_category_options = (*(p.value for p in PublicationCategories), "niet van toepassing")

role_options = (
"aanbieder",
"gebruiksverantwoordelijke",
"aanbieder & gebruiksverantwoordelijke",
"importeur",
"distributeur",
)

risk_group_options = (
"hoog-risico AI",
"geen hoog-risico AI",
"verboden AI",
"uitzondering van toepassing",
"niet van toepassing",
)

conformity_assessment_body_options = ("beoordeling door derde partij", "niet van toepassing")

systemic_risk_options = ("systeemrisico", "geen systeemrisico", "niet van toepassing")
transparency_obligations_options = (
"transparantieverplichtingen",
"geen transparantieverplichtingen",
"niet van toepassing",
)
open_source_options = ("open-source", "geen open-source")
open_source_options = ("open-source", "geen open-source", "niet van toepassing")

translations = get_current_translation(request)

return AiActProfileSelector(
radio_select=[
multiple_select=[
SelectAiProfileItem(AiActProfileItem.ROLE, role_options, translations),
],
dropdown_select=[
SelectAiProfileItem(AiActProfileItem.TYPE, type_options, translations),
SelectAiProfileItem(AiActProfileItem.PUBLICATION_CATEGORY, publication_category_options, translations),
SelectAiProfileItem(AiActProfileItem.RISK_GROUP, risk_group_options, translations),
SelectAiProfileItem(
AiActProfileItem.TRANSPARENCY_OBLIGATIONS, transparency_obligations_options, translations
),
SelectAiProfileItem(AiActProfileItem.SYSTEMIC_RISK, systemic_risk_options, translations),
],
multiple_select=[
SelectAiProfileItem(AiActProfileItem.ROLE, role_options, translations),
],
binary_select=[
SelectAiProfileItem(AiActProfileItem.OPEN_SOURCE, open_source_options, translations),
SelectAiProfileItem(
AiActProfileItem.CONFORMITY_ASSESSMENT_BODY, conformity_assessment_body_options, translations
),
],
radio_select=[],
binary_select=[],
)
38 changes: 0 additions & 38 deletions amt/api/publication_category.py

This file was deleted.

32 changes: 32 additions & 0 deletions amt/api/risk_group.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from collections.abc import Callable

from fastapi import Request

from ..schema.localized_value_item import LocalizedValueItem
from .localizable import LocalizableEnum, get_localized_enum, get_localized_enums


class RiskGroup(LocalizableEnum):
HOOG_RISICO_AI = "hoog-risico AI"
GEEN_HOOG_RISICO_AI = "geen hoog-risico AI"
VERBODEN_AI = "verboden AI"
UITZONDERING_VAN_TOEPASSING = "uitzondering van toepassing"
NIET_VAN_TOEPASSING = "niet van toepassing"

@classmethod
def get_display_values(cls: type["RiskGroup"], _: Callable[[str], str]) -> dict["RiskGroup", str]:
return {
cls.HOOG_RISICO_AI: _("hoog-risico AI"),
cls.GEEN_HOOG_RISICO_AI: _("geen hoog-risico AI"),
cls.VERBODEN_AI: _("verboden AI"),
cls.UITZONDERING_VAN_TOEPASSING: _("uitzondering van toepassing"),
cls.NIET_VAN_TOEPASSING: _("niet van toepassing"),
}


def get_localized_risk_group(key: RiskGroup | None, request: Request) -> LocalizedValueItem | None:
return get_localized_enum(key, request)


def get_localized_risk_groups(request: Request) -> list[LocalizedValueItem | None]:
return get_localized_enums(RiskGroup, request)
8 changes: 5 additions & 3 deletions amt/api/routes/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from amt.api.group_by_category import get_localized_group_by_categories
from amt.api.lifecycles import Lifecycles, get_localized_lifecycle, get_localized_lifecycles
from amt.api.navigation import Navigation, resolve_base_navigation_items, resolve_navigation_items
from amt.api.publication_category import (
get_localized_publication_categories,
from amt.api.risk_group import (
get_localized_risk_groups,
)
from amt.api.routes.shared import get_filters_and_sort_by
from amt.core.authorization import get_user
Expand Down Expand Up @@ -81,7 +81,7 @@ async def get_root(
"start": skip,
"search": search,
"lifecycles": get_localized_lifecycles(request),
"publication_categories": get_localized_publication_categories(request),
"risk_groups": get_localized_risk_groups(request),
"group_by_categories": get_localized_group_by_categories(request),
"filters": localized_filters,
"sort_by": sort_by,
Expand All @@ -105,6 +105,8 @@ async def get_new(
sub_menu_items = resolve_navigation_items([Navigation.ALGORITHMS_OVERVIEW], request) # pyright: ignore [reportUnusedVariable] # noqa
breadcrumbs = resolve_base_navigation_items([Navigation.ALGORITHMS_ROOT, Navigation.ALGORITHM_NEW], request)

# clean up session storage

ai_act_profile = get_ai_act_profile_selector(request)

user = get_user(request)
Expand Down
6 changes: 3 additions & 3 deletions amt/api/routes/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from amt.api.lifecycles import Lifecycles, get_localized_lifecycle
from amt.api.organization_filter_options import OrganizationFilterOptions, get_localized_organization_filter
from amt.api.publication_category import PublicationCategories, get_localized_publication_category
from amt.api.risk_group import RiskGroup, get_localized_risk_group
from amt.schema.localized_value_item import LocalizedValueItem


Expand Down Expand Up @@ -37,8 +37,8 @@ def get_localized_value(key: str, value: str, request: Request) -> LocalizedValu
match key:
case "lifecycle":
localized = get_localized_lifecycle(Lifecycles(value), request)
case "publication-category":
localized = get_localized_publication_category(PublicationCategories[value], request)
case "risk-group":
localized = get_localized_risk_group(RiskGroup[value], request)
case "organization-type":
localized = get_localized_organization_filter(OrganizationFilterOptions(value), request)
case _:
Expand Down
64 changes: 34 additions & 30 deletions amt/locale/base.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 0001-01-01 00:00+0000\n"
"PO-Revision-Date: 0001-01-01 00:00+0000\n"
"POT-Creation-Date: 2024-12-06 12:39+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.15.0\n"
"Generated-By: Babel 2.16.0\n"

#: amt/api/ai_act_profile.py:24
msgid "Type"
Expand All @@ -26,18 +26,22 @@ msgid "Is the application open source?"
msgstr ""

#: amt/api/ai_act_profile.py:28
msgid "Publication Category"
msgid "In what risk group falls the application?"
msgstr ""

#: amt/api/ai_act_profile.py:30
msgid "Is there a systemic risk?"
msgid "Does a conformity assessment need to be performed by an accredited body"
msgstr ""

#: amt/api/ai_act_profile.py:32
msgid "Is there a transparency obligation?"
msgid "Is there a systemic risk?"
msgstr ""

#: amt/api/ai_act_profile.py:34
msgid "Is there a transparency obligation?"
msgstr ""

#: amt/api/ai_act_profile.py:36
msgid "Role"
msgstr ""

Expand Down Expand Up @@ -142,7 +146,7 @@ msgstr ""
msgid "Model"
msgstr ""

#: amt/api/navigation.py:61 amt/site/templates/algorithms/new.html.j2:151
#: amt/api/navigation.py:61 amt/site/templates/algorithms/new.html.j2:170
msgid "Instruments"
msgstr ""

Expand All @@ -165,28 +169,24 @@ msgstr ""
msgid "My organizations"
msgstr ""

#: amt/api/publication_category.py:22
msgid "Impactful algorithm"
#: amt/api/risk_group.py:19
msgid "hoog-risico AI"
msgstr ""

#: amt/api/publication_category.py:23
msgid "Non-impactful algorithm"
#: amt/api/risk_group.py:20
msgid "geen hoog-risico AI"
msgstr ""

#: amt/api/publication_category.py:24
msgid "High-risk AI"
#: amt/api/risk_group.py:21
msgid "verboden AI"
msgstr ""

#: amt/api/publication_category.py:25
msgid "No high-risk AI"
#: amt/api/risk_group.py:22
msgid "uitzondering van toepassing"
msgstr ""

#: amt/api/publication_category.py:26
msgid "Forbidden AI"
msgstr ""

#: amt/api/publication_category.py:27
msgid "Exception of application"
#: amt/api/risk_group.py:23
msgid "niet van toepassing"
msgstr ""

#: amt/api/forms/algorithm.py:19
Expand Down Expand Up @@ -312,13 +312,13 @@ msgid ""
msgstr ""

#: amt/site/templates/algorithms/details_base.html.j2:39
#: amt/site/templates/algorithms/new.html.j2:134
#: amt/site/templates/algorithms/new.html.j2:153
#: amt/site/templates/organizations/members.html.j2:33
msgid "Yes"
msgstr ""

#: amt/site/templates/algorithms/details_base.html.j2:44
#: amt/site/templates/algorithms/new.html.j2:144
#: amt/site/templates/algorithms/new.html.j2:163
#: amt/site/templates/organizations/members.html.j2:36
msgid "No"
msgstr ""
Expand Down Expand Up @@ -548,21 +548,25 @@ msgstr ""
msgid "Find your AI Act profile"
msgstr ""

#: amt/site/templates/algorithms/new.html.j2:153
#: amt/site/templates/algorithms/new.html.j2:112
msgid "Select Option"
msgstr ""

#: amt/site/templates/algorithms/new.html.j2:172
msgid ""
"Overview of instruments for the responsible development, deployment, "
"assessment and monitoring of algorithms and AI-systems."
msgstr ""

#: amt/site/templates/algorithms/new.html.j2:161
#: amt/site/templates/algorithms/new.html.j2:180
msgid "Choose one or more instruments"
msgstr ""

#: amt/site/templates/algorithms/new.html.j2:185
#: amt/site/templates/algorithms/new.html.j2:204
msgid "Create Algorithm"
msgstr ""

#: amt/site/templates/algorithms/new.html.j2:202
#: amt/site/templates/algorithms/new.html.j2:221
msgid "Copy results and close"
msgstr ""

Expand Down Expand Up @@ -852,14 +856,14 @@ msgid "Category"
msgstr ""

#: amt/site/templates/parts/algorithm_search.html.j2:66
msgid "Select publication category"
msgid "Select risk group"
msgstr ""

#: amt/site/templates/parts/algorithm_search.html.j2:84
#: amt/site/templates/parts/algorithm_search.html.j2:82
msgid "Group by"
msgstr ""

#: amt/site/templates/parts/algorithm_search.html.j2:94
#: amt/site/templates/parts/algorithm_search.html.j2:92
msgid "Select group by"
msgstr ""

Expand Down
Binary file modified amt/locale/en_US/LC_MESSAGES/messages.mo
Binary file not shown.
Loading

0 comments on commit 9b9edb2

Please sign in to comment.