fix: add missing enum connectors to resolve ModuleNotFoundError#720
fix: add missing enum connectors to resolve ModuleNotFoundError#720Mutalenic wants to merge 1 commit intoaiondemand:developfrom
Conversation
- 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'
There was a problem hiding this comment.
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.pywith a sharedBaseEnumConnectorand the 8EnumConnector*classes referenced byconnectors/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 |
There was a problem hiding this comment.
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).
| from database.model.concept.application_area import ApplicationArea | |
| from database.model.ai_resource.application_area import ApplicationArea |
| """Connector for educational resource type enumeration data.""" | ||
|
|
||
| def __init__(self): | ||
| from database.model.concept.educational_resource_type import EducationalResourceType |
There was a problem hiding this comment.
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.
| from database.model.concept.educational_resource_type import EducationalResourceType | |
| from database.model.educational_resource.educational_resource_type import EducationalResourceType |
| """Connector for event mode enumeration data.""" | ||
|
|
||
| def __init__(self): | ||
| from database.model.concept.event_mode import EventMode |
There was a problem hiding this comment.
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.
| from database.model.concept.event_mode import EventMode | |
| from database.model.event.event import EventMode |
| """Connector for event status enumeration data.""" | ||
|
|
||
| def __init__(self): | ||
| from database.model.concept.event_status import EventStatus |
There was a problem hiding this comment.
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.
| from database.model.concept.event_status import EventStatus | |
| from database.model.event.event import EventStatus |
| """Connector for organisation type enumeration data.""" | ||
|
|
||
| def __init__(self): | ||
| from database.model.concept.organisation_type import OrganisationType |
There was a problem hiding this comment.
database.model.concept.organisation_type does not exist. OrganisationType is defined in database.model.agent.organisation (via create_taxonomy), so this import will fail.
| from database.model.concept.organisation_type import OrganisationType | |
| from database.model.agent.organisation import OrganisationType |
| """Connector for language enumeration data.""" | ||
|
|
||
| def __init__(self): | ||
| from database.model.concept.language import Language |
There was a problem hiding this comment.
database.model.concept.language does not exist. Language is defined in database.model.agent.language (via create_taxonomy), so this import will fail.
| from database.model.concept.language import Language | |
| from database.model.agent.language import Language |
| """Connector for license enumeration data.""" | ||
|
|
||
| def __init__(self): | ||
| from database.model.concept.license import License |
There was a problem hiding this comment.
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.
| from database.model.concept.license import License | |
| from database.model.ai_asset.license import License |
| """Connector for news category enumeration data.""" | ||
|
|
||
| def __init__(self): | ||
| from database.model.concept.news_category import NewsCategory |
There was a problem hiding this comment.
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.
| from database.model.concept.news_category import NewsCategory | |
| from database.model.news.news_category import NewsCategory |
| 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) |
There was a problem hiding this comment.
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.
Description
This PR fixes issue #712 where the
fill-db-with-examplesDocker service fails with aModuleNotFoundErrorwhen trying to importconnectors.example.enum. The error occurred because thefill-examples.shscript references enum connector classes that didn't exist in the codebase.Root Cause Analysis
connectors/fill-examples.shtriggers synchronization commands for:connectors.example.enum.EnumConnectorApplicationAreaconnectors.example.enum.EnumConnectorEducationalResourceTypeconnectors.example.enum.EnumConnectorEventModeHowever,
src/connectors/example/enum.pyand the related enum data files were completely missing.Changes Made
Added
src/connectors/example/enum.py:BaseEnumConnectorfor JSON-based enum data loading.fill-examples.sh.Created enum resource data:
src/connectors/example/resources/enum/directory.application_areas.jsoneducational_resource_types.jsonevent_modes.jsonevent_statuses.jsonlanguages.jsonlicenses.jsonorganisation_types.jsonnews_categories.jsonImplementation Details
BaseEnumConnectorfor consistency.name/definition/officialschema.How to Test
python -m py_compile src/connectors/example/enum.pyEnumConnector*classes exist.src/connectors/example/resources/enum/to ensure valid JSON and required fields.connectors.example.enumresolves to the new module for all classes referenced inconnectors/fill-examples.sh.Testing Results
enum.pycompiles and contains all required classes.fill-examples.shnow resolve, eliminating theModuleNotFoundError.Benefits
fill-db-with-examplesworkflow during local setup.Checklist
Related Issues
Note for ESoC 2026 Application