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 #394

Closed jschalk closed 3 days ago

jschalk commented 3 days ago

Summary by Sourcery

Refactor the codebase to use the upsert_sheet function for handling Excel sheet operations, replacing the previous ExcelWriter approach. Update the CI workflow to include xlsxwriter as a dependency. Add tests to ensure the new function works correctly for various scenarios.

Enhancements:

CI:

Tests:

sourcery-ai[bot] commented 3 days ago

Reviewer's Guide by Sourcery

This PR implements a significant refactoring of Excel file handling in the codebase by introducing a new upsert_sheet function that replaces direct usage of ExcelWriter. The changes also include enabling several test files by uncommenting them and updating their implementation to use the new function.

Sequence diagram for upsert_sheet function

sequenceDiagram
    participant User
    participant ExcelHandler
    participant FileSystem
    User->>ExcelHandler: Call upsert_sheet(file_path, sheet_name, dataframe)
    ExcelHandler->>FileSystem: Check if file exists
    alt File does not exist
        ExcelHandler->>FileSystem: Create new file with sheet
    else File exists
        ExcelHandler->>FileSystem: Replace or add sheet
    end
    FileSystem-->>ExcelHandler: Confirmation
    ExcelHandler-->>User: Operation complete

Class diagram for the updated Excel handling

classDiagram
    class ExcelHandler {
        +upsert_sheet(file_path: str, sheet_name: str, dataframe: DataFrame)
    }
    class ExcelWriter
    class DataFrame
    ExcelHandler --> ExcelWriter : uses
    ExcelHandler --> DataFrame : uses
    note for ExcelHandler "Replaces direct usage of ExcelWriter with upsert_sheet function"

File-Level Changes

Change Details Files
Introduced a new upsert_sheet function to handle Excel file operations
  • Created new function to handle both creation and updating of Excel sheets
  • Added support for creating parent directories automatically
  • Implemented sheet replacement functionality for existing files
  • Added error handling for Excel operations
src/f09_brick/pandas_tool.py
Refactored Excel file operations across test files
  • Replaced direct ExcelWriter usage with upsert_sheet function
  • Uncommented and enabled previously disabled test cases
  • Updated test assertions and file paths
  • Added new test cases for upsert_sheet functionality
src/f10_world/test/test_world_etl1_zoo_otx_group.py
src/f10_world/test/test_world_etl1_zoo_otx_node.py
src/f10_world/test/test_world_etl1_zoo_otx_nub.py
src/f10_world/test/test_world_etl1_zoo_otx_road.py
src/f09_brick/test_brick_config/test_pandas_tool_.py
src/f10_world/test/test_world_etl0_jungle_to_zoo.py
src/f10_world/test/test__world_tool_.py
src/f10_world/test/test_world_etl1_zoo_otx_appt.py
src/f10_world/test/test_world_z_examples.py
Updated WorldUnit class implementation to use new Excel handling
  • Replaced ExcelWriter calls with upsert_sheet
  • Added support for new node and road types
  • Updated error handling for pidgin categories
  • Improved file path handling
src/f10_world/world.py
Added new dependency in GitHub Actions workflow
  • Added xlsxwriter package installation step
.github/workflows/run-tests-on-push.yml

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