Skip to content

Commit

Permalink
Implement lifecycle (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
anneschuth authored Oct 11, 2024
2 parents 131c8dd + 968214e commit 95c2294
Show file tree
Hide file tree
Showing 20 changed files with 362 additions and 59 deletions.
54 changes: 54 additions & 0 deletions amt/api/lifecycles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import logging
from enum import Enum

from fastapi import Request

from amt.core.internationalization import get_current_translation
from amt.schema.lifecycle import Lifecycle

logger = logging.getLogger(__name__)


class Lifecycles(Enum):
ORGANIZATIONAL_RESPONSIBILITIES = "ORGANIZATIONAL_RESPONSIBILITIES"
PROBLEM_ANALYSIS = "PROBLEM_ANALYSIS"
DESIGN = "DESIGN"
DATA_EXPLORATION_AND_PREPARATION = "DATA_EXPLORATION_AND_PREPARATION"
DEVELOPMENT = "DEVELOPMENT"
VERIFICATION_AND_VALIDATION = "VERIFICATION_AND_VALIDATION"
IMPLEMENTATION = "IMPLEMENTATION"
MONITORING_AND_MANAGEMENT = "MONITORING_AND_MANAGEMENT"
PHASING_OUT = "PHASING_OUT"


def get_lifecycle(key: Lifecycles | None, request: Request) -> Lifecycle | None:
"""
Given the key and translation, returns the translated text.
:param key: the key
:param request: request to get the current language
:return: a Lifecycle model with the correct translation
"""

if key is None:
return None

translations = get_current_translation(request)
_ = translations.gettext
# translations are determined at runtime, which is why we use the dictionary below
keys = {
Lifecycles.ORGANIZATIONAL_RESPONSIBILITIES: _("Organizational Responsibilities"),
Lifecycles.PROBLEM_ANALYSIS: _("Problem Analysis"),
Lifecycles.DESIGN: _("Design"),
Lifecycles.DATA_EXPLORATION_AND_PREPARATION: _("Data Exploration and Preparation"),
Lifecycles.DEVELOPMENT: _("Development"),
Lifecycles.VERIFICATION_AND_VALIDATION: _("Verification and Validation"),
Lifecycles.IMPLEMENTATION: _("Implementation"),
Lifecycles.MONITORING_AND_MANAGEMENT: _("Monitoring and Management"),
Lifecycles.PHASING_OUT: _("Phasing Out"),
}
return Lifecycle(id=key.value, name=keys[key])


def get_lifecycles(request: Request) -> list[Lifecycle | None]:
lifecycles: list[Lifecycle | None] = [get_lifecycle(lifecycle, request) for lifecycle in Lifecycles]
return lifecycles
2 changes: 2 additions & 0 deletions amt/api/routes/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from fastapi.responses import HTMLResponse

from amt.api.deps import templates
from amt.api.lifecycles import get_lifecycle
from amt.api.navigation import (
BaseNavigationItem,
Navigation,
Expand Down Expand Up @@ -161,6 +162,7 @@ async def get_project_details(
tab_items = get_project_details_tabs(request)

context = {
"lifecycle": get_lifecycle(project.lifecycle, request),
"system_card": system_card_data,
"instrument_state": instrument_state,
"project": project,
Expand Down
2 changes: 2 additions & 0 deletions amt/api/routes/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from amt.api.ai_act_profile import get_ai_act_profile_selector
from amt.api.deps import templates
from amt.api.lifecycles import get_lifecycles
from amt.api.navigation import Navigation, resolve_base_navigation_items, resolve_navigation_items
from amt.schema.project import ProjectNew
from amt.services.instruments import InstrumentsService
Expand Down Expand Up @@ -61,6 +62,7 @@ async def get_new(
"ai_act_profile": ai_act_profile,
"breadcrumbs": breadcrumbs,
"sub_menu_items": {}, # sub_menu_items disabled for now,
"lifecycles": get_lifecycles(request),
}

response = templates.TemplateResponse(request, "projects/new.html.j2", context)
Expand Down
78 changes: 67 additions & 11 deletions amt/locale/base.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-10-10 11:00+0200\n"
"POT-Creation-Date: 2024-10-10 21:27+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -41,6 +41,42 @@ msgstr ""
msgid "Role"
msgstr ""

#: amt/api/lifecycles.py:39
msgid "Organizational Responsibilities"
msgstr ""

#: amt/api/lifecycles.py:40
msgid "Problem Analysis"
msgstr ""

#: amt/api/lifecycles.py:41
msgid "Design"
msgstr ""

#: amt/api/lifecycles.py:42
msgid "Data Exploration and Preparation"
msgstr ""

#: amt/api/lifecycles.py:43
msgid "Development"
msgstr ""

#: amt/api/lifecycles.py:44
msgid "Verification and Validation"
msgstr ""

#: amt/api/lifecycles.py:45
msgid "Implementation"
msgstr ""

#: amt/api/lifecycles.py:46
msgid "Monitoring and Management"
msgstr ""

#: amt/api/lifecycles.py:47
msgid "Phasing Out"
msgstr ""

#: amt/api/navigation.py:45
msgid "Home"
msgstr ""
Expand Down Expand Up @@ -97,7 +133,7 @@ msgstr ""
msgid "Model"
msgstr ""

#: amt/api/navigation.py:59 amt/site/templates/projects/new.html.j2:114
#: amt/api/navigation.py:59 amt/site/templates/projects/new.html.j2:134
msgid "Instruments"
msgstr ""

Expand Down Expand Up @@ -304,11 +340,31 @@ msgstr ""
msgid "Your project name here"
msgstr ""

#: amt/site/templates/projects/new.html.j2:35
#: amt/site/templates/projects/new.html.j2:37
msgid "Lifecycle"
msgstr ""

#: amt/site/templates/projects/new.html.j2:38
msgid "Select the lifecycle your project is currently in"
msgstr ""

#: amt/site/templates/projects/new.html.j2:38
msgid "Read"
msgstr ""

#: amt/site/templates/projects/new.html.j2:38
msgid "Algorithm Framework on lifecycles"
msgstr ""

#: amt/site/templates/projects/new.html.j2:38
msgid "for background information"
msgstr ""

#: amt/site/templates/projects/new.html.j2:55
msgid "AI Act Profile"
msgstr ""

#: amt/site/templates/projects/new.html.j2:37
#: amt/site/templates/projects/new.html.j2:57
msgid ""
"The AI Act profile provides insight into, among other things, the type of"
" AI system and the associated obligations from the European AI Act. If "
Expand All @@ -317,33 +373,33 @@ msgid ""
"tree."
msgstr ""

#: amt/site/templates/projects/new.html.j2:42
#: amt/site/templates/projects/new.html.j2:62
msgid "Find your AI Act profile"
msgstr ""

#: amt/site/templates/projects/new.html.j2:97
#: amt/site/templates/projects/new.html.j2:117
msgid "Yes"
msgstr ""

#: amt/site/templates/projects/new.html.j2:107
#: amt/site/templates/projects/new.html.j2:127
msgid "No"
msgstr ""

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

#: amt/site/templates/projects/new.html.j2:124
#: amt/site/templates/projects/new.html.j2:144
msgid "Choose one or more instruments"
msgstr ""

#: amt/site/templates/projects/new.html.j2:138
#: amt/site/templates/projects/new.html.j2:158
msgid "Create Project"
msgstr ""

#: amt/site/templates/projects/new.html.j2:152
#: amt/site/templates/projects/new.html.j2:172
msgid "Copy results and close"
msgstr ""

Binary file modified amt/locale/en_US/LC_MESSAGES/messages.mo
Binary file not shown.
87 changes: 67 additions & 20 deletions amt/locale/en_US/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-10-10 11:00+0200\n"
"POT-Creation-Date: 2024-10-10 21:27+0200\n"
"PO-Revision-Date: 2024-07-25 21:01+0200\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: en_US\n"
Expand Down Expand Up @@ -42,6 +42,42 @@ msgstr ""
msgid "Role"
msgstr ""

#: amt/api/lifecycles.py:39
msgid "Organizational Responsibilities"
msgstr ""

#: amt/api/lifecycles.py:40
msgid "Problem Analysis"
msgstr ""

#: amt/api/lifecycles.py:41
msgid "Design"
msgstr ""

#: amt/api/lifecycles.py:42
msgid "Data Exploration and Preparation"
msgstr ""

#: amt/api/lifecycles.py:43
msgid "Development"
msgstr ""

#: amt/api/lifecycles.py:44
msgid "Verification and Validation"
msgstr ""

#: amt/api/lifecycles.py:45
msgid "Implementation"
msgstr ""

#: amt/api/lifecycles.py:46
msgid "Monitoring and Management"
msgstr ""

#: amt/api/lifecycles.py:47
msgid "Phasing Out"
msgstr ""

#: amt/api/navigation.py:45
msgid "Home"
msgstr ""
Expand Down Expand Up @@ -98,7 +134,7 @@ msgstr ""
msgid "Model"
msgstr ""

#: amt/api/navigation.py:59 amt/site/templates/projects/new.html.j2:114
#: amt/api/navigation.py:59 amt/site/templates/projects/new.html.j2:134
msgid "Instruments"
msgstr ""

Expand Down Expand Up @@ -305,11 +341,31 @@ msgstr ""
msgid "Your project name here"
msgstr ""

#: amt/site/templates/projects/new.html.j2:35
#: amt/site/templates/projects/new.html.j2:37
msgid "Lifecycle"
msgstr ""

#: amt/site/templates/projects/new.html.j2:38
msgid "Select the lifecycle your project is currently in"
msgstr ""

#: amt/site/templates/projects/new.html.j2:38
msgid "Read"
msgstr ""

#: amt/site/templates/projects/new.html.j2:38
msgid "Algorithm Framework on lifecycles"
msgstr ""

#: amt/site/templates/projects/new.html.j2:38
msgid "for background information"
msgstr ""

#: amt/site/templates/projects/new.html.j2:55
msgid "AI Act Profile"
msgstr ""

#: amt/site/templates/projects/new.html.j2:37
#: amt/site/templates/projects/new.html.j2:57
msgid ""
"The AI Act profile provides insight into, among other things, the type of"
" AI system and the associated obligations from the European AI Act. If "
Expand All @@ -318,42 +374,33 @@ msgid ""
"tree."
msgstr ""

#: amt/site/templates/projects/new.html.j2:42
#: amt/site/templates/projects/new.html.j2:62
msgid "Find your AI Act profile"
msgstr ""

#: amt/site/templates/projects/new.html.j2:97
#: amt/site/templates/projects/new.html.j2:117
msgid "Yes"
msgstr ""

#: amt/site/templates/projects/new.html.j2:107
#: amt/site/templates/projects/new.html.j2:127
msgid "No"
msgstr ""

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

#: amt/site/templates/projects/new.html.j2:124
#: amt/site/templates/projects/new.html.j2:144
msgid "Choose one or more instruments"
msgstr ""

#: amt/site/templates/projects/new.html.j2:138
#: amt/site/templates/projects/new.html.j2:158
msgid "Create Project"
msgstr ""

#: amt/site/templates/projects/new.html.j2:152
#: amt/site/templates/projects/new.html.j2:172
msgid "Copy results and close"
msgstr ""

#~ msgid "TEST"
#~ msgstr ""

#~ msgid "Algorithmic Management Toolkit (AMT)"
#~ msgstr ""

#~ msgid "done"
#~ msgstr ""

Binary file modified amt/locale/nl_NL/LC_MESSAGES/messages.mo
Binary file not shown.
Loading

0 comments on commit 95c2294

Please sign in to comment.