macxred / cashctrl_ledger

Implementation of the abstract pyledger.LegderEngine interface with CashCtrl accounting service.
MIT License
0 stars 0 forks source link

New package for Shared code #61

Closed AlexTheWizardL closed 3 weeks ago

AlexTheWizardL commented 2 months ago

We should create a package that will contain the shared code that can be used across our independent packages.

Proposed package names:

modules list from the cashctrl_api package that should be moved:

Modules list from the cashctrl_ledger package that should be moved:

Here is the finalized structure for the ledger_df package, including points on how it follows community standards:

Proposed Structure for ledger_df

ledger_df/
│
├── ledger_df/
│   ├── __init__.py
│   ├── enforce_dtypes.py   # Contains enforce_dtypes() function
│   ├── nest.py             # Contains nest() and unnest() functions
│   ├── string.py           # Contains df_to_consistent_str() function
│   └── testing.py          # Contains assert_frame_equal() function
│
├── tests/
│   ├── __init__.py
│   ├── test_enforce_dtypes.py
│   ├── test_nest.py
│   ├── test_string.py
│   └── test_dataframe.py
│
└── setup.py

Explanation

  1. Root Directory (ledger_df/):

    • Contains the setup.py file for package configuration, following the standard practice for Python packages.
    • Contains the main __init__.py file to mark this directory as a package.
  2. Package Directory (ledger_df/ledger_df/):

    • Contains the __init__.py file to mark this directory as a package.
    • enforce_dtypes.py with the enforce_dtypes() function for data type enforcement.
    • nest.py with the nest() and unnest() functions for handling hierarchical data.
    • string.py with the df_to_consistent_str() function for string manipulation within DataFrames.
    • testing.py with the assert_frame_equal() function for DataFrame validation and testing.
  3. Tests Directory (ledger_df/tests/):

    • Contains the __init__.py file to mark this directory as a package.
    • test_enforce_dtypes.py for testing the enforce_dtypes() function.
    • test_nest.py for testing the nest() and unnest() functions.
    • test_string.py for testing the df_to_consistent_str() function.
    • test_dataframe.py for testing the assert_frame_equal() function.

Package Initialization (ledger_df/ledger_df/__init__.py):

In the __init__.py file of the ledger_df package, you can import the main functions and classes to make them easily accessible:

from .enforce_dtypes import enforce_dtypes
from .nest import nest, unnest
from .string import df_to_consistent_str
from .testing import assert_frame_equal

Inspiration from Python Open Source Projects:

This structure maintains a focus on DataFrame operations, ensuring the ledger_df package is modular, maintainable, and user-friendly.

Additionally, we need to include all steps from milestone#2 to maintain high code quality for our package.

Readme.md file proposal:

Click to see proposed Readme.md file # ledger_df `ledger_df` is a Python package designed to provide shared DataFrame operations that can be used across multiple modules, promoting code reuse and consistency across multiple modules. By maintaining type consistency and utilizing a drop indexes approach similar to pandas, this package simplifies DataFrame manipulations and ensures robust testing. By centralizing shared DataFrame operations in the we ensure consistency and efficiency in our development processes, helping to maintain high-quality code across various projects. ## Key Features: - Data type enforcement for DataFrames. - Nesting and unnesting operations for hierarchical data. - String manipulation functions for DataFrames. - Validation utilities for testing DataFrame content. ## Installation Easily install the package using pip: ```bash pip install https://github.com/macxred/ledger_df/tarball/main ``` ## Testing Strategy Tests are housed in the [ledger_df/tests](tests) directory and are automatically executed via GitHub Actions. This ensures that the code is tested after each commit, during pull requests, and on a daily schedule. We prefer pytest for its straightforward and readable syntax over the unittest package from the standard library. ## Package Development and Contribution See [cashctrl_api /CONTRIBUTING.md](https://github.com/macxred/cashctrl_api/blob/main/CONTRIBUTING.md) for: - Setting Up Your Development Environment - Type Consistency with DataFrames - Standards and Best Practices - Leveraging AI Tools - Shared Learning through Open Source

Further steps: