Skip to content

Initialize alt ID mapping before loading ontologies#75

Merged
jorgeMFS merged 1 commit intofeat/imputation-improvementsfrom
codex/fix-ontology-mappings-and-run-tests
Aug 10, 2025
Merged

Initialize alt ID mapping before loading ontologies#75
jorgeMFS merged 1 commit intofeat/imputation-improvementsfrom
codex/fix-ontology-mappings-and-run-tests

Conversation

@jorgeMFS
Copy link
Owner

@jorgeMFS jorgeMFS commented Aug 10, 2025

Summary

  • initialize _alt_to_primary before ontology loading so alt IDs are indexed without raising an AttributeError

Testing

  • pytest tests/test_mapping.py::TestOntologyMapper::test_alt_id_and_xref -q (fails: No module named 'yaml')

https://chatgpt.com/codex/tasks/task_e_6897f40728fc8327ba38387c1c91e630

Summary by Sourcery

Bug Fixes:

  • Initialize _alt_to_primary mapping before ontologies are loaded to prevent AttributeError when populating alt IDs

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Aug 10, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The PR ensures that the _alt_to_primary mapping structure is initialized before ontology files are loaded by relocating its instantiation and adding a clarifying comment, preventing AttributeErrors during ontology parsing.

Class diagram for updated OntologyMapper initialization

classDiagram
    class OntologyMapper {
        - config_source
        - config
        - cache_expiry_days
        - _id_regex
        - _alt_to_primary: Dict[str, Dict[str, str]]
        - ontologies
        - default_ontologies
        + __init__(config_source)
        + load_ontologies()
        + _build_id_regex_from_config(config)
    }

    %% Highlight that _alt_to_primary is now initialized before ontologies
    OntologyMapper : _alt_to_primary initialized before ontologies
    OntologyMapper : ontologies = load_ontologies()
Loading

File-Level Changes

Change Details Files
Initialize alt-to-primary mapping before ontology loading
  • Added self._alt_to_primary instantiation before calling load_ontologies()
  • Moved self.ontologies = self.load_ontologies() below the new initialization
  • Inserted a comment explaining why the mapping must exist prior to loading
src/phenoqc/mapping.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@jorgeMFS jorgeMFS merged commit fe1c7c2 into feat/imputation-improvements Aug 10, 2025
@jorgeMFS jorgeMFS deleted the codex/fix-ontology-mappings-and-run-tests branch August 10, 2025 01:28
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @jorgeMFS - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant