Skip to content

fix: add missing enum connectors to resolve ModuleNotFoundError#720

Open
Mutalenic wants to merge 1 commit intoaiondemand:developfrom
Mutalenic:fix-missing-enum-connectors-issue-712
Open

fix: add missing enum connectors to resolve ModuleNotFoundError#720
Mutalenic wants to merge 1 commit intoaiondemand:developfrom
Mutalenic:fix-missing-enum-connectors-issue-712

Conversation

@Mutalenic
Copy link

Description

This PR fixes issue #712 where the fill-db-with-examples Docker service fails with a ModuleNotFoundError when trying to import connectors.example.enum. The error occurred because the fill-examples.sh script references enum connector classes that didn't exist in the codebase.

Root Cause Analysis

connectors/fill-examples.sh triggers synchronization commands for:

  • connectors.example.enum.EnumConnectorApplicationArea
  • connectors.example.enum.EnumConnectorEducationalResourceType
  • connectors.example.enum.EnumConnectorEventMode
  • ...and five other enum connectors

However, src/connectors/example/enum.py and the related enum data files were completely missing.

Changes Made

  1. Added src/connectors/example/enum.py:

    • Introduced BaseEnumConnector for JSON-based enum data loading.
    • Implemented all eight enum connector classes required by fill-examples.sh.
    • Added type hints, documentation, and imports for the relevant database models.
  2. Created enum resource data:

    • Added src/connectors/example/resources/enum/ directory.
    • Added eight JSON files containing sample data for:
      • application_areas.json
      • educational_resource_types.json
      • event_modes.json
      • event_statuses.json
      • languages.json
      • licenses.json
      • organisation_types.json
      • news_categories.json

Implementation Details

  • Each enum connector subclasses BaseEnumConnector for consistency.
  • JSON files follow the expected name/definition/official schema.
  • Follows the same patterns as existing example connectors.

How to Test

  1. Resolve original error:
    docker compose up fill-db-with-examples
  2. Syntax & structure checks (local)
    • python -m py_compile src/connectors/example/enum.py
    • AST inspection confirming all expected EnumConnector* classes exist.
  3. JSON validation
    • Loaded every file under src/connectors/example/resources/enum/ to ensure valid JSON and required fields.
  4. Module path check
    • Verified that connectors.example.enum resolves to the new module for all classes referenced in connectors/fill-examples.sh.

Testing Results

  • enum.py compiles and contains all required classes.
  • ✅ All eight JSON files load successfully with correct schema and sample data.
  • ✅ Module paths in fill-examples.sh now resolve, eliminating the ModuleNotFoundError.

Benefits

  • Restores the fill-db-with-examples workflow during local setup.
  • Provides realistic sample data for all enum types.
  • Aligns enum connectors with the existing example connector architecture.

Checklist

  • A self-review has been conducted checking:
    • No unintended changes have been committed.
  • All CI checks pass before pinging a reviewer, or provide an explanation if they do not.
  • The PR title matches the changelog entry's one-line description.

Related Issues


Note for ESoC 2026 Application

- Create src/connectors/example/enum.py with all required EnumConnector classes
- Add EnumConnectorApplicationArea, EnumConnectorEducationalResourceType, etc.
- Create corresponding JSON data files in src/connectors/example/resources/enum/
- Implement BaseEnumConnector class for consistent enum data loading
- Add proper documentation and type hints for all enum connectors

Fixes aiondemand#712: Resolves 'No module named connectors.example.enum' error
when running 'docker compose up fill-db-with-examples'
Copilot AI review requested due to automatic review settings March 5, 2026 11:28
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes fill-db-with-examples failing with ModuleNotFoundError: No module named 'connectors.example.enum' by adding the missing example enum connector module and providing JSON-backed example enum datasets.

Changes:

  • Added src/connectors/example/enum.py with a shared BaseEnumConnector and the 8 EnumConnector* classes referenced by connectors/fill-examples.sh.
  • Added JSON enum resource files under src/connectors/example/resources/enum/ for the 8 enum connectors.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/connectors/example/enum.py Introduces enum connector classes that load JSON-backed enum/taxonomy data into the DB.
src/connectors/example/resources/enum/application_areas.json Example enum data for application areas.
src/connectors/example/resources/enum/educational_resource_types.json Example enum data for educational resource types.
src/connectors/example/resources/enum/event_modes.json Example enum data for event modes.
src/connectors/example/resources/enum/event_statuses.json Example enum data for event statuses.
src/connectors/example/resources/enum/languages.json Example enum data for languages.
src/connectors/example/resources/enum/licenses.json Example enum data for licenses.
src/connectors/example/resources/enum/organisation_types.json Example enum data for organisation types.
src/connectors/example/resources/enum/news_categories.json Example enum data for news categories.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"""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.
"""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.
"""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.
"""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.
"""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.
"""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.
"""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.
"""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.
Comment on lines +19 to +24
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)
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Error in initial setup of repository

2 participants