jschalk / jaar

Cross-cultural communication engine built on customizable economic systems. Produces personalized agendas, calendars, finance reports for users.
0 stars 1 forks source link

closes #342 create bridgeunit directly from csv files #356

Closed jschalk closed 1 month ago

jschalk commented 1 month ago

Summary by Sourcery

Introduce the ability to create a BridgeUnit directly from CSV files, enhancing the data handling capabilities. Refactor existing code to use OwnerID for face_id attributes, improving type safety. Update and add tests to ensure the new CSV handling functionality works as expected.

New Features:

Enhancements:

Tests:

sourcery-ai[bot] commented 1 month ago

Reviewer's Guide by Sourcery

This pull request implements changes to create a BridgeUnit directly from CSV files. It modifies the existing code to handle CSV file operations more efficiently and introduces new functionality for loading and saving BridgeUnit data from/to CSV files.

Sequence diagram for loading BridgeUnit from CSV

sequenceDiagram
    participant User
    participant System
    participant BridgeUnit
    participant BridgeKind

    User->>System: Request to load BridgeUnit from CSV
    System->>BridgeUnit: create_dir_valid_bridgeunit(x_dir)
    loop for each BridgeKind
        BridgeUnit->>BridgeKind: _load_otx_to_inx_from_csv(x_dir)
        BridgeUnit->>BridgeKind: _load_explicit_label_from_csv(x_dir)
    end
    System->>User: Return loaded BridgeUnit

Sequence diagram for saving BridgeUnit to CSV

sequenceDiagram
    participant User
    participant System
    participant BridgeUnit
    participant BridgeKind

    User->>System: Request to save BridgeUnit to CSV
    System->>BridgeUnit: save_all_csvs_from_bridgeunit(x_dir)
    loop for each BridgeKind
        BridgeUnit->>BridgeKind: _save_otx_to_inx_csv(x_dir)
        BridgeUnit->>BridgeKind: _save_explicit_label_csv(x_dir)
    end
    System->>User: Confirm save operation

Updated class diagram for BridgeUnit and BridgeKind

classDiagram
    class BridgeKind {
        +OwnerID face_id
        +dict explicit_label
        +str python_type
        +set_all_otx_to_inx(dict, bool)
    }

    class BridgeUnit {
        +OwnerID face_id
        +dict[str, BridgeKind] bridgekinds
        +str unknown_word
        +str otx_road_delimiter
        +str inx_road_delimiter
    }

    BridgeUnit --> BridgeKind : contains

    class OwnerID {
        <<datatype>>
    }

File-Level Changes

Change Details Files
Refactor CSV file handling for BridgeUnit
  • Rename 'save_all_bridgeunit_files' to 'save_all_csvs_from_bridgeunit'
  • Rename '_save_otx_to_inx_dt_file' to '_save_otx_to_inx_csv'
  • Rename '_save_explicit_label_dt_file' to '_save_explicit_label_csv'
  • Rename 'load_otx_to_inx_from_csv' to '_load_otx_to_inx_from_csv'
  • Rename 'load_explicit_label_from_csv' to '_load_explicit_label_from_csv'
src/f09_filter/bridge.py
src/f09_filter/test/test_bridgeunit_dict.py
Implement new functions for creating and loading BridgeUnit from CSV files
  • Add 'get_csvs_loaded_bridgeunit' function to load BridgeUnit data from CSV files
  • Add 'create_dir_valid_bridgeunit' function to create a valid BridgeUnit from directory contents
  • Update test cases to reflect new CSV handling functionality
src/f09_filter/bridge.py
src/f09_filter/test/test_bridgeunit_dict.py
Update data type for 'face_id' attribute
  • Change 'face_id' type from 'str' to 'OwnerID' in BridgeKind class
  • Update 'face_id' type in BridgeUnit class and related functions
src/f09_filter/bridge.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. - **Generate a pull request title:** Write `@sourcery-ai` anywhere in the pull request title to generate a 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. You can also use this command to specify where the summary should be inserted. #### Customizing Your Experience Access your [dashboard](https://app.sourcery.ai) 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 - [Contact our support team](mailto:support@sourcery.ai) for questions or feedback. - Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information. - Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).