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

#346 zoo_to_otx working #380

Closed jschalk closed 2 weeks ago

jschalk commented 2 weeks ago

Summary by Sourcery

Refactor the BrickRef class to use a dictionary for attributes, allowing for more complex metadata handling. Update related functions and tests to support this change, including renaming functions for clarity and adding new test cases to verify the updated logic.

Enhancements:

Tests:

sourcery-ai[bot] commented 2 weeks ago

Reviewer's Guide by Sourcery

This PR implements changes to support OTX (One True X) key functionality in the brick reference system. The main changes include modifying the BrickRef class to store attributes with OTX key flags and updating the grouping logic to handle these flags appropriately.

Sequence diagram for setting attributes with OTX keys

sequenceDiagram
    participant Test as Test Suite
    participant BrickRef
    Test->>BrickRef: set_attribute(x_attribute, True)
    BrickRef->>BrickRef: _attributes[x_attribute] = {"otx_key": True}
    Test->>BrickRef: set_attribute(x_attribute, False)
    BrickRef->>BrickRef: _attributes[x_attribute] = {"otx_key": False}

Updated class diagram for BrickRef

classDiagram
    class BrickRef {
        - str brick_name
        - str categorys
        - dict<str, dict<str, bool>> _attributes
        + set_attribute(x_attribute: str, otx_key: bool)
        + list<str> get_headers_list()
        + list<str> get_otx_keys_list()
        + list<str> get_otx_values_list()
    }
    note for BrickRef "Attributes now store OTX key flags"

File-Level Changes

Change Details Files
Modified BrickRef class to support OTX key functionality
  • Changed _attributes from set[str] to dict[str, dict[str, bool]] to store OTX key flags
  • Updated set_attribute method to accept otx_key boolean parameter
  • Added get_otx_keys_list method to return attributes marked as OTX keys
  • Added get_otx_values_list method to return attributes not marked as OTX keys
src/f09_brick/brick.py
src/f09_brick/test_brick_format/test_brick_column.py
Refactored grouping functionality to use SQL for consistent value filtering
  • Renamed get_groupby_dataframe to get_grouping_with_all_values_equal_df
  • Updated SQL query generation to handle OTX key-based grouping
  • Renamed get_consistent_values_sql_query to get_grouping_with_all_values_equal_sql_query
src/f09_brick/pandas_tool.py
src/f00_instrument/db_toolbox.py
src/f09_brick/test_brick_config/test_pandas_tool.py
Updated brick reference handling and file operations
  • Renamed get_brickref to get_brickref_obj for clarity
  • Renamed get_brickref_dict to get_brickref_from_file
  • Added get_brick_format_filename helper function
src/f09_brick/brick_config.py
src/f09_brick/test_brick_config/test_brick_config_.py
Modified zoo_to_otx transformation logic
  • Updated _group_by_brick_columns to use OTX keys for grouping
  • Fixed column ordering in DataFrame operations
  • Added tests for OTX transformation scenarios
src/f10_world/world.py
src/f10_world/test/test_world_jungle.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).