Skip to content

Conversation

b-rodrigues
Copy link
Collaborator

This commit introduces a significant refactoring of the R package's core functionality related to Nix pipeline generation, dependency parsing, and code quality.

Key changes include:

  1. Generic Derivation Function (R/rixpress.R, R/derivs.R):

    • Introduced a generic makeDerivation Nix function in pipeline.nix generation, replacing separate makeRDerivation, makePyDerivation, and makeJlDerivation.
    • Updated rxp_* functions in R/derivs.R to use this generic Nix function with a type parameter (e.g., "R", "Py", "Jl").
  2. Refactored Library Generation (R/parse_pkgs.R):

    • Consolidated generate_r_libraries_from_nix, generate_py_libraries_from_nix, and generate_jl_libraries_from_nix into a single generate_r_or_py_libraries_from_nix function.
    • This function now accepts a language-specific configuration object (lang_config) to manage parameters like Nix block names, import formatters, and file patterns, reducing code duplication.
  3. Refactored Dependency Extraction (R/generate_dag.R):

    • Introduced extract_script_dependencies helper function to consolidate common logic for parsing dependencies from R, Python, and Julia script snippets.
    • QMD/RMD parsing remains distinct due to its nature.
    • Improved handling of unhandled derivation types.
  4. Simplified rixpress() Function (R/rixpress.R):

    • Broke down the main rixpress() function into smaller, more focused internal helper functions: .process_nix_configs (for handling Nix environments and additional files) and .orchestrate_library_generation (for calling library generation scripts).
  5. Refactored gen_pipeline() (R/rixpress.R):

    • Introduced a language configuration list (.PIPELINE_LANG_CONFIGS) to manage language-specific settings (e.g., script_cmd, load_line_func) for injecting dependency loading logic into pipeline.nix.
  6. Code Quality Improvements (All Modified Files):

    • Enhanced comments throughout the refactored files to improve clarity and explain complex logic (e.g., Nix code generation, regex patterns, configuration object structures).
    • Improved variable names for better readability.
    • Strengthened error handling in some areas (e.g., parsing Nix environments in R/rixpress.R).

These changes aim to make the codebase more modular, maintainable, readable, and easier to extend for future development.

google-labs-jules bot and others added 2 commits May 21, 2025 14:42
This commit introduces a significant refactoring of the R package's core functionality related to Nix pipeline generation, dependency parsing, and code quality.

Key changes include:

1.  **Generic Derivation Function (`R/rixpress.R`, `R/derivs.R`):**
    *   Introduced a generic `makeDerivation` Nix function in `pipeline.nix` generation, replacing separate `makeRDerivation`, `makePyDerivation`, and `makeJlDerivation`.
    *   Updated `rxp_*` functions in `R/derivs.R` to use this generic Nix function with a `type` parameter (e.g., "R", "Py", "Jl").

2.  **Refactored Library Generation (`R/parse_pkgs.R`):**
    *   Consolidated `generate_r_libraries_from_nix`, `generate_py_libraries_from_nix`, and `generate_jl_libraries_from_nix` into a single `generate_r_or_py_libraries_from_nix` function.
    *   This function now accepts a language-specific configuration object (`lang_config`) to manage parameters like Nix block names, import formatters, and file patterns, reducing code duplication.

3.  **Refactored Dependency Extraction (`R/generate_dag.R`):**
    *   Introduced `extract_script_dependencies` helper function to consolidate common logic for parsing dependencies from R, Python, and Julia script snippets.
    *   QMD/RMD parsing remains distinct due to its nature.
    *   Improved handling of unhandled derivation types.

4.  **Simplified `rixpress()` Function (`R/rixpress.R`):**
    *   Broke down the main `rixpress()` function into smaller, more focused internal helper functions: `.process_nix_configs` (for handling Nix environments and additional files) and `.orchestrate_library_generation` (for calling library generation scripts).

5.  **Refactored `gen_pipeline()` (`R/rixpress.R`):**
    *   Introduced a language configuration list (`.PIPELINE_LANG_CONFIGS`) to manage language-specific settings (e.g., `script_cmd`, `load_line_func`) for injecting dependency loading logic into `pipeline.nix`.

6.  **Code Quality Improvements (All Modified Files):**
    *   Enhanced comments throughout the refactored files to improve clarity and explain complex logic (e.g., Nix code generation, regex patterns, configuration object structures).
    *   Improved variable names for better readability.
    *   Strengthened error handling in some areas (e.g., parsing Nix environments in `R/rixpress.R`).

These changes aim to make the codebase more modular, maintainable, readable, and easier to extend for future development.
@b-rodrigues b-rodrigues deleted the refactor/core-pipeline-logic branch May 22, 2025 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant