Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions src/connectors/example/enum.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
"""
Enum connectors for populating taxonomy and enumeration data in the AIOD database.

This module provides connectors for various enumeration types used throughout
the AIOD platform, such as application areas, resource types, event modes, etc.
"""

import pathlib
from typing import Type, TypeVar

from connectors.example.example_connector import ExampleConnector
from database.model.named_relation import NamedRelation

T = TypeVar('T', bound=NamedRelation)

ENUM_RESOURCE_PATH = pathlib.Path(__file__).parent / "resources" / "enum"


class BaseEnumConnector(ExampleConnector[T]):
"""Base class for enum connectors that load enumeration data from JSON files."""

def __init__(self, enum_filename: str, enum_class: Type[T]):
json_path = ENUM_RESOURCE_PATH / f"{enum_filename}.json"
super().__init__(json_path, enum_class)
Comment on lines +19 to +24
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New enum connectors and their JSON resources are not covered by tests. Since src/tests/connectors/example/test_example_connector.py already exercises example connectors, add similar pytest coverage for each EnumConnector* to ensure the modules import correctly and fetch() can parse the new JSON files.

Copilot uses AI. Check for mistakes.


class EnumConnectorApplicationArea(BaseEnumConnector):
"""Connector for application area enumeration data."""

def __init__(self):
from database.model.concept.application_area import ApplicationArea
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

database.model.concept.application_area does not exist in this codebase, so instantiating this connector will raise ModuleNotFoundError/ImportError. Import ApplicationArea from its actual module (database.model.ai_resource.application_area).

Suggested change
from database.model.concept.application_area import ApplicationArea
from database.model.ai_resource.application_area import ApplicationArea

Copilot uses AI. Check for mistakes.
super().__init__("application_areas", ApplicationArea)


class EnumConnectorEducationalResourceType(BaseEnumConnector):
"""Connector for educational resource type enumeration data."""

def __init__(self):
from database.model.concept.educational_resource_type import EducationalResourceType
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

database.model.concept.educational_resource_type does not exist, so this connector cannot be constructed. Import EducationalResourceType from database.model.educational_resource.educational_resource_type.

Suggested change
from database.model.concept.educational_resource_type import EducationalResourceType
from database.model.educational_resource.educational_resource_type import EducationalResourceType

Copilot uses AI. Check for mistakes.
super().__init__("educational_resource_types", EducationalResourceType)


class EnumConnectorEventMode(BaseEnumConnector):
"""Connector for event mode enumeration data."""

def __init__(self):
from database.model.concept.event_mode import EventMode
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

database.model.concept.event_mode does not exist. EventMode is defined via create_taxonomy in database.model.event.event, so this import will fail at runtime.

Suggested change
from database.model.concept.event_mode import EventMode
from database.model.event.event import EventMode

Copilot uses AI. Check for mistakes.
super().__init__("event_modes", EventMode)


class EnumConnectorEventStatus(BaseEnumConnector):
"""Connector for event status enumeration data."""

def __init__(self):
from database.model.concept.event_status import EventStatus
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

database.model.concept.event_status does not exist. EventStatus is defined in database.model.event.event, so this import will fail when the connector is used.

Suggested change
from database.model.concept.event_status import EventStatus
from database.model.event.event import EventStatus

Copilot uses AI. Check for mistakes.
super().__init__("event_statuses", EventStatus)


class EnumConnectorLanguage(BaseEnumConnector):
"""Connector for language enumeration data."""

def __init__(self):
from database.model.concept.language import Language
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

database.model.concept.language does not exist. Language is defined in database.model.agent.language (via create_taxonomy), so this import will fail.

Suggested change
from database.model.concept.language import Language
from database.model.agent.language import Language

Copilot uses AI. Check for mistakes.
super().__init__("languages", Language)


class EnumConnectorLicense(BaseEnumConnector):
"""Connector for license enumeration data."""

def __init__(self):
from database.model.concept.license import License
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

database.model.concept.license does not exist. License is defined in database.model.ai_asset.license, so this import will fail when running the fill script.

Suggested change
from database.model.concept.license import License
from database.model.ai_asset.license import License

Copilot uses AI. Check for mistakes.
super().__init__("licenses", License)


class EnumConnectorOrganisationType(BaseEnumConnector):
"""Connector for organisation type enumeration data."""

def __init__(self):
from database.model.concept.organisation_type import OrganisationType
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

database.model.concept.organisation_type does not exist. OrganisationType is defined in database.model.agent.organisation (via create_taxonomy), so this import will fail.

Suggested change
from database.model.concept.organisation_type import OrganisationType
from database.model.agent.organisation import OrganisationType

Copilot uses AI. Check for mistakes.
super().__init__("organisation_types", OrganisationType)


class EnumConnectorNewsCategory(BaseEnumConnector):
"""Connector for news category enumeration data."""

def __init__(self):
from database.model.concept.news_category import NewsCategory
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

database.model.concept.news_category does not exist. NewsCategory is defined in database.model.news.news_category (via create_taxonomy), so this import will fail.

Suggested change
from database.model.concept.news_category import NewsCategory
from database.model.news.news_category import NewsCategory

Copilot uses AI. Check for mistakes.
super().__init__("news_categories", NewsCategory)
22 changes: 22 additions & 0 deletions src/connectors/example/resources/enum/application_areas.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[
{
"name": "machine learning",
"definition": "Applications involving machine learning algorithms and techniques",
"official": true
},
{
"name": "natural language processing",
"definition": "Applications focused on processing and understanding human language",
"official": true
},
{
"name": "computer vision",
"definition": "Applications involving image and video analysis",
"official": true
},
{
"name": "robotics",
"definition": "Applications in robotics and autonomous systems",
"official": true
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[
{
"name": "course",
"definition": "A structured educational program or series of lessons",
"official": true
},
{
"name": "tutorial",
"definition": "Step-by-step instructional content",
"official": true
},
{
"name": "documentation",
"definition": "Technical documentation and guides",
"official": true
},
{
"name": "video",
"definition": "Video-based educational content",
"official": true
}
]
17 changes: 17 additions & 0 deletions src/connectors/example/resources/enum/event_modes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
{
"name": "online",
"definition": "Virtual events conducted over the internet",
"official": true
},
{
"name": "offline",
"definition": "In-person events at physical locations",
"official": true
},
{
"name": "hybrid",
"definition": "Events combining both online and offline participation",
"official": true
}
]
22 changes: 22 additions & 0 deletions src/connectors/example/resources/enum/event_statuses.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[
{
"name": "upcoming",
"definition": "Events scheduled for the future",
"official": true
},
{
"name": "ongoing",
"definition": "Events currently taking place",
"official": true
},
{
"name": "completed",
"definition": "Events that have finished",
"official": true
},
{
"name": "cancelled",
"definition": "Events that have been cancelled",
"official": true
}
]
27 changes: 27 additions & 0 deletions src/connectors/example/resources/enum/languages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[
{
"name": "english",
"definition": "English language",
"official": true
},
{
"name": "german",
"definition": "German language",
"official": true
},
{
"name": "french",
"definition": "French language",
"official": true
},
{
"name": "spanish",
"definition": "Spanish language",
"official": true
},
{
"name": "italian",
"definition": "Italian language",
"official": true
}
]
27 changes: 27 additions & 0 deletions src/connectors/example/resources/enum/licenses.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[
{
"name": "mit",
"definition": "MIT License - permissive open source license",
"official": true
},
{
"name": "apache-2.0",
"definition": "Apache License 2.0 - permissive open source license",
"official": true
},
{
"name": "gpl-3.0",
"definition": "GNU General Public License v3.0 - copyleft license",
"official": true
},
{
"name": "bsd-3-clause",
"definition": "BSD 3-Clause License - permissive open source license",
"official": true
},
{
"name": "cc-by-4.0",
"definition": "Creative Commons Attribution 4.0 International",
"official": true
}
]
27 changes: 27 additions & 0 deletions src/connectors/example/resources/enum/news_categories.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[
{
"name": "research",
"definition": "News related to research developments and findings",
"official": true
},
{
"name": "technology",
"definition": "Technology-related news and updates",
"official": true
},
{
"name": "events",
"definition": "Announcements and coverage of events",
"official": true
},
{
"name": "funding",
"definition": "News about funding opportunities and grants",
"official": true
},
{
"name": "partnerships",
"definition": "News about collaborations and partnerships",
"official": true
}
]
27 changes: 27 additions & 0 deletions src/connectors/example/resources/enum/organisation_types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[
{
"name": "university",
"definition": "Academic institution providing higher education",
"official": true
},
{
"name": "research institute",
"definition": "Organization focused on research activities",
"official": true
},
{
"name": "company",
"definition": "Commercial business organization",
"official": true
},
{
"name": "non-profit",
"definition": "Non-profit organization",
"official": true
},
{
"name": "government",
"definition": "Government agency or department",
"official": true
}
]
Loading