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

175 enable documentation process #385

Closed jschalk closed 1 week ago

jschalk commented 1 week ago

Summary by Sourcery

Refactor the codebase to improve consistency in path creation and enhance the 'WorldUnit' class with new pidgin management capabilities. Update and expand test coverage to ensure reliability of the new and modified functionalities.

Enhancements:

Tests:

sourcery-ai[bot] commented 1 week ago

Reviewer's Guide by Sourcery

This PR implements a major refactoring of the pidgin/bridge functionality, focusing on renaming and restructuring components to improve code clarity and maintainability. The changes include renaming key functions and attributes, adding new functionality for handling Excel sheets, and introducing a new brick format for account translations.

Updated class diagram for WorldUnit and related classes

classDiagram
    class WorldUnit {
        +WorldID world_id
        +str worlds_dir
        +TimeLinePoint current_time
        +dict[TimeLinePoint, AcctID] events
        +dict[AcctID, PidginUnit] pidgins
        +dict[TimeLineLabel, TimeConversion] timeconversions
        +str _events_dir
        +str _pidgins_dir
        +set[FiscalID] _fiscalunits
        +str _world_dir
        +str _jungle_dir
        +str _zoo_dir
        +set_event(event_id: TimeLinePoint, face_id: AcctID)
        +event_exists(event_id: TimeLinePoint) bool
        +get_event(event_id: TimeLinePoint) AcctID
        +set_pidginunit(x_pidginunit: PidginUnit)
        +add_pidginunit(face_id: AcctID)
        +pidginunit_exists(face_id: AcctID) bool
        +get_pidginunit(face_id: AcctID) PidginUnit
        +del_pidginunit(face_id: TimeLinePoint)
        +del_all_pidginunits()
        +pidgins_empty() bool
        +_pidgin_dir(face_id: AcctID) str
        +save_pidginunit_files(face_id: AcctID)
        +pidgin_dir_exists(face_id: AcctID) bool
        +_set_all_pidginunits_from_dirs()
        +_delete_pidginunit_dir(event_id: TimeLinePoint)
        +load_pidginunit_from_files(face_id: AcctID)
        +set_events_from_events_agg()
        +otx_to_otxinx_staging()
    }

    class OtxToOtx2InxPiginTransformer {
        +str zoo_dir
        +set[TimeLinePoint] legitmate_events
        +transform()
        +insert_legitmate_brick_otx2inx(brick_number: str, zoo_brick_path: str, otx2inx_columns: list[str], otx2inx_df: DataFrame)
    }

    WorldUnit --> OtxToOtx2InxPiginTransformer

    class BridgeUnit {
        +dict otx2inx
        +str unknown_word
        +str otx_road_delimiter
        +str inx_road_delimiter
        +dict nub_label
        +str jaar_type
        +OwnerID face_id
        +set_all_otx2inx(x_otx2inx: dict, raise_exception_if_invalid: bool)
        +set_otx2inx(otx_word: str, inx_word: str)
        +_get_inx_value(otx_word: str) str
        +get_create_inx(otx_word: str, missing_add: bool) str
        +_get_create_roadunit_inx(otx_road) RoadUnit
        +_get_nub_roadnode(x_roadNode: RoadNode) RoadNode
        +otx2inx_exists(otx_word: str, inx_word: str) bool
        +otx_exists(otx_word: str) bool
        +del_otx2inx(otx_word: str)
        +set_nub_label(otx_label: RoadNode, inx_label: RoadNode)
        +_set_new_nub_label_to_otx_inx(otx_label, inx_label)
        +_get_nub_inx_label(otx_label: RoadNode) RoadNode
        +nub_label_exists(otx_label: RoadNode, inx_label: RoadNode) bool
        +nub_otx_label_exists(otx_label: RoadNode) bool
        +del_nub_label(otx_label: RoadNode)
        +_unknown_word_in_otx2inx() bool
        +_otx_road_delimiter_in_otx_words() bool
        +_inx_road_delimiter_in_otx_words() bool
        +_otx_road_delimiter_in_inx_words() bool
        +_inx_road_delimiter_in_inx_words() bool
        +_is_otx_delimiter_inclusion_correct() bool
        +_is_inx_delimiter_inclusion_correct() bool
        +all_otx_parent_roads_exist() bool
        +get_dict() dict
        +get_json() str
    }

File-Level Changes

Change Details Files
Renamed pidgin/bridge-related functions and attributes to improve clarity
  • Renamed 'otx_to_inx' to 'otx2inx' throughout the codebase
  • Renamed 'explicit_label' to 'nub_label' throughout the codebase
  • Updated related function names and variables to match new naming convention
src/f08_pidgin/pidgin.py
src/f08_pidgin/test_pidgin/test_bridgeunit_.py
src/f08_pidgin/pidgin_config.json
Added new Excel sheet handling functionality
  • Added get_sheet_names function to retrieve Excel workbook sheet names
  • Added sheet name assertions in tests to verify correct sheet creation
  • Updated Excel writer mode to append sheets instead of overwriting
src/f09_brick/pandas_tool.py
src/f10_world/test/test_world_jungle_to_zoo.py
Added new brick format for account translations
  • Added brick_format_00113_acct_otx2inx_v0_0_0.json for account translations
  • Updated brick models to include br00113 tables
  • Added new columns and configuration for account translation format
src/f09_brick/brick_formats/brick_format_00113_acct_otx2inx_v0_0_0.json
src/f09_brick/brick_models.py
src/f09_brick/brick_config.json
Refactored file path handling
  • Renamed create_file_path to create_path for better clarity
  • Updated all file path creation calls to use new function name
src/f00_instrument/file.py
src/f10_world/test/test_world_db.py
src/f09_brick/test_brick_config/test_pandas_tool_.py

Possibly linked issues


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).